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 javax.xml.bind.JAXBException;
30 import javax.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.LoaderFactory;
46 import org.onap.aai.introspection.ModelType;
47 import org.onap.aai.nodes.NodeIngestor;
48 import org.onap.aai.serialization.engines.JanusGraphDBEngine;
49 import org.onap.aai.serialization.engines.QueryStyle;
50 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
51 import org.onap.aai.setup.SchemaVersion;
52 import org.springframework.beans.factory.annotation.Autowired;
55 public class RelationshipGremlinQueryTest extends AAISetup {
58 private NodeIngestor injestor;
59 private TransactionalGraphEngine dbEngine;
60 private SchemaVersion version;
61 private DynamicJAXBContext context = injestor.getContextForVersion(version);
64 public ExpectedException thrown = ExpectedException.none();
68 version = new SchemaVersion("v10");
69 dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
70 loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
76 * @throws JAXBException the JAXB exception
77 * @throws UnsupportedEncodingException the unsupported encoding exception
78 * @throws AAIException the AAI exception
81 public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
83 String content = "{" + "\"related-to\" : \"pserver\"," + "\"relationship-data\" : [{"
84 + "\"relationship-key\" : \"pserver.hostname\"," + "\"relationship-value\" : \"key1\"" + "}]" + "}";
86 Unmarshaller unmarshaller = context.createUnmarshaller();
87 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
88 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
89 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
90 Object obj = context.newDynamicEntity("Relationship");
92 DynamicEntity entity = (DynamicEntity) unmarshaller
93 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
95 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
96 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
98 String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
99 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
100 assertEquals("parent gremlin query should be equal to normal query", expected,
101 query.getQueryBuilder().getParentQuery().getQuery());
102 assertEquals("result type should be pserver", "pserver", 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 {
115 String content = "{" + "\"related-to\" : \"lag-interface\"," + "\"relationship-data\" : [{"
116 + "\"relationship-key\" : \"pserver.hostname\"," + "\"relationship-value\" : \"key1\"" + "}, {"
117 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
120 Unmarshaller unmarshaller = context.createUnmarshaller();
121 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
122 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
123 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
124 Object obj = context.newDynamicEntity("Relationship");
126 DynamicEntity entity = (DynamicEntity) unmarshaller
127 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
129 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
130 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
133 ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
134 + ".has('interface-name', 'key2')";
135 String parentExpected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
136 assertEquals("gremlin query should be for node", expected, query.getQueryBuilder().getQuery());
137 assertEquals("parent gremlin query should be for parent", parentExpected,
138 query.getQueryBuilder().getParentQuery().getQuery());
139 assertEquals("result type should be lag-interface", "lag-interface", query.getResultType());
145 * @throws JAXBException the JAXB exception
146 * @throws UnsupportedEncodingException the unsupported encoding exception
147 * @throws AAIException the AAI exception
150 public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
151 String content = "{" + "\"related-to\" : \"cvlan-tag\"," + "\"relationship-data\" : [{"
152 + "\"relationship-key\" : \"vce.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}, {"
153 + "\"relationship-key\" : \"port-group.interface-id\"," + "\"relationship-value\" : \"key2\"" + "},{"
154 + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\"," + "\"relationship-value\" : \"655\"" + "}]" + "}";
156 Unmarshaller unmarshaller = context.createUnmarshaller();
157 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
158 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
159 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
160 Object obj = context.newDynamicEntity("Relationship");
162 DynamicEntity entity = (DynamicEntity) unmarshaller
163 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
165 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
166 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
167 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
168 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
169 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
170 + ".has('cvlan-tag', 655)";
171 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
172 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
173 + ".has('interface-id', 'key2')";
174 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
175 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
176 query.getQueryBuilder().getParentQuery().getQuery());
177 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
182 * Scrambled relationship.
184 * @throws JAXBException the JAXB exception
185 * @throws UnsupportedEncodingException the unsupported encoding exception
186 * @throws AAIException the AAI exception
189 public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
190 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
191 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
192 + "\"relationship-value\" : \"key5\"" + "},{"
193 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
194 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
195 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
196 + "},{" + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}]"
198 scrambledRelationshipSpec(content);
202 * Reversed relationship.
204 * @throws JAXBException the JAXB exception
205 * @throws UnsupportedEncodingException the unsupported encoding exception
206 * @throws AAIException the AAI exception
209 public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
210 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
211 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
212 + "\"relationship-value\" : \"key5\"" + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\","
213 + "\"relationship-value\" : \"key4\"" + "},{" + "\"relationship-key\" : \"l-interface.interface-name\","
214 + "\"relationship-value\" : \"key3\"" + "},{"
215 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
216 + "},{" + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "}]"
218 scrambledRelationshipSpec(content);
222 * Ordered ambiguous relationship.
224 * @throws JAXBException the JAXB exception
225 * @throws UnsupportedEncodingException the unsupported encoding exception
226 * @throws AAIException the AAI exception
229 public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
230 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
231 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
232 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
233 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
234 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
235 + "},{" + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
236 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
237 scrambledRelationshipSpec(content);
241 * Scrambled relationship spec.
243 * @param content the content
244 * @throws JAXBException the JAXB exception
245 * @throws UnsupportedEncodingException the unsupported encoding exception
246 * @throws AAIException the AAI exception
248 public void scrambledRelationshipSpec(String content)
249 throws JAXBException, UnsupportedEncodingException, AAIException {
251 Unmarshaller unmarshaller = context.createUnmarshaller();
252 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
253 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
254 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
255 Object obj = context.newDynamicEntity("Relationship");
257 DynamicEntity entity = (DynamicEntity) unmarshaller
258 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
260 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
261 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
262 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
263 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
264 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
265 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
266 + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
267 + ".has('l3-interface-ipv4-address', 'key5')";
268 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
269 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
270 + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
271 + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
272 + ".has('vlan-interface', 'key4')";
273 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
274 assertEquals("parent gremlin query should be equal the query for vlan", expectedParent,
275 query.getQueryBuilder().getParentQuery().getQuery());
276 assertEquals("result type should be l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list",
277 query.getResultType());
284 * @throws JAXBException the JAXB exception
285 * @throws UnsupportedEncodingException the unsupported encoding exception
286 * @throws AAIException the AAI exception
289 public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
290 String content = "{" + "\"related-to\" : \"cvlan-tag\","
291 + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
292 + "\"relationship-data\" : [{" + "\"relationship-key\" : \"vce.vnf-id\","
293 + "\"relationship-value\" : \"key1\"" + "}, {" + "\"relationship-key\" : \"port-group.interface-id\","
294 + "\"relationship-value\" : \"key2\"" + "},{" + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
295 + "\"relationship-value\" : \"655\"" + "}]" + "}";
297 Unmarshaller unmarshaller = context.createUnmarshaller();
298 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
299 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
300 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
301 Object obj = context.newDynamicEntity("Relationship");
303 DynamicEntity entity = (DynamicEntity) unmarshaller
304 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
306 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
307 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
308 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
309 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
310 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
311 + ".has('cvlan-tag', 655)";
312 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
313 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
314 + ".has('interface-id', 'key2')";
315 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
316 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
317 query.getQueryBuilder().getParentQuery().getQuery());
318 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
323 public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
324 String content = "{" + "\"related-to\" : \"cvlan-tag\","
325 + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
328 Unmarshaller unmarshaller = context.createUnmarshaller();
329 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
330 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
331 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
332 Object obj = context.newDynamicEntity("Relationship");
334 DynamicEntity entity = (DynamicEntity) unmarshaller
335 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
337 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
338 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
339 String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
340 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
341 + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
342 + ".has('cvlan-tag', 655)";
343 String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
344 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
345 + ".has('interface-id', 'key2')";
346 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
347 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
348 query.getQueryBuilder().getParentQuery().getQuery());
349 assertEquals("result type should be cvlan-tag", "cvlan-tag", query.getResultType());
356 * @throws JAXBException the JAXB exception
357 * @throws UnsupportedEncodingException the unsupported encoding exception
358 * @throws AAIException the AAI exception
361 public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
362 String content = "{" + "\"related-to\" : \"ctag-pool\"," + "\"relationship-data\" : [{"
363 + "\"relationship-key\" : \"complex.physical-location-id\"," + "\"relationship-value\" : \"key1\""
364 + " }, { " + "\"relationship-key\" : \"ctag-pool.target-pe\"," + " \"relationship-value\" : \"key2\""
365 + " },{" + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
366 + "\"relationship-value\" : \"key3\"" + "}]" + "}";
368 Unmarshaller unmarshaller = context.createUnmarshaller();
369 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
370 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
371 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
372 Object obj = context.newDynamicEntity("Relationship");
374 DynamicEntity entity = (DynamicEntity) unmarshaller
375 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
377 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
378 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
380 String expected = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
381 + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
382 + ".has('target-pe', 'key2')" + ".has('availability-zone-name', 'key3')";
383 String expectedParent = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
385 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
386 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
387 query.getQueryBuilder().getParentQuery().getQuery());
388 assertEquals("result type should be ctag-pool", "ctag-pool", query.getResultType());
395 * @throws JAXBException the JAXB exception
396 * @throws UnsupportedEncodingException the unsupported encoding exception
397 * @throws AAIException the AAI exception
400 public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
401 String content = "{" + "\"related-to\" : \"vnf\"," + "\"relationship-data\" : [{"
402 + "\"relationship-key\" : \"vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + " }]" + "}";
404 Unmarshaller unmarshaller = context.createUnmarshaller();
405 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
406 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
407 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
408 Object obj = context.newDynamicEntity("Relationship");
410 DynamicEntity entity = (DynamicEntity) unmarshaller
411 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
413 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
414 QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
416 String expected = ".has('vnf-id', 'key1')" + ".has('aai-node-type', P.within('vce','generic-vnf'))";
418 String expectedParent = ".has('vnf-id', 'key1')" + ".has('aai-node-type', P.within('vce','generic-vnf'))";
420 assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
421 assertEquals("parent gremlin query should be equal the query for port group", expectedParent,
422 query.getQueryBuilder().getParentQuery().getQuery());
423 assertEquals("result type should be vnf", "vnf", query.getResultType());
430 * @throws JAXBException the JAXB exception
431 * @throws UnsupportedEncodingException the unsupported encoding exception
432 * @throws AAIException the AAI exception
435 public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
436 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
437 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
438 + "\"relationship-key\" : \"lag-interface.interface-name\"," + "\"relationship-value\" : \"key2\""
439 + "},{" + "\"relationship-key\" : \"l-infeaterface.interface-name\","
440 + "\"relationship-value\" : \"key3\"" + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\","
441 + "\"relationship-value\" : \"key4\"" + "},{"
442 + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
443 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
444 thrown.expect(AAIException.class);
445 thrown.expectMessage(containsString("invalid object name"));
447 Unmarshaller unmarshaller = context.createUnmarshaller();
448 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
449 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
450 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
451 Object obj = context.newDynamicEntity("Relationship");
453 DynamicEntity entity = (DynamicEntity) unmarshaller
454 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
456 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
457 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
462 * Invalid property name.
464 * @throws JAXBException the JAXB exception
465 * @throws UnsupportedEncodingException the unsupported encoding exception
466 * @throws AAIException the AAI exception
469 public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
470 String content = "{" + "\"related-to\" : \"l3-interface-ipv4-address-list\"," + "\"relationship-data\" : [{"
471 + "\"relationship-key\" : \"generic-vnf.vnf-id\"," + "\"relationship-value\" : \"key1\"" + "},{"
472 + "\"relationship-key\" : \"lag-interface.intfdaferface-name\"," + "\"relationship-value\" : \"key2\""
473 + "},{" + "\"relationship-key\" : \"l-interface.interface-name\"," + "\"relationship-value\" : \"key3\""
474 + "},{" + "\"relationship-key\" : \"vlan.vlan-interface\"," + "\"relationship-value\" : \"key4\""
475 + "},{" + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
476 + "\"relationship-value\" : \"key5\"" + "}]" + "}";
477 thrown.expect(AAIException.class);
478 thrown.expectMessage(containsString("invalid property name"));
480 Unmarshaller unmarshaller = context.createUnmarshaller();
481 unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
482 unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
483 unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
484 Object obj = context.newDynamicEntity("Relationship");
486 DynamicEntity entity = (DynamicEntity) unmarshaller
487 .unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
489 Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
490 dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);