2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.openecomp.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.BeforeClass;
37 import org.junit.Rule;
38 import org.junit.Test;
39 import org.junit.rules.ExpectedException;
41 import org.openecomp.aai.exceptions.AAIException;
42 import org.openecomp.aai.introspection.Introspector;
43 import org.openecomp.aai.introspection.IntrospectorFactory;
44 import org.openecomp.aai.introspection.LoaderFactory;
45 import org.openecomp.aai.introspection.ModelInjestor;
46 import org.openecomp.aai.introspection.ModelType;
47 import org.openecomp.aai.introspection.Version;
48 import org.openecomp.aai.serialization.engines.QueryStyle;
49 import org.openecomp.aai.serialization.engines.TitanDBEngine;
50 import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
52 public class RelationshipGremlinQueryTest {
54 private ModelInjestor injestor = ModelInjestor.getInstance();
55 private TransactionalGraphEngine dbEngine =
56 new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
57 LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
59 private final Version version = Version.v8;
60 private DynamicJAXBContext context = injestor.getContextForVersion(version);
63 public ExpectedException thrown = ExpectedException.none();
69 public static void configure() {
70 System.setProperty("AJSC_HOME", "./src/test/resources/");
71 System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
78 * @throws JAXBException the JAXB exception
79 * @throws UnsupportedEncodingException the unsupported encoding exception
80 * @throws AAIException the AAI exception
83 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
87 + "\"related-to\" : \"pserver\","
88 + "\"relationship-data\" : [{"
89 + "\"relationship-key\" : \"pserver.hostname\","
90 + "\"relationship-value\" : \"key1\""
94 Unmarshaller unmarshaller = context.createUnmarshaller();
95 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
96 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
97 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
98 Object obj = context.newDynamicEntity("Relationship");
100 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
102 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
103 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
106 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
108 "gremlin query should be " + expected,
110 query.getQueryBuilder().getQuery());
112 "parent gremlin query should be equal to normal query",
114 query.getQueryBuilder().getParentQuery().getQuery());
116 "result type should be pserver",
118 query.getResultType());
125 * @throws JAXBException the JAXB exception
126 * @throws UnsupportedEncodingException the unsupported encoding exception
127 * @throws AAIException the AAI exception
130 public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
133 + "\"related-to\" : \"lag-interface\","
134 + "\"relationship-data\" : [{"
135 + "\"relationship-key\" : \"pserver.hostname\","
136 + "\"relationship-value\" : \"key1\""
138 + "\"relationship-key\" : \"lag-interface.interface-name\","
139 + "\"relationship-value\" : \"key2\""
143 Unmarshaller unmarshaller = context.createUnmarshaller();
144 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
145 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
146 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
147 Object obj = context.newDynamicEntity("Relationship");
149 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
151 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
152 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
154 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
155 + ".has('interface-name', 'key2')";
156 String parentExpected =
157 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
159 "gremlin query should be for node",
161 query.getQueryBuilder().getQuery());
163 "parent gremlin query should be for parent",
165 query.getQueryBuilder().getParentQuery().getQuery());
167 "result type should be lag-interface",
169 query.getResultType());
175 * @throws JAXBException the JAXB exception
176 * @throws UnsupportedEncodingException the unsupported encoding exception
177 * @throws AAIException the AAI exception
180 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
183 + "\"related-to\" : \"cvlan-tag\","
184 + "\"relationship-data\" : [{"
185 + "\"relationship-key\" : \"vce.vnf-id\","
186 + "\"relationship-value\" : \"key1\""
188 + "\"relationship-key\" : \"port-group.interface-id\","
189 + "\"relationship-value\" : \"key2\""
191 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
192 + "\"relationship-value\" : \"655\""
196 Unmarshaller unmarshaller = context.createUnmarshaller();
197 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
198 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
199 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
200 Object obj = context.newDynamicEntity("Relationship");
202 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
204 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
205 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
207 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
208 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
209 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
210 + ".has('cvlan-tag', 655)";
211 String expectedParent =
212 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
213 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
214 + ".has('interface-id', 'key2')";
216 "gremlin query should be " + expected,
218 query.getQueryBuilder().getQuery());
220 "parent gremlin query should be equal the query for port group",
222 query.getQueryBuilder().getParentQuery().getQuery());
224 "result type should be cvlan-tag",
226 query.getResultType());
231 * Scrambled relationship.
233 * @throws JAXBException the JAXB exception
234 * @throws UnsupportedEncodingException the unsupported encoding exception
235 * @throws AAIException the AAI exception
238 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
241 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
242 + "\"relationship-data\" : [{"
243 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
244 + "\"relationship-value\" : \"key5\""
246 + "\"relationship-key\" : \"lag-interface.interface-name\","
247 + "\"relationship-value\" : \"key2\""
249 + "\"relationship-key\" : \"l-interface.interface-name\","
250 + "\"relationship-value\" : \"key3\""
252 + "\"relationship-key\" : \"vlan.vlan-interface\","
253 + "\"relationship-value\" : \"key4\""
255 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
256 + "\"relationship-value\" : \"key1\""
259 scrambledRelationshipSpec(content);
263 * Reversed relationship.
265 * @throws JAXBException the JAXB exception
266 * @throws UnsupportedEncodingException the unsupported encoding exception
267 * @throws AAIException the AAI exception
270 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
273 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
274 + "\"relationship-data\" : [{"
275 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
276 + "\"relationship-value\" : \"key5\""
278 + "\"relationship-key\" : \"vlan.vlan-interface\","
279 + "\"relationship-value\" : \"key4\""
281 + "\"relationship-key\" : \"l-interface.interface-name\","
282 + "\"relationship-value\" : \"key3\""
284 + "\"relationship-key\" : \"lag-interface.interface-name\","
285 + "\"relationship-value\" : \"key2\""
287 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
288 + "\"relationship-value\" : \"key1\""
291 scrambledRelationshipSpec(content);
295 * Ordered ambiguous relationship.
297 * @throws JAXBException the JAXB exception
298 * @throws UnsupportedEncodingException the unsupported encoding exception
299 * @throws AAIException the AAI exception
302 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
305 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
306 + "\"relationship-data\" : [{"
307 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
308 + "\"relationship-value\" : \"key1\""
310 + "\"relationship-key\" : \"lag-interface.interface-name\","
311 + "\"relationship-value\" : \"key2\""
313 + "\"relationship-key\" : \"l-interface.interface-name\","
314 + "\"relationship-value\" : \"key3\""
316 + "\"relationship-key\" : \"vlan.vlan-interface\","
317 + "\"relationship-value\" : \"key4\""
319 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
320 + "\"relationship-value\" : \"key5\""
323 scrambledRelationshipSpec(content);
327 * Scrambled relationship spec.
329 * @param content the content
330 * @throws JAXBException the JAXB exception
331 * @throws UnsupportedEncodingException the unsupported encoding exception
332 * @throws AAIException the AAI exception
334 public void scrambledRelationshipSpec(String content) throws JAXBException, UnsupportedEncodingException, AAIException {
337 Unmarshaller unmarshaller = context.createUnmarshaller();
338 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
339 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
340 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
341 Object obj = context.newDynamicEntity("Relationship");
343 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
345 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
346 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
348 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
349 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
350 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
351 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
352 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
353 + ".has('l3-interface-ipv4-address', 'key5')";
354 String expectedParent =
355 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
356 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
357 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
358 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
359 + ".has('vlan-interface', 'key4')";
361 "gremlin query should be " + expected,
363 query.getQueryBuilder().getQuery());
365 "parent gremlin query should be equal the query for vlan",
367 query.getQueryBuilder().getParentQuery().getQuery());
369 "result type should be l3-interface-ipv4-address-list",
370 "l3-interface-ipv4-address-list",
371 query.getResultType());
378 * @throws JAXBException the JAXB exception
379 * @throws UnsupportedEncodingException the unsupported encoding exception
380 * @throws AAIException the AAI exception
383 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
386 + "\"related-to\" : \"cvlan-tag\","
387 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
388 + "\"relationship-data\" : [{"
389 + "\"relationship-key\" : \"vce.vnf-id\","
390 + "\"relationship-value\" : \"key1\""
392 + "\"relationship-key\" : \"port-group.interface-id\","
393 + "\"relationship-value\" : \"key2\""
395 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
396 + "\"relationship-value\" : \"655\""
400 Unmarshaller unmarshaller = context.createUnmarshaller();
401 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
402 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
403 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
404 Object obj = context.newDynamicEntity("Relationship");
406 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
408 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
409 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
411 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
412 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
413 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
414 + ".has('cvlan-tag', 655)";
415 String expectedParent =
416 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
417 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
418 + ".has('interface-id', 'key2')";
420 "gremlin query should be " + expected,
422 query.getQueryBuilder().getQuery());
424 "parent gremlin query should be equal the query for port group",
426 query.getQueryBuilder().getParentQuery().getQuery());
428 "result type should be cvlan-tag",
430 query.getResultType());
435 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
438 + "\"related-to\" : \"cvlan-tag\","
439 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
442 Unmarshaller unmarshaller = context.createUnmarshaller();
443 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
444 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
445 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
446 Object obj = context.newDynamicEntity("Relationship");
448 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
450 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
451 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
453 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
454 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
455 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
456 + ".has('cvlan-tag', 655)";
457 String expectedParent =
458 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
459 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
460 + ".has('interface-id', 'key2')";
462 "gremlin query should be " + expected,
464 query.getQueryBuilder().getQuery());
466 "parent gremlin query should be equal the query for port group",
468 query.getQueryBuilder().getParentQuery().getQuery());
470 "result type should be cvlan-tag",
472 query.getResultType());
479 * @throws JAXBException the JAXB exception
480 * @throws UnsupportedEncodingException the unsupported encoding exception
481 * @throws AAIException the AAI exception
484 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
487 + "\"related-to\" : \"ctag-pool\","
488 + "\"relationship-data\" : [{"
489 + "\"relationship-key\" : \"complex.physical-location-id\","
490 + "\"relationship-value\" : \"key1\""
492 + "\"relationship-key\" : \"ctag-pool.target-pe\","
493 + " \"relationship-value\" : \"key2\""
495 + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
496 + "\"relationship-value\" : \"key3\""
501 Unmarshaller unmarshaller = context.createUnmarshaller();
502 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
503 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
504 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
505 Object obj = context.newDynamicEntity("Relationship");
507 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
509 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
510 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
513 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
514 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
515 + ".has('target-pe', 'key2')"
516 + ".has('availability-zone-name', 'key3')";
517 String expectedParent =
518 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
521 "gremlin query should be " + expected,
523 query.getQueryBuilder().getQuery());
525 "parent gremlin query should be equal the query for port group",
527 query.getQueryBuilder().getParentQuery().getQuery());
529 "result type should be ctag-pool",
531 query.getResultType());
538 * @throws JAXBException the JAXB exception
539 * @throws UnsupportedEncodingException the unsupported encoding exception
540 * @throws AAIException the AAI exception
543 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
546 + "\"related-to\" : \"vnf\","
547 + "\"relationship-data\" : [{"
548 + "\"relationship-key\" : \"vnf.vnf-id\","
549 + "\"relationship-value\" : \"key1\""
554 Unmarshaller unmarshaller = context.createUnmarshaller();
555 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
556 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
557 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
558 Object obj = context.newDynamicEntity("Relationship");
560 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
562 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
563 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
566 ".has('vnf-id', 'key1')"
567 + ".has('aai-node-type', P.within('vce','vpe','generic-vnf'))";
569 String expectedParent =
570 ".has('vnf-id', 'key1')"
571 + ".has('aai-node-type', P.within('vce','vpe','generic-vnf'))";
574 "gremlin query should be " + expected,
576 query.getQueryBuilder().getQuery());
578 "parent gremlin query should be equal the query for port group",
580 query.getQueryBuilder().getParentQuery().getQuery());
582 "result type should be vnf",
584 query.getResultType());
591 * @throws JAXBException the JAXB exception
592 * @throws UnsupportedEncodingException the unsupported encoding exception
593 * @throws AAIException the AAI exception
596 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
599 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
600 + "\"relationship-data\" : [{"
601 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
602 + "\"relationship-value\" : \"key1\""
604 + "\"relationship-key\" : \"lag-interface.interface-name\","
605 + "\"relationship-value\" : \"key2\""
607 + "\"relationship-key\" : \"l-infeaterface.interface-name\","
608 + "\"relationship-value\" : \"key3\""
610 + "\"relationship-key\" : \"vlan.vlan-interface\","
611 + "\"relationship-value\" : \"key4\""
613 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
614 + "\"relationship-value\" : \"key5\""
617 thrown.expect(AAIException.class);
618 thrown.expectMessage(containsString("invalid object name"));
620 Unmarshaller unmarshaller = context.createUnmarshaller();
621 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
622 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
623 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
624 Object obj = context.newDynamicEntity("Relationship");
626 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
628 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
629 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
634 * Invalid property name.
636 * @throws JAXBException the JAXB exception
637 * @throws UnsupportedEncodingException the unsupported encoding exception
638 * @throws AAIException the AAI exception
641 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
644 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
645 + "\"relationship-data\" : [{"
646 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
647 + "\"relationship-value\" : \"key1\""
649 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\","
650 + "\"relationship-value\" : \"key2\""
652 + "\"relationship-key\" : \"l-interface.interface-name\","
653 + "\"relationship-value\" : \"key3\""
655 + "\"relationship-key\" : \"vlan.vlan-interface\","
656 + "\"relationship-value\" : \"key4\""
658 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
659 + "\"relationship-value\" : \"key5\""
662 thrown.expect(AAIException.class);
663 thrown.expectMessage(containsString("invalid property name"));
665 Unmarshaller unmarshaller = context.createUnmarshaller();
666 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
667 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
668 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
669 Object obj = context.newDynamicEntity("Relationship");
671 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
673 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
674 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);