2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 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=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.parsers.query;
24 import org.eclipse.persistence.dynamic.DynamicEntity;
25 import org.eclipse.persistence.jaxb.UnmarshallerProperties;
26 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
27 import org.junit.Ignore;
28 import org.junit.Rule;
29 import org.junit.Test;
30 import org.junit.rules.ExpectedException;
31 import org.onap.aai.AAISetup;
32 import org.onap.aai.exceptions.AAIException;
33 import org.onap.aai.introspection.*;
34 import org.onap.aai.serialization.engines.QueryStyle;
35 import org.onap.aai.serialization.engines.TitanDBEngine;
36 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
38 import javax.xml.bind.JAXBException;
39 import javax.xml.bind.Unmarshaller;
40 import javax.xml.transform.stream.StreamSource;
41 import java.io.StringReader;
42 import java.io.UnsupportedEncodingException;
44 import static org.hamcrest.CoreMatchers.containsString;
45 import static org.junit.Assert.assertEquals;
48 public class RelationshipGremlinQueryTest extends AAISetup {
50 private ModelInjestor injestor = ModelInjestor.getInstance();
51 private TransactionalGraphEngine dbEngine =
52 new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
53 LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
55 private final Version version = Version.v8;
56 private DynamicJAXBContext context = injestor.getContextForVersion(version);
59 public ExpectedException thrown = ExpectedException.none();
64 * @throws JAXBException the JAXB exception
65 * @throws UnsupportedEncodingException the unsupported encoding exception
66 * @throws AAIException the AAI exception
69 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
73 + "\"related-to\" : \"pserver\","
74 + "\"relationship-data\" : [{"
75 + "\"relationship-key\" : \"pserver.hostname\","
76 + "\"relationship-value\" : \"key1\""
80 Unmarshaller unmarshaller = context.createUnmarshaller();
81 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
82 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
83 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
84 Object obj = context.newDynamicEntity("Relationship");
86 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
88 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
89 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
92 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
94 "gremlin query should be " + expected,
96 query.getQueryBuilder().getQuery());
98 "parent gremlin query should be equal to normal query",
100 query.getQueryBuilder().getParentQuery().getQuery());
102 "result type should be pserver",
104 query.getResultType());
111 * @throws JAXBException the JAXB exception
112 * @throws UnsupportedEncodingException the unsupported encoding exception
113 * @throws AAIException the AAI exception
116 public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
119 + "\"related-to\" : \"lag-interface\","
120 + "\"relationship-data\" : [{"
121 + "\"relationship-key\" : \"pserver.hostname\","
122 + "\"relationship-value\" : \"key1\""
124 + "\"relationship-key\" : \"lag-interface.interface-name\","
125 + "\"relationship-value\" : \"key2\""
129 Unmarshaller unmarshaller = context.createUnmarshaller();
130 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
131 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
132 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
133 Object obj = context.newDynamicEntity("Relationship");
135 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
137 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
138 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
140 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
141 + ".has('interface-name', 'key2')";
142 String parentExpected =
143 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
145 "gremlin query should be for node",
147 query.getQueryBuilder().getQuery());
149 "parent gremlin query should be for parent",
151 query.getQueryBuilder().getParentQuery().getQuery());
153 "result type should be lag-interface",
155 query.getResultType());
161 * @throws JAXBException the JAXB exception
162 * @throws UnsupportedEncodingException the unsupported encoding exception
163 * @throws AAIException the AAI exception
166 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
169 + "\"related-to\" : \"cvlan-tag\","
170 + "\"relationship-data\" : [{"
171 + "\"relationship-key\" : \"vce.vnf-id\","
172 + "\"relationship-value\" : \"key1\""
174 + "\"relationship-key\" : \"port-group.interface-id\","
175 + "\"relationship-value\" : \"key2\""
177 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
178 + "\"relationship-value\" : \"655\""
182 Unmarshaller unmarshaller = context.createUnmarshaller();
183 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
184 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
185 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
186 Object obj = context.newDynamicEntity("Relationship");
188 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
190 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
191 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
193 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
194 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
195 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
196 + ".has('cvlan-tag', 655)";
197 String expectedParent =
198 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
199 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
200 + ".has('interface-id', 'key2')";
202 "gremlin query should be " + expected,
204 query.getQueryBuilder().getQuery());
206 "parent gremlin query should be equal the query for port group",
208 query.getQueryBuilder().getParentQuery().getQuery());
210 "result type should be cvlan-tag",
212 query.getResultType());
217 * Scrambled relationship.
219 * @throws JAXBException the JAXB exception
220 * @throws UnsupportedEncodingException the unsupported encoding exception
221 * @throws AAIException the AAI exception
224 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
227 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
228 + "\"relationship-data\" : [{"
229 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
230 + "\"relationship-value\" : \"key5\""
232 + "\"relationship-key\" : \"lag-interface.interface-name\","
233 + "\"relationship-value\" : \"key2\""
235 + "\"relationship-key\" : \"l-interface.interface-name\","
236 + "\"relationship-value\" : \"key3\""
238 + "\"relationship-key\" : \"vlan.vlan-interface\","
239 + "\"relationship-value\" : \"key4\""
241 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
242 + "\"relationship-value\" : \"key1\""
245 scrambledRelationshipSpec(content);
249 * Reversed relationship.
251 * @throws JAXBException the JAXB exception
252 * @throws UnsupportedEncodingException the unsupported encoding exception
253 * @throws AAIException the AAI exception
256 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
259 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
260 + "\"relationship-data\" : [{"
261 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
262 + "\"relationship-value\" : \"key5\""
264 + "\"relationship-key\" : \"vlan.vlan-interface\","
265 + "\"relationship-value\" : \"key4\""
267 + "\"relationship-key\" : \"l-interface.interface-name\","
268 + "\"relationship-value\" : \"key3\""
270 + "\"relationship-key\" : \"lag-interface.interface-name\","
271 + "\"relationship-value\" : \"key2\""
273 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
274 + "\"relationship-value\" : \"key1\""
277 scrambledRelationshipSpec(content);
281 * Ordered ambiguous relationship.
283 * @throws JAXBException the JAXB exception
284 * @throws UnsupportedEncodingException the unsupported encoding exception
285 * @throws AAIException the AAI exception
288 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
291 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
292 + "\"relationship-data\" : [{"
293 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
294 + "\"relationship-value\" : \"key1\""
296 + "\"relationship-key\" : \"lag-interface.interface-name\","
297 + "\"relationship-value\" : \"key2\""
299 + "\"relationship-key\" : \"l-interface.interface-name\","
300 + "\"relationship-value\" : \"key3\""
302 + "\"relationship-key\" : \"vlan.vlan-interface\","
303 + "\"relationship-value\" : \"key4\""
305 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
306 + "\"relationship-value\" : \"key5\""
309 scrambledRelationshipSpec(content);
313 * Scrambled relationship spec.
315 * @param content the content
316 * @throws JAXBException the JAXB exception
317 * @throws UnsupportedEncodingException the unsupported encoding exception
318 * @throws AAIException the AAI exception
320 public void scrambledRelationshipSpec(String content) throws JAXBException, UnsupportedEncodingException, AAIException {
323 Unmarshaller unmarshaller = context.createUnmarshaller();
324 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
325 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
326 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
327 Object obj = context.newDynamicEntity("Relationship");
329 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
331 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
332 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
334 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
335 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
336 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
337 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
338 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
339 + ".has('l3-interface-ipv4-address', 'key5')";
340 String expectedParent =
341 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
342 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
343 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
344 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
345 + ".has('vlan-interface', 'key4')";
347 "gremlin query should be " + expected,
349 query.getQueryBuilder().getQuery());
351 "parent gremlin query should be equal the query for vlan",
353 query.getQueryBuilder().getParentQuery().getQuery());
355 "result type should be l3-interface-ipv4-address-list",
356 "l3-interface-ipv4-address-list",
357 query.getResultType());
364 * @throws JAXBException the JAXB exception
365 * @throws UnsupportedEncodingException the unsupported encoding exception
366 * @throws AAIException the AAI exception
369 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
372 + "\"related-to\" : \"cvlan-tag\","
373 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
374 + "\"relationship-data\" : [{"
375 + "\"relationship-key\" : \"vce.vnf-id\","
376 + "\"relationship-value\" : \"key1\""
378 + "\"relationship-key\" : \"port-group.interface-id\","
379 + "\"relationship-value\" : \"key2\""
381 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
382 + "\"relationship-value\" : \"655\""
386 Unmarshaller unmarshaller = context.createUnmarshaller();
387 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
388 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
389 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
390 Object obj = context.newDynamicEntity("Relationship");
392 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
394 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
395 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
397 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
398 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
399 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
400 + ".has('cvlan-tag', 655)";
401 String expectedParent =
402 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
403 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
404 + ".has('interface-id', 'key2')";
406 "gremlin query should be " + expected,
408 query.getQueryBuilder().getQuery());
410 "parent gremlin query should be equal the query for port group",
412 query.getQueryBuilder().getParentQuery().getQuery());
414 "result type should be cvlan-tag",
416 query.getResultType());
421 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
424 + "\"related-to\" : \"cvlan-tag\","
425 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
428 Unmarshaller unmarshaller = context.createUnmarshaller();
429 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
430 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
431 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
432 Object obj = context.newDynamicEntity("Relationship");
434 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
436 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
437 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
439 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
440 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
441 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
442 + ".has('cvlan-tag', 655)";
443 String expectedParent =
444 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
445 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
446 + ".has('interface-id', 'key2')";
448 "gremlin query should be " + expected,
450 query.getQueryBuilder().getQuery());
452 "parent gremlin query should be equal the query for port group",
454 query.getQueryBuilder().getParentQuery().getQuery());
456 "result type should be cvlan-tag",
458 query.getResultType());
465 * @throws JAXBException the JAXB exception
466 * @throws UnsupportedEncodingException the unsupported encoding exception
467 * @throws AAIException the AAI exception
470 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
473 + "\"related-to\" : \"ctag-pool\","
474 + "\"relationship-data\" : [{"
475 + "\"relationship-key\" : \"complex.physical-location-id\","
476 + "\"relationship-value\" : \"key1\""
478 + "\"relationship-key\" : \"ctag-pool.target-pe\","
479 + " \"relationship-value\" : \"key2\""
481 + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
482 + "\"relationship-value\" : \"key3\""
487 Unmarshaller unmarshaller = context.createUnmarshaller();
488 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
489 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
490 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
491 Object obj = context.newDynamicEntity("Relationship");
493 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
495 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
496 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
499 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
500 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
501 + ".has('target-pe', 'key2')"
502 + ".has('availability-zone-name', 'key3')";
503 String expectedParent =
504 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
507 "gremlin query should be " + expected,
509 query.getQueryBuilder().getQuery());
511 "parent gremlin query should be equal the query for port group",
513 query.getQueryBuilder().getParentQuery().getQuery());
515 "result type should be ctag-pool",
517 query.getResultType());
524 * @throws JAXBException the JAXB exception
525 * @throws UnsupportedEncodingException the unsupported encoding exception
526 * @throws AAIException the AAI exception
529 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
532 + "\"related-to\" : \"vnf\","
533 + "\"relationship-data\" : [{"
534 + "\"relationship-key\" : \"vnf.vnf-id\","
535 + "\"relationship-value\" : \"key1\""
540 Unmarshaller unmarshaller = context.createUnmarshaller();
541 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
542 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
543 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
544 Object obj = context.newDynamicEntity("Relationship");
546 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
548 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
549 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
552 ".has('vnf-id', 'key1')"
553 + ".has('aai-node-type', P.within('vce','generic-vnf'))";
555 String expectedParent =
556 ".has('vnf-id', 'key1')"
557 + ".has('aai-node-type', P.within('vce','generic-vnf'))";
560 "gremlin query should be " + expected,
562 query.getQueryBuilder().getQuery());
564 "parent gremlin query should be equal the query for port group",
566 query.getQueryBuilder().getParentQuery().getQuery());
568 "result type should be vnf",
570 query.getResultType());
577 * @throws JAXBException the JAXB exception
578 * @throws UnsupportedEncodingException the unsupported encoding exception
579 * @throws AAIException the AAI exception
582 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
585 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
586 + "\"relationship-data\" : [{"
587 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
588 + "\"relationship-value\" : \"key1\""
590 + "\"relationship-key\" : \"lag-interface.interface-name\","
591 + "\"relationship-value\" : \"key2\""
593 + "\"relationship-key\" : \"l-infeaterface.interface-name\","
594 + "\"relationship-value\" : \"key3\""
596 + "\"relationship-key\" : \"vlan.vlan-interface\","
597 + "\"relationship-value\" : \"key4\""
599 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
600 + "\"relationship-value\" : \"key5\""
603 thrown.expect(AAIException.class);
604 thrown.expectMessage(containsString("invalid object name"));
606 Unmarshaller unmarshaller = context.createUnmarshaller();
607 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
608 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
609 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
610 Object obj = context.newDynamicEntity("Relationship");
612 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
614 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
615 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
620 * Invalid property name.
622 * @throws JAXBException the JAXB exception
623 * @throws UnsupportedEncodingException the unsupported encoding exception
624 * @throws AAIException the AAI exception
627 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
630 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
631 + "\"relationship-data\" : [{"
632 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
633 + "\"relationship-value\" : \"key1\""
635 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\","
636 + "\"relationship-value\" : \"key2\""
638 + "\"relationship-key\" : \"l-interface.interface-name\","
639 + "\"relationship-value\" : \"key3\""
641 + "\"relationship-key\" : \"vlan.vlan-interface\","
642 + "\"relationship-value\" : \"key4\""
644 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
645 + "\"relationship-value\" : \"key5\""
648 thrown.expect(AAIException.class);
649 thrown.expectMessage(containsString("invalid property name"));
651 Unmarshaller unmarshaller = context.createUnmarshaller();
652 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
653 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
654 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
655 Object obj = context.newDynamicEntity("Relationship");
657 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
659 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
660 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);