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.Ignore;
38 import org.junit.Rule;
39 import org.junit.Test;
40 import org.junit.rules.ExpectedException;
42 import org.openecomp.aai.exceptions.AAIException;
43 import org.openecomp.aai.introspection.Introspector;
44 import org.openecomp.aai.introspection.IntrospectorFactory;
45 import org.openecomp.aai.introspection.LoaderFactory;
46 import org.openecomp.aai.introspection.ModelInjestor;
47 import org.openecomp.aai.introspection.ModelType;
48 import org.openecomp.aai.introspection.Version;
49 import org.openecomp.aai.serialization.engines.QueryStyle;
50 import org.openecomp.aai.serialization.engines.TitanDBEngine;
51 import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
54 public class RelationshipGremlinQueryTest {
56 private ModelInjestor injestor = ModelInjestor.getInstance();
57 private TransactionalGraphEngine dbEngine =
58 new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
59 LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
61 private final Version version = Version.v8;
62 private DynamicJAXBContext context = injestor.getContextForVersion(version);
65 public ExpectedException thrown = ExpectedException.none();
71 public static void configure() {
72 System.setProperty("AJSC_HOME", "./src/test/resources/");
73 System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
80 * @throws JAXBException the JAXB exception
81 * @throws UnsupportedEncodingException the unsupported encoding exception
82 * @throws AAIException the AAI exception
85 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
89 + "\"related-to\" : \"pserver\","
90 + "\"relationship-data\" : [{"
91 + "\"relationship-key\" : \"pserver.hostname\","
92 + "\"relationship-value\" : \"key1\""
96 Unmarshaller unmarshaller = context.createUnmarshaller();
97 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
98 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
99 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
100 Object obj = context.newDynamicEntity("Relationship");
102 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
104 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
105 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
108 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
110 "gremlin query should be " + expected,
112 query.getQueryBuilder().getQuery());
114 "parent gremlin query should be equal to normal query",
116 query.getQueryBuilder().getParentQuery().getQuery());
118 "result type should be pserver",
120 query.getResultType());
127 * @throws JAXBException the JAXB exception
128 * @throws UnsupportedEncodingException the unsupported encoding exception
129 * @throws AAIException the AAI exception
132 public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
135 + "\"related-to\" : \"lag-interface\","
136 + "\"relationship-data\" : [{"
137 + "\"relationship-key\" : \"pserver.hostname\","
138 + "\"relationship-value\" : \"key1\""
140 + "\"relationship-key\" : \"lag-interface.interface-name\","
141 + "\"relationship-value\" : \"key2\""
145 Unmarshaller unmarshaller = context.createUnmarshaller();
146 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
147 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
148 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
149 Object obj = context.newDynamicEntity("Relationship");
151 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
153 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
154 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
156 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
157 + ".has('interface-name', 'key2')";
158 String parentExpected =
159 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
161 "gremlin query should be for node",
163 query.getQueryBuilder().getQuery());
165 "parent gremlin query should be for parent",
167 query.getQueryBuilder().getParentQuery().getQuery());
169 "result type should be lag-interface",
171 query.getResultType());
177 * @throws JAXBException the JAXB exception
178 * @throws UnsupportedEncodingException the unsupported encoding exception
179 * @throws AAIException the AAI exception
182 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
185 + "\"related-to\" : \"cvlan-tag\","
186 + "\"relationship-data\" : [{"
187 + "\"relationship-key\" : \"vce.vnf-id\","
188 + "\"relationship-value\" : \"key1\""
190 + "\"relationship-key\" : \"port-group.interface-id\","
191 + "\"relationship-value\" : \"key2\""
193 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
194 + "\"relationship-value\" : \"655\""
198 Unmarshaller unmarshaller = context.createUnmarshaller();
199 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
200 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
201 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
202 Object obj = context.newDynamicEntity("Relationship");
204 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
206 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
207 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
209 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
210 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
211 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
212 + ".has('cvlan-tag', 655)";
213 String expectedParent =
214 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
215 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
216 + ".has('interface-id', 'key2')";
218 "gremlin query should be " + expected,
220 query.getQueryBuilder().getQuery());
222 "parent gremlin query should be equal the query for port group",
224 query.getQueryBuilder().getParentQuery().getQuery());
226 "result type should be cvlan-tag",
228 query.getResultType());
233 * Scrambled relationship.
235 * @throws JAXBException the JAXB exception
236 * @throws UnsupportedEncodingException the unsupported encoding exception
237 * @throws AAIException the AAI exception
240 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
243 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
244 + "\"relationship-data\" : [{"
245 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
246 + "\"relationship-value\" : \"key5\""
248 + "\"relationship-key\" : \"lag-interface.interface-name\","
249 + "\"relationship-value\" : \"key2\""
251 + "\"relationship-key\" : \"l-interface.interface-name\","
252 + "\"relationship-value\" : \"key3\""
254 + "\"relationship-key\" : \"vlan.vlan-interface\","
255 + "\"relationship-value\" : \"key4\""
257 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
258 + "\"relationship-value\" : \"key1\""
261 scrambledRelationshipSpec(content);
265 * Reversed relationship.
267 * @throws JAXBException the JAXB exception
268 * @throws UnsupportedEncodingException the unsupported encoding exception
269 * @throws AAIException the AAI exception
272 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
275 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
276 + "\"relationship-data\" : [{"
277 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
278 + "\"relationship-value\" : \"key5\""
280 + "\"relationship-key\" : \"vlan.vlan-interface\","
281 + "\"relationship-value\" : \"key4\""
283 + "\"relationship-key\" : \"l-interface.interface-name\","
284 + "\"relationship-value\" : \"key3\""
286 + "\"relationship-key\" : \"lag-interface.interface-name\","
287 + "\"relationship-value\" : \"key2\""
289 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
290 + "\"relationship-value\" : \"key1\""
293 scrambledRelationshipSpec(content);
297 * Ordered ambiguous relationship.
299 * @throws JAXBException the JAXB exception
300 * @throws UnsupportedEncodingException the unsupported encoding exception
301 * @throws AAIException the AAI exception
304 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
307 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
308 + "\"relationship-data\" : [{"
309 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
310 + "\"relationship-value\" : \"key1\""
312 + "\"relationship-key\" : \"lag-interface.interface-name\","
313 + "\"relationship-value\" : \"key2\""
315 + "\"relationship-key\" : \"l-interface.interface-name\","
316 + "\"relationship-value\" : \"key3\""
318 + "\"relationship-key\" : \"vlan.vlan-interface\","
319 + "\"relationship-value\" : \"key4\""
321 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
322 + "\"relationship-value\" : \"key5\""
325 scrambledRelationshipSpec(content);
329 * Scrambled relationship spec.
331 * @param content the content
332 * @throws JAXBException the JAXB exception
333 * @throws UnsupportedEncodingException the unsupported encoding exception
334 * @throws AAIException the AAI exception
336 public void scrambledRelationshipSpec(String content) throws JAXBException, UnsupportedEncodingException, AAIException {
339 Unmarshaller unmarshaller = context.createUnmarshaller();
340 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
341 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
342 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
343 Object obj = context.newDynamicEntity("Relationship");
345 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
347 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
348 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
350 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
351 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
352 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
353 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
354 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
355 + ".has('l3-interface-ipv4-address', 'key5')";
356 String expectedParent =
357 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
358 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
359 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
360 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
361 + ".has('vlan-interface', 'key4')";
363 "gremlin query should be " + expected,
365 query.getQueryBuilder().getQuery());
367 "parent gremlin query should be equal the query for vlan",
369 query.getQueryBuilder().getParentQuery().getQuery());
371 "result type should be l3-interface-ipv4-address-list",
372 "l3-interface-ipv4-address-list",
373 query.getResultType());
380 * @throws JAXBException the JAXB exception
381 * @throws UnsupportedEncodingException the unsupported encoding exception
382 * @throws AAIException the AAI exception
385 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
388 + "\"related-to\" : \"cvlan-tag\","
389 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
390 + "\"relationship-data\" : [{"
391 + "\"relationship-key\" : \"vce.vnf-id\","
392 + "\"relationship-value\" : \"key1\""
394 + "\"relationship-key\" : \"port-group.interface-id\","
395 + "\"relationship-value\" : \"key2\""
397 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
398 + "\"relationship-value\" : \"655\""
402 Unmarshaller unmarshaller = context.createUnmarshaller();
403 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
404 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
405 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
406 Object obj = context.newDynamicEntity("Relationship");
408 DynamicEntity entity = (DynamicEntity)unmarshaller.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 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
414 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
415 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
416 + ".has('cvlan-tag', 655)";
417 String expectedParent =
418 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
419 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
420 + ".has('interface-id', 'key2')";
422 "gremlin query should be " + expected,
424 query.getQueryBuilder().getQuery());
426 "parent gremlin query should be equal the query for port group",
428 query.getQueryBuilder().getParentQuery().getQuery());
430 "result type should be cvlan-tag",
432 query.getResultType());
437 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
440 + "\"related-to\" : \"cvlan-tag\","
441 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
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.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
452 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
453 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
455 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
456 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
457 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
458 + ".has('cvlan-tag', 655)";
459 String expectedParent =
460 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
461 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
462 + ".has('interface-id', 'key2')";
464 "gremlin query should be " + expected,
466 query.getQueryBuilder().getQuery());
468 "parent gremlin query should be equal the query for port group",
470 query.getQueryBuilder().getParentQuery().getQuery());
472 "result type should be cvlan-tag",
474 query.getResultType());
481 * @throws JAXBException the JAXB exception
482 * @throws UnsupportedEncodingException the unsupported encoding exception
483 * @throws AAIException the AAI exception
486 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
489 + "\"related-to\" : \"ctag-pool\","
490 + "\"relationship-data\" : [{"
491 + "\"relationship-key\" : \"complex.physical-location-id\","
492 + "\"relationship-value\" : \"key1\""
494 + "\"relationship-key\" : \"ctag-pool.target-pe\","
495 + " \"relationship-value\" : \"key2\""
497 + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
498 + "\"relationship-value\" : \"key3\""
503 Unmarshaller unmarshaller = context.createUnmarshaller();
504 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
505 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
506 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
507 Object obj = context.newDynamicEntity("Relationship");
509 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
511 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
512 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
515 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
516 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
517 + ".has('target-pe', 'key2')"
518 + ".has('availability-zone-name', 'key3')";
519 String expectedParent =
520 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
523 "gremlin query should be " + expected,
525 query.getQueryBuilder().getQuery());
527 "parent gremlin query should be equal the query for port group",
529 query.getQueryBuilder().getParentQuery().getQuery());
531 "result type should be ctag-pool",
533 query.getResultType());
540 * @throws JAXBException the JAXB exception
541 * @throws UnsupportedEncodingException the unsupported encoding exception
542 * @throws AAIException the AAI exception
545 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
548 + "\"related-to\" : \"vnf\","
549 + "\"relationship-data\" : [{"
550 + "\"relationship-key\" : \"vnf.vnf-id\","
551 + "\"relationship-value\" : \"key1\""
556 Unmarshaller unmarshaller = context.createUnmarshaller();
557 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
558 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
559 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
560 Object obj = context.newDynamicEntity("Relationship");
562 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
564 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
565 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
568 ".has('vnf-id', 'key1')"
569 + ".has('aai-node-type', P.within('vce','vpe','generic-vnf'))";
571 String expectedParent =
572 ".has('vnf-id', 'key1')"
573 + ".has('aai-node-type', P.within('vce','vpe','generic-vnf'))";
576 "gremlin query should be " + expected,
578 query.getQueryBuilder().getQuery());
580 "parent gremlin query should be equal the query for port group",
582 query.getQueryBuilder().getParentQuery().getQuery());
584 "result type should be vnf",
586 query.getResultType());
593 * @throws JAXBException the JAXB exception
594 * @throws UnsupportedEncodingException the unsupported encoding exception
595 * @throws AAIException the AAI exception
598 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
601 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
602 + "\"relationship-data\" : [{"
603 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
604 + "\"relationship-value\" : \"key1\""
606 + "\"relationship-key\" : \"lag-interface.interface-name\","
607 + "\"relationship-value\" : \"key2\""
609 + "\"relationship-key\" : \"l-infeaterface.interface-name\","
610 + "\"relationship-value\" : \"key3\""
612 + "\"relationship-key\" : \"vlan.vlan-interface\","
613 + "\"relationship-value\" : \"key4\""
615 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
616 + "\"relationship-value\" : \"key5\""
619 thrown.expect(AAIException.class);
620 thrown.expectMessage(containsString("invalid object name"));
622 Unmarshaller unmarshaller = context.createUnmarshaller();
623 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
624 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
625 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
626 Object obj = context.newDynamicEntity("Relationship");
628 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
630 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
631 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
636 * Invalid property name.
638 * @throws JAXBException the JAXB exception
639 * @throws UnsupportedEncodingException the unsupported encoding exception
640 * @throws AAIException the AAI exception
643 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
646 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
647 + "\"relationship-data\" : [{"
648 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
649 + "\"relationship-value\" : \"key1\""
651 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\","
652 + "\"relationship-value\" : \"key2\""
654 + "\"relationship-key\" : \"l-interface.interface-name\","
655 + "\"relationship-value\" : \"key3\""
657 + "\"relationship-key\" : \"vlan.vlan-interface\","
658 + "\"relationship-value\" : \"key4\""
660 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
661 + "\"relationship-value\" : \"key5\""
664 thrown.expect(AAIException.class);
665 thrown.expectMessage(containsString("invalid property name"));
667 Unmarshaller unmarshaller = context.createUnmarshaller();
668 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
669 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
670 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
671 Object obj = context.newDynamicEntity("Relationship");
673 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
675 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
676 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);