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=========================================================
21 package org.onap.aai.parsers.query;
23 import static org.hamcrest.CoreMatchers.containsString;
24 import static org.junit.Assert.assertEquals;
26 import java.io.StringReader;
27 import java.io.UnsupportedEncodingException;
29 import jakarta.xml.bind.JAXBException;
30 import jakarta.xml.bind.Unmarshaller;
31 import javax.xml.transform.stream.StreamSource;
33 import org.eclipse.persistence.dynamic.DynamicEntity;
34 import org.eclipse.persistence.jaxb.UnmarshallerProperties;
35 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
36 import org.junit.Before;
37 import org.junit.Ignore;
38 import org.junit.Rule;
39 import org.junit.Test;
40 import org.junit.rules.ExpectedException;
41 import org.onap.aai.AAISetup;
42 import org.onap.aai.exceptions.AAIException;
43 import org.onap.aai.introspection.Introspector;
44 import org.onap.aai.introspection.IntrospectorFactory;
45 import org.onap.aai.introspection.ModelType;
46 import org.onap.aai.nodes.NodeIngestor;
47 import org.onap.aai.serialization.engines.JanusGraphDBEngine;
48 import org.onap.aai.serialization.engines.QueryStyle;
49 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
50 import org.onap.aai.setup.SchemaVersion;
51 import org.springframework.beans.factory.annotation.Autowired;
54 public class RelationshipGremlinQueryTest extends AAISetup {
57 private NodeIngestor injestor;
58 private TransactionalGraphEngine dbEngine;
59 private SchemaVersion version;
60 private DynamicJAXBContext context = injestor.getContextForVersion(version);
63 public ExpectedException thrown = ExpectedException.none();
67 version = new SchemaVersion("v10");
68 dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
69 loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
75 * @throws JAXBException the JAXB exception
76 * @throws UnsupportedEncodingException the unsupported encoding exception
77 * @throws AAIException the AAI exception
80 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
82 String content = "{" + "\"related-to\" : \"pserver\"," + "\"relationship-data\" : [{"
83 + "\"relationship-key\" : \"pserver.hostname\"," + "\"relationship-value\" : \"key1\"" + "}]" + "}";
85 Unmarshaller unmarshaller = context.createUnmarshaller();
86 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
87 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
88 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
89 Object obj = context.newDynamicEntity("Relationship");
91 DynamicEntity entity = (DynamicEntity) unmarshaller
92 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
94 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
95 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
97 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
98 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
99 assertEquals("parent gremlin query should be equal to normal query", expected,
100 query.getQueryBuilder().getParentQuery().getQuery());
101 assertEquals("result type should be pserver", "pserver", query.getResultType());
108 * @throws JAXBException the JAXB exception
109 * @throws UnsupportedEncodingException the unsupported encoding exception
110 * @throws AAIException the AAI exception
113 public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
114 String content = "{" + "\"related-to\" : \"lag-interface\"," + "\"relationship-data\" : [{"
115 + "\"relationship-key\" : \"pserver.hostname\"," + "\"relationship-value\" : \"key1\"" + "}, {"
116 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
119 Unmarshaller unmarshaller = context.createUnmarshaller();
120 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
121 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
122 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
123 Object obj = context.newDynamicEntity("Relationship");
125 DynamicEntity entity = (DynamicEntity) unmarshaller
126 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
128 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
129 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
132 ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
133 + ".has('interface-name', 'key2')";
134 String parentExpected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
135 assertEquals("gremlin query should be for node", expected, query.getQueryBuilder().getQuery());
136 assertEquals("parent gremlin query should be for parent", parentExpected,
137 query.getQueryBuilder().getParentQuery().getQuery());
138 assertEquals("result type should be lag-interface", "lag-interface", query.getResultType());
144 * @throws JAXBException the JAXB exception
145 * @throws UnsupportedEncodingException the unsupported encoding exception
146 * @throws AAIException the AAI exception
149 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
150 String content = "{" + "\"related-to\" : \"cvlan-tag\"," + "\"relationship-data\" : [{"
151 + "\"relationship-key\" : \"vce.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}, {"
152 + "\"relationship-key\" : \"port-group.interface-id\"," + "\"relationship-value\" : \"key2\"" + "},{"
153 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\"," + "\"relationship-value\" : \"655\"" + "}]" + "}";
155 Unmarshaller unmarshaller = context.createUnmarshaller();
156 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
157 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
158 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
159 Object obj = context.newDynamicEntity("Relationship");
161 DynamicEntity entity = (DynamicEntity) unmarshaller
162 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
164 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
165 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
166 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
167 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
168 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
169 + ".has('cvlan-tag', 655)";
170 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
171 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
172 + ".has('interface-id', 'key2')";
173 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
174 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
175 query.getQueryBuilder().getParentQuery().getQuery());
176 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
181 * Scrambled relationship.
183 * @throws JAXBException the JAXB exception
184 * @throws UnsupportedEncodingException the unsupported encoding exception
185 * @throws AAIException the AAI exception
188 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
189 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
190 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
191 + "\"relationship-value\" : \"key5\"" + "},{"
192 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
193 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
194 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
195 + "},{" + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}]"
197 scrambledRelationshipSpec(content);
201 * Reversed relationship.
203 * @throws JAXBException the JAXB exception
204 * @throws UnsupportedEncodingException the unsupported encoding exception
205 * @throws AAIException the AAI exception
208 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
209 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
210 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
211 + "\"relationship-value\" : \"key5\"" + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\","
212 + "\"relationship-value\" : \"key4\"" + "},{" + "\"relationship-key\" : \"l-interface.interface-name\","
213 + "\"relationship-value\" : \"key3\"" + "},{"
214 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
215 + "},{" + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}]"
217 scrambledRelationshipSpec(content);
221 * Ordered ambiguous relationship.
223 * @throws JAXBException the JAXB exception
224 * @throws UnsupportedEncodingException the unsupported encoding exception
225 * @throws AAIException the AAI exception
228 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
229 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
230 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
231 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
232 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
233 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
234 + "},{" + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
235 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
236 scrambledRelationshipSpec(content);
240 * Scrambled relationship spec.
242 * @param content the content
243 * @throws JAXBException the JAXB exception
244 * @throws UnsupportedEncodingException the unsupported encoding exception
245 * @throws AAIException the AAI exception
247 public void scrambledRelationshipSpec(String content)
248 throws JAXBException, UnsupportedEncodingException, AAIException {
250 Unmarshaller unmarshaller = context.createUnmarshaller();
251 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
252 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
253 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
254 Object obj = context.newDynamicEntity("Relationship");
256 DynamicEntity entity = (DynamicEntity) unmarshaller
257 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
259 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
260 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
261 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
262 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
263 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
264 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
265 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
266 + ".has('l3-interface-ipv4-address', 'key5')";
267 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
268 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
269 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
270 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
271 + ".has('vlan-interface', 'key4')";
272 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
273 assertEquals("parent gremlin query should be equal the query for vlan", expectedParent,
274 query.getQueryBuilder().getParentQuery().getQuery());
275 assertEquals("result type should be l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list",
276 query.getResultType());
283 * @throws JAXBException the JAXB exception
284 * @throws UnsupportedEncodingException the unsupported encoding exception
285 * @throws AAIException the AAI exception
288 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
289 String content = "{" + "\"related-to\" : \"cvlan-tag\","
290 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
291 + "\"relationship-data\" : [{" + "\"relationship-key\" : \"vce.vnf-id\","
292 + "\"relationship-value\" : \"key1\"" + "}, {" + "\"relationship-key\" : \"port-group.interface-id\","
293 + "\"relationship-value\" : \"key2\"" + "},{" + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
294 + "\"relationship-value\" : \"655\"" + "}]" + "}";
296 Unmarshaller unmarshaller = context.createUnmarshaller();
297 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
298 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
299 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
300 Object obj = context.newDynamicEntity("Relationship");
302 DynamicEntity entity = (DynamicEntity) unmarshaller
303 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
305 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
306 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
307 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
308 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
309 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
310 + ".has('cvlan-tag', 655)";
311 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
312 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
313 + ".has('interface-id', 'key2')";
314 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
315 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
316 query.getQueryBuilder().getParentQuery().getQuery());
317 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
322 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
323 String content = "{" + "\"related-to\" : \"cvlan-tag\","
324 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
327 Unmarshaller unmarshaller = context.createUnmarshaller();
328 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
329 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
330 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
331 Object obj = context.newDynamicEntity("Relationship");
333 DynamicEntity entity = (DynamicEntity) unmarshaller
334 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
336 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
337 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
338 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
339 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
340 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
341 + ".has('cvlan-tag', 655)";
342 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
343 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
344 + ".has('interface-id', 'key2')";
345 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
346 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
347 query.getQueryBuilder().getParentQuery().getQuery());
348 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
355 * @throws JAXBException the JAXB exception
356 * @throws UnsupportedEncodingException the unsupported encoding exception
357 * @throws AAIException the AAI exception
360 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
361 String content = "{" + "\"related-to\" : \"ctag-pool\"," + "\"relationship-data\" : [{"
362 + "\"relationship-key\" : \"complex.physical-location-id\"," + "\"relationship-value\" : \"key1\""
363 + " }, { " + "\"relationship-key\" : \"ctag-pool.target-pe\"," + " \"relationship-value\" : \"key2\""
364 + " },{" + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
365 + "\"relationship-value\" : \"key3\"" + "}]" + "}";
367 Unmarshaller unmarshaller = context.createUnmarshaller();
368 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
369 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
370 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
371 Object obj = context.newDynamicEntity("Relationship");
373 DynamicEntity entity = (DynamicEntity) unmarshaller
374 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
376 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
377 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
379 String expected = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
380 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
381 + ".has('target-pe', 'key2')" + ".has('availability-zone-name', 'key3')";
382 String expectedParent = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
384 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
385 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
386 query.getQueryBuilder().getParentQuery().getQuery());
387 assertEquals("result type should be ctag-pool", "ctag-pool", query.getResultType());
394 * @throws JAXBException the JAXB exception
395 * @throws UnsupportedEncodingException the unsupported encoding exception
396 * @throws AAIException the AAI exception
399 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
400 String content = "{" + "\"related-to\" : \"vnf\"," + "\"relationship-data\" : [{"
401 + "\"relationship-key\" : \"vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + " }]" + "}";
403 Unmarshaller unmarshaller = context.createUnmarshaller();
404 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
405 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
406 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
407 Object obj = context.newDynamicEntity("Relationship");
409 DynamicEntity entity = (DynamicEntity) unmarshaller
410 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
412 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
413 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
415 String expected = ".has('vnf-id', 'key1')" + ".has('aai-node-type', P.within('vce','generic-vnf'))";
417 String expectedParent = ".has('vnf-id', 'key1')" + ".has('aai-node-type', P.within('vce','generic-vnf'))";
419 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
420 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
421 query.getQueryBuilder().getParentQuery().getQuery());
422 assertEquals("result type should be vnf", "vnf", query.getResultType());
429 * @throws JAXBException the JAXB exception
430 * @throws UnsupportedEncodingException the unsupported encoding exception
431 * @throws AAIException the AAI exception
434 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
435 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
436 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
437 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
438 + "},{" + "\"relationship-key\" : \"l-infeaterface.interface-name\","
439 + "\"relationship-value\" : \"key3\"" + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\","
440 + "\"relationship-value\" : \"key4\"" + "},{"
441 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
442 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
443 thrown.expect(AAIException.class);
444 thrown.expectMessage(containsString("invalid object name"));
446 Unmarshaller unmarshaller = context.createUnmarshaller();
447 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
448 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
449 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
450 Object obj = context.newDynamicEntity("Relationship");
452 DynamicEntity entity = (DynamicEntity) unmarshaller
453 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
455 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
456 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
461 * Invalid property name.
463 * @throws JAXBException the JAXB exception
464 * @throws UnsupportedEncodingException the unsupported encoding exception
465 * @throws AAIException the AAI exception
468 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
469 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
470 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
471 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\"," + "\"relationship-value\" : \"key2\""
472 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
473 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
474 + "},{" + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
475 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
476 thrown.expect(AAIException.class);
477 thrown.expectMessage(containsString("invalid property name"));
479 Unmarshaller unmarshaller = context.createUnmarshaller();
480 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
481 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
482 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
483 Object obj = context.newDynamicEntity("Relationship");
485 DynamicEntity entity = (DynamicEntity) unmarshaller
486 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
488 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
489 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);