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=========================================================
20 package org.onap.aai.parsers.query;
22 import org.eclipse.persistence.dynamic.DynamicEntity;
23 import org.eclipse.persistence.jaxb.UnmarshallerProperties;
24 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
25 import org.junit.Ignore;
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.junit.rules.ExpectedException;
29 import org.onap.aai.AAISetup;
30 import org.onap.aai.exceptions.AAIException;
31 import org.onap.aai.introspection.*;
32 import org.onap.aai.serialization.engines.QueryStyle;
33 import org.onap.aai.serialization.engines.TitanDBEngine;
34 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
36 import javax.xml.bind.JAXBException;
37 import javax.xml.bind.Unmarshaller;
38 import javax.xml.transform.stream.StreamSource;
39 import java.io.StringReader;
40 import java.io.UnsupportedEncodingException;
42 import static org.hamcrest.CoreMatchers.containsString;
43 import static org.junit.Assert.assertEquals;
46 public class RelationshipGremlinQueryTest extends AAISetup {
48 private ModelInjestor injestor = ModelInjestor.getInstance();
49 private TransactionalGraphEngine dbEngine =
50 new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
51 LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
53 private final Version version = Version.v8;
54 private DynamicJAXBContext context = injestor.getContextForVersion(version);
57 public ExpectedException thrown = ExpectedException.none();
62 * @throws JAXBException the JAXB exception
63 * @throws UnsupportedEncodingException the unsupported encoding exception
64 * @throws AAIException the AAI exception
67 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
71 + "\"related-to\" : \"pserver\","
72 + "\"relationship-data\" : [{"
73 + "\"relationship-key\" : \"pserver.hostname\","
74 + "\"relationship-value\" : \"key1\""
78 Unmarshaller unmarshaller = context.createUnmarshaller();
79 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
80 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
81 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
82 Object obj = context.newDynamicEntity("Relationship");
84 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
86 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
87 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
90 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
92 "gremlin query should be " + expected,
94 query.getQueryBuilder().getQuery());
96 "parent gremlin query should be equal to normal query",
98 query.getQueryBuilder().getParentQuery().getQuery());
100 "result type should be pserver",
102 query.getResultType());
109 * @throws JAXBException the JAXB exception
110 * @throws UnsupportedEncodingException the unsupported encoding exception
111 * @throws AAIException the AAI exception
114 public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
117 + "\"related-to\" : \"lag-interface\","
118 + "\"relationship-data\" : [{"
119 + "\"relationship-key\" : \"pserver.hostname\","
120 + "\"relationship-value\" : \"key1\""
122 + "\"relationship-key\" : \"lag-interface.interface-name\","
123 + "\"relationship-value\" : \"key2\""
127 Unmarshaller unmarshaller = context.createUnmarshaller();
128 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
129 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
130 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
131 Object obj = context.newDynamicEntity("Relationship");
133 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
135 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
136 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
138 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
139 + ".has('interface-name', 'key2')";
140 String parentExpected =
141 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
143 "gremlin query should be for node",
145 query.getQueryBuilder().getQuery());
147 "parent gremlin query should be for parent",
149 query.getQueryBuilder().getParentQuery().getQuery());
151 "result type should be lag-interface",
153 query.getResultType());
159 * @throws JAXBException the JAXB exception
160 * @throws UnsupportedEncodingException the unsupported encoding exception
161 * @throws AAIException the AAI exception
164 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
167 + "\"related-to\" : \"cvlan-tag\","
168 + "\"relationship-data\" : [{"
169 + "\"relationship-key\" : \"vce.vnf-id\","
170 + "\"relationship-value\" : \"key1\""
172 + "\"relationship-key\" : \"port-group.interface-id\","
173 + "\"relationship-value\" : \"key2\""
175 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
176 + "\"relationship-value\" : \"655\""
180 Unmarshaller unmarshaller = context.createUnmarshaller();
181 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
182 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
183 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
184 Object obj = context.newDynamicEntity("Relationship");
186 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
188 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
189 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
191 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
192 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
193 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
194 + ".has('cvlan-tag', 655)";
195 String expectedParent =
196 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
197 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
198 + ".has('interface-id', 'key2')";
200 "gremlin query should be " + expected,
202 query.getQueryBuilder().getQuery());
204 "parent gremlin query should be equal the query for port group",
206 query.getQueryBuilder().getParentQuery().getQuery());
208 "result type should be cvlan-tag",
210 query.getResultType());
215 * Scrambled relationship.
217 * @throws JAXBException the JAXB exception
218 * @throws UnsupportedEncodingException the unsupported encoding exception
219 * @throws AAIException the AAI exception
222 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
225 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
226 + "\"relationship-data\" : [{"
227 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
228 + "\"relationship-value\" : \"key5\""
230 + "\"relationship-key\" : \"lag-interface.interface-name\","
231 + "\"relationship-value\" : \"key2\""
233 + "\"relationship-key\" : \"l-interface.interface-name\","
234 + "\"relationship-value\" : \"key3\""
236 + "\"relationship-key\" : \"vlan.vlan-interface\","
237 + "\"relationship-value\" : \"key4\""
239 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
240 + "\"relationship-value\" : \"key1\""
243 scrambledRelationshipSpec(content);
247 * Reversed relationship.
249 * @throws JAXBException the JAXB exception
250 * @throws UnsupportedEncodingException the unsupported encoding exception
251 * @throws AAIException the AAI exception
254 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
257 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
258 + "\"relationship-data\" : [{"
259 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
260 + "\"relationship-value\" : \"key5\""
262 + "\"relationship-key\" : \"vlan.vlan-interface\","
263 + "\"relationship-value\" : \"key4\""
265 + "\"relationship-key\" : \"l-interface.interface-name\","
266 + "\"relationship-value\" : \"key3\""
268 + "\"relationship-key\" : \"lag-interface.interface-name\","
269 + "\"relationship-value\" : \"key2\""
271 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
272 + "\"relationship-value\" : \"key1\""
275 scrambledRelationshipSpec(content);
279 * Ordered ambiguous relationship.
281 * @throws JAXBException the JAXB exception
282 * @throws UnsupportedEncodingException the unsupported encoding exception
283 * @throws AAIException the AAI exception
286 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
289 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
290 + "\"relationship-data\" : [{"
291 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
292 + "\"relationship-value\" : \"key1\""
294 + "\"relationship-key\" : \"lag-interface.interface-name\","
295 + "\"relationship-value\" : \"key2\""
297 + "\"relationship-key\" : \"l-interface.interface-name\","
298 + "\"relationship-value\" : \"key3\""
300 + "\"relationship-key\" : \"vlan.vlan-interface\","
301 + "\"relationship-value\" : \"key4\""
303 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
304 + "\"relationship-value\" : \"key5\""
307 scrambledRelationshipSpec(content);
311 * Scrambled relationship spec.
313 * @param content the content
314 * @throws JAXBException the JAXB exception
315 * @throws UnsupportedEncodingException the unsupported encoding exception
316 * @throws AAIException the AAI exception
318 public void scrambledRelationshipSpec(String content) throws JAXBException, UnsupportedEncodingException, AAIException {
321 Unmarshaller unmarshaller = context.createUnmarshaller();
322 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
323 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
324 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
325 Object obj = context.newDynamicEntity("Relationship");
327 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
329 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
330 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
332 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
333 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
334 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
335 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
336 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
337 + ".has('l3-interface-ipv4-address', 'key5')";
338 String expectedParent =
339 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
340 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
341 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
342 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
343 + ".has('vlan-interface', 'key4')";
345 "gremlin query should be " + expected,
347 query.getQueryBuilder().getQuery());
349 "parent gremlin query should be equal the query for vlan",
351 query.getQueryBuilder().getParentQuery().getQuery());
353 "result type should be l3-interface-ipv4-address-list",
354 "l3-interface-ipv4-address-list",
355 query.getResultType());
362 * @throws JAXBException the JAXB exception
363 * @throws UnsupportedEncodingException the unsupported encoding exception
364 * @throws AAIException the AAI exception
367 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
370 + "\"related-to\" : \"cvlan-tag\","
371 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
372 + "\"relationship-data\" : [{"
373 + "\"relationship-key\" : \"vce.vnf-id\","
374 + "\"relationship-value\" : \"key1\""
376 + "\"relationship-key\" : \"port-group.interface-id\","
377 + "\"relationship-value\" : \"key2\""
379 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
380 + "\"relationship-value\" : \"655\""
384 Unmarshaller unmarshaller = context.createUnmarshaller();
385 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
386 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
387 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
388 Object obj = context.newDynamicEntity("Relationship");
390 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
392 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
393 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
395 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
396 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
397 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
398 + ".has('cvlan-tag', 655)";
399 String expectedParent =
400 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
401 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
402 + ".has('interface-id', 'key2')";
404 "gremlin query should be " + expected,
406 query.getQueryBuilder().getQuery());
408 "parent gremlin query should be equal the query for port group",
410 query.getQueryBuilder().getParentQuery().getQuery());
412 "result type should be cvlan-tag",
414 query.getResultType());
419 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
422 + "\"related-to\" : \"cvlan-tag\","
423 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
426 Unmarshaller unmarshaller = context.createUnmarshaller();
427 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
428 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
429 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
430 Object obj = context.newDynamicEntity("Relationship");
432 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
434 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
435 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
437 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
438 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
439 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
440 + ".has('cvlan-tag', 655)";
441 String expectedParent =
442 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
443 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
444 + ".has('interface-id', 'key2')";
446 "gremlin query should be " + expected,
448 query.getQueryBuilder().getQuery());
450 "parent gremlin query should be equal the query for port group",
452 query.getQueryBuilder().getParentQuery().getQuery());
454 "result type should be cvlan-tag",
456 query.getResultType());
463 * @throws JAXBException the JAXB exception
464 * @throws UnsupportedEncodingException the unsupported encoding exception
465 * @throws AAIException the AAI exception
468 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
471 + "\"related-to\" : \"ctag-pool\","
472 + "\"relationship-data\" : [{"
473 + "\"relationship-key\" : \"complex.physical-location-id\","
474 + "\"relationship-value\" : \"key1\""
476 + "\"relationship-key\" : \"ctag-pool.target-pe\","
477 + " \"relationship-value\" : \"key2\""
479 + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
480 + "\"relationship-value\" : \"key3\""
485 Unmarshaller unmarshaller = context.createUnmarshaller();
486 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
487 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
488 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
489 Object obj = context.newDynamicEntity("Relationship");
491 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
493 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
494 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
497 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
498 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
499 + ".has('target-pe', 'key2')"
500 + ".has('availability-zone-name', 'key3')";
501 String expectedParent =
502 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
505 "gremlin query should be " + expected,
507 query.getQueryBuilder().getQuery());
509 "parent gremlin query should be equal the query for port group",
511 query.getQueryBuilder().getParentQuery().getQuery());
513 "result type should be ctag-pool",
515 query.getResultType());
522 * @throws JAXBException the JAXB exception
523 * @throws UnsupportedEncodingException the unsupported encoding exception
524 * @throws AAIException the AAI exception
527 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
530 + "\"related-to\" : \"vnf\","
531 + "\"relationship-data\" : [{"
532 + "\"relationship-key\" : \"vnf.vnf-id\","
533 + "\"relationship-value\" : \"key1\""
538 Unmarshaller unmarshaller = context.createUnmarshaller();
539 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
540 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
541 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
542 Object obj = context.newDynamicEntity("Relationship");
544 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
546 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
547 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
550 ".has('vnf-id', 'key1')"
551 + ".has('aai-node-type', P.within('vce','generic-vnf'))";
553 String expectedParent =
554 ".has('vnf-id', 'key1')"
555 + ".has('aai-node-type', P.within('vce','generic-vnf'))";
558 "gremlin query should be " + expected,
560 query.getQueryBuilder().getQuery());
562 "parent gremlin query should be equal the query for port group",
564 query.getQueryBuilder().getParentQuery().getQuery());
566 "result type should be vnf",
568 query.getResultType());
575 * @throws JAXBException the JAXB exception
576 * @throws UnsupportedEncodingException the unsupported encoding exception
577 * @throws AAIException the AAI exception
580 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
583 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
584 + "\"relationship-data\" : [{"
585 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
586 + "\"relationship-value\" : \"key1\""
588 + "\"relationship-key\" : \"lag-interface.interface-name\","
589 + "\"relationship-value\" : \"key2\""
591 + "\"relationship-key\" : \"l-infeaterface.interface-name\","
592 + "\"relationship-value\" : \"key3\""
594 + "\"relationship-key\" : \"vlan.vlan-interface\","
595 + "\"relationship-value\" : \"key4\""
597 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
598 + "\"relationship-value\" : \"key5\""
601 thrown.expect(AAIException.class);
602 thrown.expectMessage(containsString("invalid object name"));
604 Unmarshaller unmarshaller = context.createUnmarshaller();
605 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
606 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
607 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
608 Object obj = context.newDynamicEntity("Relationship");
610 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
612 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
613 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
618 * Invalid property name.
620 * @throws JAXBException the JAXB exception
621 * @throws UnsupportedEncodingException the unsupported encoding exception
622 * @throws AAIException the AAI exception
625 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
628 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
629 + "\"relationship-data\" : [{"
630 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
631 + "\"relationship-value\" : \"key1\""
633 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\","
634 + "\"relationship-value\" : \"key2\""
636 + "\"relationship-key\" : \"l-interface.interface-name\","
637 + "\"relationship-value\" : \"key3\""
639 + "\"relationship-key\" : \"vlan.vlan-interface\","
640 + "\"relationship-value\" : \"key4\""
642 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
643 + "\"relationship-value\" : \"key5\""
646 thrown.expect(AAIException.class);
647 thrown.expectMessage(containsString("invalid property name"));
649 Unmarshaller unmarshaller = context.createUnmarshaller();
650 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
651 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
652 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
653 Object obj = context.newDynamicEntity("Relationship");
655 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
657 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
658 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);