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.Before;
26 import org.junit.Ignore;
27 import org.junit.Rule;
28 import org.junit.Test;
29 import org.junit.rules.ExpectedException;
30 import org.onap.aai.AAISetup;
31 import org.onap.aai.exceptions.AAIException;
32 import org.onap.aai.introspection.*;
33 import org.onap.aai.nodes.NodeIngestor;
34 import org.onap.aai.setup.SchemaVersion;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.onap.aai.serialization.engines.QueryStyle;
37 import org.onap.aai.serialization.engines.JanusGraphDBEngine;
38 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
40 import javax.xml.bind.JAXBException;
41 import javax.xml.bind.Unmarshaller;
42 import javax.xml.transform.stream.StreamSource;
43 import java.io.StringReader;
44 import java.io.UnsupportedEncodingException;
46 import static org.hamcrest.CoreMatchers.containsString;
47 import static org.junit.Assert.assertEquals;
50 public class RelationshipGremlinQueryTest extends AAISetup {
53 private NodeIngestor injestor;
54 private TransactionalGraphEngine dbEngine;
55 private SchemaVersion version;
56 private DynamicJAXBContext context = injestor.getContextForVersion(version);
59 public ExpectedException thrown = ExpectedException.none();
63 version = new SchemaVersion("v10");
65 new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
66 loaderFactory.createLoaderForVersion(ModelType.MOXY, version),
73 * @throws JAXBException the JAXB exception
74 * @throws UnsupportedEncodingException the unsupported encoding exception
75 * @throws AAIException the AAI exception
78 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
82 + "\"related-to\" : \"pserver\","
83 + "\"relationship-data\" : [{"
84 + "\"relationship-key\" : \"pserver.hostname\","
85 + "\"relationship-value\" : \"key1\""
89 Unmarshaller unmarshaller = context.createUnmarshaller();
90 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
91 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
92 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
93 Object obj = context.newDynamicEntity("Relationship");
95 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
97 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
98 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
101 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
103 "gremlin query should be " + expected,
105 query.getQueryBuilder().getQuery());
107 "parent gremlin query should be equal to normal query",
109 query.getQueryBuilder().getParentQuery().getQuery());
111 "result type should be pserver",
113 query.getResultType());
120 * @throws JAXBException the JAXB exception
121 * @throws UnsupportedEncodingException the unsupported encoding exception
122 * @throws AAIException the AAI exception
125 public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
128 + "\"related-to\" : \"lag-interface\","
129 + "\"relationship-data\" : [{"
130 + "\"relationship-key\" : \"pserver.hostname\","
131 + "\"relationship-value\" : \"key1\""
133 + "\"relationship-key\" : \"lag-interface.interface-name\","
134 + "\"relationship-value\" : \"key2\""
138 Unmarshaller unmarshaller = context.createUnmarshaller();
139 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
140 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
141 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
142 Object obj = context.newDynamicEntity("Relationship");
144 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
146 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
147 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
149 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
150 + ".has('interface-name', 'key2')";
151 String parentExpected =
152 ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
154 "gremlin query should be for node",
156 query.getQueryBuilder().getQuery());
158 "parent gremlin query should be for parent",
160 query.getQueryBuilder().getParentQuery().getQuery());
162 "result type should be lag-interface",
164 query.getResultType());
170 * @throws JAXBException the JAXB exception
171 * @throws UnsupportedEncodingException the unsupported encoding exception
172 * @throws AAIException the AAI exception
175 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
178 + "\"related-to\" : \"cvlan-tag\","
179 + "\"relationship-data\" : [{"
180 + "\"relationship-key\" : \"vce.vnf-id\","
181 + "\"relationship-value\" : \"key1\""
183 + "\"relationship-key\" : \"port-group.interface-id\","
184 + "\"relationship-value\" : \"key2\""
186 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
187 + "\"relationship-value\" : \"655\""
191 Unmarshaller unmarshaller = context.createUnmarshaller();
192 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
193 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
194 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
195 Object obj = context.newDynamicEntity("Relationship");
197 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
199 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
200 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
202 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
203 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
204 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
205 + ".has('cvlan-tag', 655)";
206 String expectedParent =
207 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
208 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
209 + ".has('interface-id', 'key2')";
211 "gremlin query should be " + expected,
213 query.getQueryBuilder().getQuery());
215 "parent gremlin query should be equal the query for port group",
217 query.getQueryBuilder().getParentQuery().getQuery());
219 "result type should be cvlan-tag",
221 query.getResultType());
226 * Scrambled relationship.
228 * @throws JAXBException the JAXB exception
229 * @throws UnsupportedEncodingException the unsupported encoding exception
230 * @throws AAIException the AAI exception
233 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
236 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
237 + "\"relationship-data\" : [{"
238 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
239 + "\"relationship-value\" : \"key5\""
241 + "\"relationship-key\" : \"lag-interface.interface-name\","
242 + "\"relationship-value\" : \"key2\""
244 + "\"relationship-key\" : \"l-interface.interface-name\","
245 + "\"relationship-value\" : \"key3\""
247 + "\"relationship-key\" : \"vlan.vlan-interface\","
248 + "\"relationship-value\" : \"key4\""
250 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
251 + "\"relationship-value\" : \"key1\""
254 scrambledRelationshipSpec(content);
258 * Reversed relationship.
260 * @throws JAXBException the JAXB exception
261 * @throws UnsupportedEncodingException the unsupported encoding exception
262 * @throws AAIException the AAI exception
265 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
268 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
269 + "\"relationship-data\" : [{"
270 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
271 + "\"relationship-value\" : \"key5\""
273 + "\"relationship-key\" : \"vlan.vlan-interface\","
274 + "\"relationship-value\" : \"key4\""
276 + "\"relationship-key\" : \"l-interface.interface-name\","
277 + "\"relationship-value\" : \"key3\""
279 + "\"relationship-key\" : \"lag-interface.interface-name\","
280 + "\"relationship-value\" : \"key2\""
282 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
283 + "\"relationship-value\" : \"key1\""
286 scrambledRelationshipSpec(content);
290 * Ordered ambiguous relationship.
292 * @throws JAXBException the JAXB exception
293 * @throws UnsupportedEncodingException the unsupported encoding exception
294 * @throws AAIException the AAI exception
297 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
300 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
301 + "\"relationship-data\" : [{"
302 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
303 + "\"relationship-value\" : \"key1\""
305 + "\"relationship-key\" : \"lag-interface.interface-name\","
306 + "\"relationship-value\" : \"key2\""
308 + "\"relationship-key\" : \"l-interface.interface-name\","
309 + "\"relationship-value\" : \"key3\""
311 + "\"relationship-key\" : \"vlan.vlan-interface\","
312 + "\"relationship-value\" : \"key4\""
314 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
315 + "\"relationship-value\" : \"key5\""
318 scrambledRelationshipSpec(content);
322 * Scrambled relationship spec.
324 * @param content the content
325 * @throws JAXBException the JAXB exception
326 * @throws UnsupportedEncodingException the unsupported encoding exception
327 * @throws AAIException the AAI exception
329 public void scrambledRelationshipSpec(String content) throws JAXBException, UnsupportedEncodingException, AAIException {
332 Unmarshaller unmarshaller = context.createUnmarshaller();
333 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
334 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
335 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
336 Object obj = context.newDynamicEntity("Relationship");
338 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
340 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
341 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
343 ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
344 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
345 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
346 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
347 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
348 + ".has('l3-interface-ipv4-address', 'key5')";
349 String expectedParent =
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')";
356 "gremlin query should be " + expected,
358 query.getQueryBuilder().getQuery());
360 "parent gremlin query should be equal the query for vlan",
362 query.getQueryBuilder().getParentQuery().getQuery());
364 "result type should be l3-interface-ipv4-address-list",
365 "l3-interface-ipv4-address-list",
366 query.getResultType());
373 * @throws JAXBException the JAXB exception
374 * @throws UnsupportedEncodingException the unsupported encoding exception
375 * @throws AAIException the AAI exception
378 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
381 + "\"related-to\" : \"cvlan-tag\","
382 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
383 + "\"relationship-data\" : [{"
384 + "\"relationship-key\" : \"vce.vnf-id\","
385 + "\"relationship-value\" : \"key1\""
387 + "\"relationship-key\" : \"port-group.interface-id\","
388 + "\"relationship-value\" : \"key2\""
390 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
391 + "\"relationship-value\" : \"655\""
395 Unmarshaller unmarshaller = context.createUnmarshaller();
396 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
397 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
398 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
399 Object obj = context.newDynamicEntity("Relationship");
401 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
403 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
404 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
406 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
407 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
408 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
409 + ".has('cvlan-tag', 655)";
410 String expectedParent =
411 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
412 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
413 + ".has('interface-id', 'key2')";
415 "gremlin query should be " + expected,
417 query.getQueryBuilder().getQuery());
419 "parent gremlin query should be equal the query for port group",
421 query.getQueryBuilder().getParentQuery().getQuery());
423 "result type should be cvlan-tag",
425 query.getResultType());
430 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
433 + "\"related-to\" : \"cvlan-tag\","
434 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
437 Unmarshaller unmarshaller = context.createUnmarshaller();
438 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
439 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
440 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
441 Object obj = context.newDynamicEntity("Relationship");
443 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
445 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
446 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
448 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
449 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
450 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
451 + ".has('cvlan-tag', 655)";
452 String expectedParent =
453 ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
454 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
455 + ".has('interface-id', 'key2')";
457 "gremlin query should be " + expected,
459 query.getQueryBuilder().getQuery());
461 "parent gremlin query should be equal the query for port group",
463 query.getQueryBuilder().getParentQuery().getQuery());
465 "result type should be cvlan-tag",
467 query.getResultType());
474 * @throws JAXBException the JAXB exception
475 * @throws UnsupportedEncodingException the unsupported encoding exception
476 * @throws AAIException the AAI exception
479 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
482 + "\"related-to\" : \"ctag-pool\","
483 + "\"relationship-data\" : [{"
484 + "\"relationship-key\" : \"complex.physical-location-id\","
485 + "\"relationship-value\" : \"key1\""
487 + "\"relationship-key\" : \"ctag-pool.target-pe\","
488 + " \"relationship-value\" : \"key2\""
490 + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
491 + "\"relationship-value\" : \"key3\""
496 Unmarshaller unmarshaller = context.createUnmarshaller();
497 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
498 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
499 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
500 Object obj = context.newDynamicEntity("Relationship");
502 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
504 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
505 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
508 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
509 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
510 + ".has('target-pe', 'key2')"
511 + ".has('availability-zone-name', 'key3')";
512 String expectedParent =
513 ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
516 "gremlin query should be " + expected,
518 query.getQueryBuilder().getQuery());
520 "parent gremlin query should be equal the query for port group",
522 query.getQueryBuilder().getParentQuery().getQuery());
524 "result type should be ctag-pool",
526 query.getResultType());
533 * @throws JAXBException the JAXB exception
534 * @throws UnsupportedEncodingException the unsupported encoding exception
535 * @throws AAIException the AAI exception
538 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
541 + "\"related-to\" : \"vnf\","
542 + "\"relationship-data\" : [{"
543 + "\"relationship-key\" : \"vnf.vnf-id\","
544 + "\"relationship-value\" : \"key1\""
549 Unmarshaller unmarshaller = context.createUnmarshaller();
550 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
551 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
552 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
553 Object obj = context.newDynamicEntity("Relationship");
555 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
557 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
558 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
561 ".has('vnf-id', 'key1')"
562 + ".has('aai-node-type', P.within('vce','generic-vnf'))";
564 String expectedParent =
565 ".has('vnf-id', 'key1')"
566 + ".has('aai-node-type', P.within('vce','generic-vnf'))";
569 "gremlin query should be " + expected,
571 query.getQueryBuilder().getQuery());
573 "parent gremlin query should be equal the query for port group",
575 query.getQueryBuilder().getParentQuery().getQuery());
577 "result type should be vnf",
579 query.getResultType());
586 * @throws JAXBException the JAXB exception
587 * @throws UnsupportedEncodingException the unsupported encoding exception
588 * @throws AAIException the AAI exception
591 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
594 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
595 + "\"relationship-data\" : [{"
596 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
597 + "\"relationship-value\" : \"key1\""
599 + "\"relationship-key\" : \"lag-interface.interface-name\","
600 + "\"relationship-value\" : \"key2\""
602 + "\"relationship-key\" : \"l-infeaterface.interface-name\","
603 + "\"relationship-value\" : \"key3\""
605 + "\"relationship-key\" : \"vlan.vlan-interface\","
606 + "\"relationship-value\" : \"key4\""
608 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
609 + "\"relationship-value\" : \"key5\""
612 thrown.expect(AAIException.class);
613 thrown.expectMessage(containsString("invalid object name"));
615 Unmarshaller unmarshaller = context.createUnmarshaller();
616 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
617 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
618 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
619 Object obj = context.newDynamicEntity("Relationship");
621 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
623 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
624 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
629 * Invalid property name.
631 * @throws JAXBException the JAXB exception
632 * @throws UnsupportedEncodingException the unsupported encoding exception
633 * @throws AAIException the AAI exception
636 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
639 + "\"related-to\" : \"l3-interface-ipv4-address-list\","
640 + "\"relationship-data\" : [{"
641 + "\"relationship-key\" : \"generic-vnf.vnf-id\","
642 + "\"relationship-value\" : \"key1\""
644 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\","
645 + "\"relationship-value\" : \"key2\""
647 + "\"relationship-key\" : \"l-interface.interface-name\","
648 + "\"relationship-value\" : \"key3\""
650 + "\"relationship-key\" : \"vlan.vlan-interface\","
651 + "\"relationship-value\" : \"key4\""
653 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
654 + "\"relationship-value\" : \"key5\""
657 thrown.expect(AAIException.class);
658 thrown.expectMessage(containsString("invalid property name"));
660 Unmarshaller unmarshaller = context.createUnmarshaller();
661 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
662 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
663 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
664 Object obj = context.newDynamicEntity("Relationship");
666 DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
668 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
669 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);