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 org.eclipse.persistence.dynamic.DynamicEntity;
24 import org.eclipse.persistence.jaxb.UnmarshallerProperties;
25 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
26 import org.junit.Ignore;
27 import org.junit.Rule;
28 import org.junit.Test;
29 import org.junit.rules.ExpectedException;
30 import org.openecomp.aai.AAISetup;
31 import org.openecomp.aai.exceptions.AAIException;
32 import org.openecomp.aai.introspection.*;
33 import org.openecomp.aai.serialization.engines.QueryStyle;
34 import org.openecomp.aai.serialization.engines.TitanDBEngine;
35 import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
37 import javax.xml.bind.JAXBException;
38 import javax.xml.bind.Unmarshaller;
39 import javax.xml.transform.stream.StreamSource;
40 import java.io.StringReader;
41 import java.io.UnsupportedEncodingException;
43 import static org.hamcrest.CoreMatchers.containsString;
44 import static org.junit.Assert.assertEquals;
47 public class RelationshipGremlinQueryTest extends AAISetup {
49 private ModelInjestor injestor = ModelInjestor.getInstance();
50 private TransactionalGraphEngine dbEngine =
51 new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
52 LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
54 private final Version version = Version.v8;
55 private DynamicJAXBContext context = injestor.getContextForVersion(version);
58 public ExpectedException thrown = ExpectedException.none();
63 * @throws JAXBException the JAXB exception
64 * @throws UnsupportedEncodingException the unsupported encoding exception
65 * @throws AAIException the AAI exception
68 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
72 + "\"related-to\" : \"pserver\","
73 + "\"relationship-data\" : [{"
74 + "\"relationship-key\" : \"pserver.hostname\","
75 + "\"relationship-value\" : \"key1\""
79 Unmarshaller unmarshaller = context.createUnmarshaller();
80 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
81 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
82 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
83 Object obj = context.newDynamicEntity("Relationship");
85 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
87 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
88 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
91 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
93 "gremlin query should be " + expected,
95 query.getQueryBuilder().getQuery());
97 "parent gremlin query should be equal to normal query",
99 query.getQueryBuilder().getParentQuery().getQuery());
101 "result type should be pserver",
103 query.getResultType());
110 * @throws JAXBException the JAXB exception
111 * @throws UnsupportedEncodingException the unsupported encoding exception
112 * @throws AAIException the AAI exception
115 public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
118 + "\"related-to\" : \"lag-interface\","
119 + "\"relationship-data\" : [{"
120 + "\"relationship-key\" : \"pserver.hostname\","
121 + "\"relationship-value\" : \"key1\""
123 + "\"relationship-key\" : \"lag-interface.interface-name\","
124 + "\"relationship-value\" : \"key2\""
128 Unmarshaller unmarshaller = context.createUnmarshaller();
129 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
130 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
131 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
132 Object obj = context.newDynamicEntity("Relationship");
134 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
136 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
137 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
139 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
140 + ".has('interface-name', 'key2')";
141 String parentExpected =
142 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
144 "gremlin query should be for node",
146 query.getQueryBuilder().getQuery());
148 "parent gremlin query should be for parent",
150 query.getQueryBuilder().getParentQuery().getQuery());
152 "result type should be lag-interface",
154 query.getResultType());
160 * @throws JAXBException the JAXB exception
161 * @throws UnsupportedEncodingException the unsupported encoding exception
162 * @throws AAIException the AAI exception
165 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
168 + "\"related-to\" : \"cvlan-tag\","
169 + "\"relationship-data\" : [{"
170 + "\"relationship-key\" : \"vce.vnf-id\","
171 + "\"relationship-value\" : \"key1\""
173 + "\"relationship-key\" : \"port-group.interface-id\","
174 + "\"relationship-value\" : \"key2\""
176 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
177 + "\"relationship-value\" : \"655\""
181 Unmarshaller unmarshaller = context.createUnmarshaller();
182 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
183 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
184 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
185 Object obj = context.newDynamicEntity("Relationship");
187 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
189 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
190 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
192 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
193 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
194 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
195 + ".has('cvlan-tag', 655)";
196 String expectedParent =
197 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
198 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
199 + ".has('interface-id', 'key2')";
201 "gremlin query should be " + expected,
203 query.getQueryBuilder().getQuery());
205 "parent gremlin query should be equal the query for port group",
207 query.getQueryBuilder().getParentQuery().getQuery());
209 "result type should be cvlan-tag",
211 query.getResultType());
216 * Scrambled relationship.
218 * @throws JAXBException the JAXB exception
219 * @throws UnsupportedEncodingException the unsupported encoding exception
220 * @throws AAIException the AAI exception
223 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
226 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
227 + "\"relationship-data\" : [{"
228 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
229 + "\"relationship-value\" : \"key5\""
231 + "\"relationship-key\" : \"lag-interface.interface-name\","
232 + "\"relationship-value\" : \"key2\""
234 + "\"relationship-key\" : \"l-interface.interface-name\","
235 + "\"relationship-value\" : \"key3\""
237 + "\"relationship-key\" : \"vlan.vlan-interface\","
238 + "\"relationship-value\" : \"key4\""
240 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
241 + "\"relationship-value\" : \"key1\""
244 scrambledRelationshipSpec(content);
248 * Reversed relationship.
250 * @throws JAXBException the JAXB exception
251 * @throws UnsupportedEncodingException the unsupported encoding exception
252 * @throws AAIException the AAI exception
255 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
258 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
259 + "\"relationship-data\" : [{"
260 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
261 + "\"relationship-value\" : \"key5\""
263 + "\"relationship-key\" : \"vlan.vlan-interface\","
264 + "\"relationship-value\" : \"key4\""
266 + "\"relationship-key\" : \"l-interface.interface-name\","
267 + "\"relationship-value\" : \"key3\""
269 + "\"relationship-key\" : \"lag-interface.interface-name\","
270 + "\"relationship-value\" : \"key2\""
272 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
273 + "\"relationship-value\" : \"key1\""
276 scrambledRelationshipSpec(content);
280 * Ordered ambiguous relationship.
282 * @throws JAXBException the JAXB exception
283 * @throws UnsupportedEncodingException the unsupported encoding exception
284 * @throws AAIException the AAI exception
287 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
290 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
291 + "\"relationship-data\" : [{"
292 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
293 + "\"relationship-value\" : \"key1\""
295 + "\"relationship-key\" : \"lag-interface.interface-name\","
296 + "\"relationship-value\" : \"key2\""
298 + "\"relationship-key\" : \"l-interface.interface-name\","
299 + "\"relationship-value\" : \"key3\""
301 + "\"relationship-key\" : \"vlan.vlan-interface\","
302 + "\"relationship-value\" : \"key4\""
304 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
305 + "\"relationship-value\" : \"key5\""
308 scrambledRelationshipSpec(content);
312 * Scrambled relationship spec.
314 * @param content the content
315 * @throws JAXBException the JAXB exception
316 * @throws UnsupportedEncodingException the unsupported encoding exception
317 * @throws AAIException the AAI exception
319 public void scrambledRelationshipSpec(String content) throws JAXBException, UnsupportedEncodingException, AAIException {
322 Unmarshaller unmarshaller = context.createUnmarshaller();
323 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
324 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
325 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
326 Object obj = context.newDynamicEntity("Relationship");
328 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
330 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
331 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
333 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
334 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
335 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
336 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
337 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
338 + ".has('l3-interface-ipv4-address', 'key5')";
339 String expectedParent =
340 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
341 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
342 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
343 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
344 + ".has('vlan-interface', 'key4')";
346 "gremlin query should be " + expected,
348 query.getQueryBuilder().getQuery());
350 "parent gremlin query should be equal the query for vlan",
352 query.getQueryBuilder().getParentQuery().getQuery());
354 "result type should be l3-interface-ipv4-address-list",
355 "l3-interface-ipv4-address-list",
356 query.getResultType());
363 * @throws JAXBException the JAXB exception
364 * @throws UnsupportedEncodingException the unsupported encoding exception
365 * @throws AAIException the AAI exception
368 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
371 + "\"related-to\" : \"cvlan-tag\","
372 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
373 + "\"relationship-data\" : [{"
374 + "\"relationship-key\" : \"vce.vnf-id\","
375 + "\"relationship-value\" : \"key1\""
377 + "\"relationship-key\" : \"port-group.interface-id\","
378 + "\"relationship-value\" : \"key2\""
380 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
381 + "\"relationship-value\" : \"655\""
385 Unmarshaller unmarshaller = context.createUnmarshaller();
386 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
387 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
388 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
389 Object obj = context.newDynamicEntity("Relationship");
391 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
393 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
394 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
396 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
397 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
398 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
399 + ".has('cvlan-tag', 655)";
400 String expectedParent =
401 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
402 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
403 + ".has('interface-id', 'key2')";
405 "gremlin query should be " + expected,
407 query.getQueryBuilder().getQuery());
409 "parent gremlin query should be equal the query for port group",
411 query.getQueryBuilder().getParentQuery().getQuery());
413 "result type should be cvlan-tag",
415 query.getResultType());
420 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
423 + "\"related-to\" : \"cvlan-tag\","
424 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
427 Unmarshaller unmarshaller = context.createUnmarshaller();
428 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
429 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
430 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
431 Object obj = context.newDynamicEntity("Relationship");
433 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
435 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
436 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
438 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
439 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
440 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
441 + ".has('cvlan-tag', 655)";
442 String expectedParent =
443 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
444 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
445 + ".has('interface-id', 'key2')";
447 "gremlin query should be " + expected,
449 query.getQueryBuilder().getQuery());
451 "parent gremlin query should be equal the query for port group",
453 query.getQueryBuilder().getParentQuery().getQuery());
455 "result type should be cvlan-tag",
457 query.getResultType());
464 * @throws JAXBException the JAXB exception
465 * @throws UnsupportedEncodingException the unsupported encoding exception
466 * @throws AAIException the AAI exception
469 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
472 + "\"related-to\" : \"ctag-pool\","
473 + "\"relationship-data\" : [{"
474 + "\"relationship-key\" : \"complex.physical-location-id\","
475 + "\"relationship-value\" : \"key1\""
477 + "\"relationship-key\" : \"ctag-pool.target-pe\","
478 + " \"relationship-value\" : \"key2\""
480 + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
481 + "\"relationship-value\" : \"key3\""
486 Unmarshaller unmarshaller = context.createUnmarshaller();
487 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
488 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
489 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
490 Object obj = context.newDynamicEntity("Relationship");
492 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
494 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
495 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
498 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
499 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
500 + ".has('target-pe', 'key2')"
501 + ".has('availability-zone-name', 'key3')";
502 String expectedParent =
503 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
506 "gremlin query should be " + expected,
508 query.getQueryBuilder().getQuery());
510 "parent gremlin query should be equal the query for port group",
512 query.getQueryBuilder().getParentQuery().getQuery());
514 "result type should be ctag-pool",
516 query.getResultType());
523 * @throws JAXBException the JAXB exception
524 * @throws UnsupportedEncodingException the unsupported encoding exception
525 * @throws AAIException the AAI exception
528 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
531 + "\"related-to\" : \"vnf\","
532 + "\"relationship-data\" : [{"
533 + "\"relationship-key\" : \"vnf.vnf-id\","
534 + "\"relationship-value\" : \"key1\""
539 Unmarshaller unmarshaller = context.createUnmarshaller();
540 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
541 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
542 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
543 Object obj = context.newDynamicEntity("Relationship");
545 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
547 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
548 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
551 ".has('vnf-id', 'key1')"
552 + ".has('aai-node-type', P.within('vce','generic-vnf'))";
554 String expectedParent =
555 ".has('vnf-id', 'key1')"
556 + ".has('aai-node-type', P.within('vce','generic-vnf'))";
559 "gremlin query should be " + expected,
561 query.getQueryBuilder().getQuery());
563 "parent gremlin query should be equal the query for port group",
565 query.getQueryBuilder().getParentQuery().getQuery());
567 "result type should be vnf",
569 query.getResultType());
576 * @throws JAXBException the JAXB exception
577 * @throws UnsupportedEncodingException the unsupported encoding exception
578 * @throws AAIException the AAI exception
581 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
584 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
585 + "\"relationship-data\" : [{"
586 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
587 + "\"relationship-value\" : \"key1\""
589 + "\"relationship-key\" : \"lag-interface.interface-name\","
590 + "\"relationship-value\" : \"key2\""
592 + "\"relationship-key\" : \"l-infeaterface.interface-name\","
593 + "\"relationship-value\" : \"key3\""
595 + "\"relationship-key\" : \"vlan.vlan-interface\","
596 + "\"relationship-value\" : \"key4\""
598 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
599 + "\"relationship-value\" : \"key5\""
602 thrown.expect(AAIException.class);
603 thrown.expectMessage(containsString("invalid object name"));
605 Unmarshaller unmarshaller = context.createUnmarshaller();
606 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
607 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
608 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
609 Object obj = context.newDynamicEntity("Relationship");
611 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
613 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
614 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
619 * Invalid property name.
621 * @throws JAXBException the JAXB exception
622 * @throws UnsupportedEncodingException the unsupported encoding exception
623 * @throws AAIException the AAI exception
626 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
629 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
630 + "\"relationship-data\" : [{"
631 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
632 + "\"relationship-value\" : \"key1\""
634 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\","
635 + "\"relationship-value\" : \"key2\""
637 + "\"relationship-key\" : \"l-interface.interface-name\","
638 + "\"relationship-value\" : \"key3\""
640 + "\"relationship-key\" : \"vlan.vlan-interface\","
641 + "\"relationship-value\" : \"key4\""
643 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
644 + "\"relationship-value\" : \"key5\""
647 thrown.expect(AAIException.class);
648 thrown.expectMessage(containsString("invalid property name"));
650 Unmarshaller unmarshaller = context.createUnmarshaller();
651 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
652 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
653 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
654 Object obj = context.newDynamicEntity("Relationship");
656 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
658 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
659 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);