2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.aai.parsers.query;
23 import static org.hamcrest.CoreMatchers.containsString;
24 import static org.junit.Assert.assertEquals;
26 import java.io.StringReader;
27 import java.io.UnsupportedEncodingException;
29 import javax.xml.bind.JAXBException;
30 import javax.xml.bind.Unmarshaller;
31 import javax.xml.transform.stream.StreamSource;
33 import org.eclipse.persistence.dynamic.DynamicEntity;
34 import org.eclipse.persistence.jaxb.UnmarshallerProperties;
35 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
36 import org.junit.Before;
37 import org.junit.Ignore;
38 import org.junit.Rule;
39 import org.junit.Test;
40 import org.junit.rules.ExpectedException;
41 import org.onap.aai.AAISetup;
42 import org.onap.aai.exceptions.AAIException;
43 import org.onap.aai.introspection.*;
44 import org.onap.aai.nodes.NodeIngestor;
45 import org.onap.aai.serialization.engines.JanusGraphDBEngine;
46 import org.onap.aai.serialization.engines.QueryStyle;
47 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
48 import org.onap.aai.setup.SchemaVersion;
49 import org.springframework.beans.factory.annotation.Autowired;
52 public class RelationshipGremlinQueryTest extends AAISetup {
55 private NodeIngestor injestor;
56 private TransactionalGraphEngine dbEngine;
57 private SchemaVersion version;
58 private DynamicJAXBContext context = injestor.getContextForVersion(version);
61 public ExpectedException thrown = ExpectedException.none();
65 version = new SchemaVersion("v10");
66 dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
67 loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
73 * @throws JAXBException the JAXB exception
74 * @throws UnsupportedEncodingException the unsupported encoding exception
75 * @throws AAIException the AAI exception
78 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
80 String content = "{" + "\"related-to\" : \"pserver\"," + "\"relationship-data\" : [{"
81 + "\"relationship-key\" : \"pserver.hostname\"," + "\"relationship-value\" : \"key1\"" + "}]" + "}";
83 Unmarshaller unmarshaller = context.createUnmarshaller();
84 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
85 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
86 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
87 Object obj = context.newDynamicEntity("Relationship");
89 DynamicEntity entity = (DynamicEntity) unmarshaller
90 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
92 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
93 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
95 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
96 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
97 assertEquals("parent gremlin query should be equal to normal query", expected,
98 query.getQueryBuilder().getParentQuery().getQuery());
99 assertEquals("result type should be pserver", "pserver", query.getResultType());
106 * @throws JAXBException the JAXB exception
107 * @throws UnsupportedEncodingException the unsupported encoding exception
108 * @throws AAIException the AAI exception
111 public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
112 String content = "{" + "\"related-to\" : \"lag-interface\"," + "\"relationship-data\" : [{"
113 + "\"relationship-key\" : \"pserver.hostname\"," + "\"relationship-value\" : \"key1\"" + "}, {"
114 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
117 Unmarshaller unmarshaller = context.createUnmarshaller();
118 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
119 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
120 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
121 Object obj = context.newDynamicEntity("Relationship");
123 DynamicEntity entity = (DynamicEntity) unmarshaller
124 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
126 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
127 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
130 ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
131 + ".has('interface-name', 'key2')";
132 String parentExpected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
133 assertEquals("gremlin query should be for node", expected, query.getQueryBuilder().getQuery());
134 assertEquals("parent gremlin query should be for parent", parentExpected,
135 query.getQueryBuilder().getParentQuery().getQuery());
136 assertEquals("result type should be lag-interface", "lag-interface", query.getResultType());
142 * @throws JAXBException the JAXB exception
143 * @throws UnsupportedEncodingException the unsupported encoding exception
144 * @throws AAIException the AAI exception
147 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
148 String content = "{" + "\"related-to\" : \"cvlan-tag\"," + "\"relationship-data\" : [{"
149 + "\"relationship-key\" : \"vce.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}, {"
150 + "\"relationship-key\" : \"port-group.interface-id\"," + "\"relationship-value\" : \"key2\"" + "},{"
151 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\"," + "\"relationship-value\" : \"655\"" + "}]" + "}";
153 Unmarshaller unmarshaller = context.createUnmarshaller();
154 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
155 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
156 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
157 Object obj = context.newDynamicEntity("Relationship");
159 DynamicEntity entity = (DynamicEntity) unmarshaller
160 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
162 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
163 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
164 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
165 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
166 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
167 + ".has('cvlan-tag', 655)";
168 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
169 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
170 + ".has('interface-id', 'key2')";
171 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
172 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
173 query.getQueryBuilder().getParentQuery().getQuery());
174 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
179 * Scrambled relationship.
181 * @throws JAXBException the JAXB exception
182 * @throws UnsupportedEncodingException the unsupported encoding exception
183 * @throws AAIException the AAI exception
186 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
187 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
188 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
189 + "\"relationship-value\" : \"key5\"" + "},{"
190 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
191 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
192 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
193 + "},{" + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}]"
195 scrambledRelationshipSpec(content);
199 * Reversed relationship.
201 * @throws JAXBException the JAXB exception
202 * @throws UnsupportedEncodingException the unsupported encoding exception
203 * @throws AAIException the AAI exception
206 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
207 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
208 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
209 + "\"relationship-value\" : \"key5\"" + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\","
210 + "\"relationship-value\" : \"key4\"" + "},{" + "\"relationship-key\" : \"l-interface.interface-name\","
211 + "\"relationship-value\" : \"key3\"" + "},{"
212 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
213 + "},{" + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}]"
215 scrambledRelationshipSpec(content);
219 * Ordered ambiguous relationship.
221 * @throws JAXBException the JAXB exception
222 * @throws UnsupportedEncodingException the unsupported encoding exception
223 * @throws AAIException the AAI exception
226 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
227 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
228 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
229 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
230 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
231 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
232 + "},{" + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
233 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
234 scrambledRelationshipSpec(content);
238 * Scrambled relationship spec.
240 * @param content the content
241 * @throws JAXBException the JAXB exception
242 * @throws UnsupportedEncodingException the unsupported encoding exception
243 * @throws AAIException the AAI exception
245 public void scrambledRelationshipSpec(String content)
246 throws JAXBException, UnsupportedEncodingException, AAIException {
248 Unmarshaller unmarshaller = context.createUnmarshaller();
249 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
250 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
251 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
252 Object obj = context.newDynamicEntity("Relationship");
254 DynamicEntity entity = (DynamicEntity) unmarshaller
255 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
257 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
258 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
259 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
260 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
261 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
262 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
263 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
264 + ".has('l3-interface-ipv4-address', 'key5')";
265 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
266 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
267 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
268 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
269 + ".has('vlan-interface', 'key4')";
270 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
271 assertEquals("parent gremlin query should be equal the query for vlan", expectedParent,
272 query.getQueryBuilder().getParentQuery().getQuery());
273 assertEquals("result type should be l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list",
274 query.getResultType());
281 * @throws JAXBException the JAXB exception
282 * @throws UnsupportedEncodingException the unsupported encoding exception
283 * @throws AAIException the AAI exception
286 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
287 String content = "{" + "\"related-to\" : \"cvlan-tag\","
288 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
289 + "\"relationship-data\" : [{" + "\"relationship-key\" : \"vce.vnf-id\","
290 + "\"relationship-value\" : \"key1\"" + "}, {" + "\"relationship-key\" : \"port-group.interface-id\","
291 + "\"relationship-value\" : \"key2\"" + "},{" + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
292 + "\"relationship-value\" : \"655\"" + "}]" + "}";
294 Unmarshaller unmarshaller = context.createUnmarshaller();
295 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
296 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
297 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
298 Object obj = context.newDynamicEntity("Relationship");
300 DynamicEntity entity = (DynamicEntity) unmarshaller
301 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
303 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
304 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
305 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
306 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
307 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
308 + ".has('cvlan-tag', 655)";
309 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
310 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
311 + ".has('interface-id', 'key2')";
312 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
313 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
314 query.getQueryBuilder().getParentQuery().getQuery());
315 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
320 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
321 String content = "{" + "\"related-to\" : \"cvlan-tag\","
322 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
325 Unmarshaller unmarshaller = context.createUnmarshaller();
326 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
327 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
328 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
329 Object obj = context.newDynamicEntity("Relationship");
331 DynamicEntity entity = (DynamicEntity) unmarshaller
332 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
334 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
335 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
336 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
337 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
338 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
339 + ".has('cvlan-tag', 655)";
340 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
341 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
342 + ".has('interface-id', 'key2')";
343 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
344 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
345 query.getQueryBuilder().getParentQuery().getQuery());
346 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
353 * @throws JAXBException the JAXB exception
354 * @throws UnsupportedEncodingException the unsupported encoding exception
355 * @throws AAIException the AAI exception
358 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
359 String content = "{" + "\"related-to\" : \"ctag-pool\"," + "\"relationship-data\" : [{"
360 + "\"relationship-key\" : \"complex.physical-location-id\"," + "\"relationship-value\" : \"key1\""
361 + " }, { " + "\"relationship-key\" : \"ctag-pool.target-pe\"," + " \"relationship-value\" : \"key2\""
362 + " },{" + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
363 + "\"relationship-value\" : \"key3\"" + "}]" + "}";
365 Unmarshaller unmarshaller = context.createUnmarshaller();
366 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
367 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
368 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
369 Object obj = context.newDynamicEntity("Relationship");
371 DynamicEntity entity = (DynamicEntity) unmarshaller
372 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
374 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
375 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
377 String expected = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
378 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
379 + ".has('target-pe', 'key2')" + ".has('availability-zone-name', 'key3')";
380 String expectedParent = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
382 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
383 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
384 query.getQueryBuilder().getParentQuery().getQuery());
385 assertEquals("result type should be ctag-pool", "ctag-pool", query.getResultType());
392 * @throws JAXBException the JAXB exception
393 * @throws UnsupportedEncodingException the unsupported encoding exception
394 * @throws AAIException the AAI exception
397 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
398 String content = "{" + "\"related-to\" : \"vnf\"," + "\"relationship-data\" : [{"
399 + "\"relationship-key\" : \"vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + " }]" + "}";
401 Unmarshaller unmarshaller = context.createUnmarshaller();
402 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
403 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
404 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
405 Object obj = context.newDynamicEntity("Relationship");
407 DynamicEntity entity = (DynamicEntity) unmarshaller
408 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
410 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
411 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
413 String expected = ".has('vnf-id', 'key1')" + ".has('aai-node-type', P.within('vce','generic-vnf'))";
415 String expectedParent = ".has('vnf-id', 'key1')" + ".has('aai-node-type', P.within('vce','generic-vnf'))";
417 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
418 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
419 query.getQueryBuilder().getParentQuery().getQuery());
420 assertEquals("result type should be vnf", "vnf", query.getResultType());
427 * @throws JAXBException the JAXB exception
428 * @throws UnsupportedEncodingException the unsupported encoding exception
429 * @throws AAIException the AAI exception
432 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
433 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
434 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
435 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
436 + "},{" + "\"relationship-key\" : \"l-infeaterface.interface-name\","
437 + "\"relationship-value\" : \"key3\"" + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\","
438 + "\"relationship-value\" : \"key4\"" + "},{"
439 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
440 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
441 thrown.expect(AAIException.class);
442 thrown.expectMessage(containsString("invalid object name"));
444 Unmarshaller unmarshaller = context.createUnmarshaller();
445 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
446 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
447 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
448 Object obj = context.newDynamicEntity("Relationship");
450 DynamicEntity entity = (DynamicEntity) unmarshaller
451 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
453 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
454 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
459 * Invalid property name.
461 * @throws JAXBException the JAXB exception
462 * @throws UnsupportedEncodingException the unsupported encoding exception
463 * @throws AAIException the AAI exception
466 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
467 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
468 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
469 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\"," + "\"relationship-value\" : \"key2\""
470 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
471 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
472 + "},{" + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
473 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
474 thrown.expect(AAIException.class);
475 thrown.expectMessage(containsString("invalid property name"));
477 Unmarshaller unmarshaller = context.createUnmarshaller();
478 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
479 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
480 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
481 Object obj = context.newDynamicEntity("Relationship");
483 DynamicEntity entity = (DynamicEntity) unmarshaller
484 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
486 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
487 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);