@Before
public void setup(){
- version = new SchemaVersion("v8");
+ version = new SchemaVersion("v10");
dbEngine =
new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
loaderFactory.createLoaderForVersion(ModelType.MOXY, version),
*/
@Test
public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
-
+
String content =
"{"
+ "\"related-to\" : \"pserver\","
+ "\"relationship-value\" : \"key1\""
+ "}]"
+ "}";
-
+
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
Object obj = context.newDynamicEntity("Relationship");
DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
+
Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- String expected =
+ String expected =
".has('hostname', 'key1').has('aai-node-type', 'pserver')";
assertEquals(
"gremlin query should be " + expected,
"result type should be pserver",
"pserver",
query.getResultType());
-
+
}
/**
+ "\"relationship-value\" : \"key2\""
+ "}]"
+ "}";
-
+
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
Object obj = context.newDynamicEntity("Relationship");
DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
+
Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
String expected =
".has('hostname', 'key1').has('aai-node-type', 'pserver').out('hasLAGInterface').has('aai-node-type', 'lag-interface')"
+ ".has('interface-name', 'key2')";
- String parentExpected =
+ String parentExpected =
".has('hostname', 'key1').has('aai-node-type', 'pserver')";
assertEquals(
"gremlin query should be for node",
"lag-interface",
query.getResultType());
}
-
+
/**
* Naming exceptions.
*
+ "\"relationship-value\" : \"655\""
+ "}]"
+ "}";
-
+
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
Object obj = context.newDynamicEntity("Relationship");
DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
+
Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- String expected =
+ String expected =
".has('vnf-id', 'key1').has('aai-node-type', 'vce').in('org.onap.relationships.inventory.BelongsTo')"
+ ".has('aai-node-type', 'port-group').has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
+ ".has('cvlan-tag', 655)";
- String expectedParent =
+ String expectedParent =
".has('vnf-id', 'key1').has('aai-node-type', 'vce').in('org.onap.relationships.inventory.BelongsTo')"
+ ".has('aai-node-type', 'port-group').has('interface-id', 'key2')";
-
+
assertEquals(
"gremlin query should be " + expected,
expected,
"result type should be cvlan-tag",
"cvlan-tag",
query.getResultType());
-
+
}
-
+
/**
* Double key.
*
+ "\"relationship-value\" : \"key3\""
+ "}]"
+ "}";
-
-
+
+
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
Object obj = context.newDynamicEntity("Relationship");
DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
+
Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- String expected =
+ String expected =
".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
+ ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
+ ".has('target-pe', 'key2')"
+ ".has('availability-zone-name', 'key3')";
- String expectedParent =
+ String expectedParent =
".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
assertEquals(
"result type should be ctag-pool",
"ctag-pool",
query.getResultType());
-
+
}
-
+
}