summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java160
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java80
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java854
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java34
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/SimplePathTest.java146
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java402
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/TraversalURIOptimizedQueryTest.java72
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java126
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java306
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderTestQueryiesToRun.java286
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/optimization/OptimizeEnum.java2
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/AOneTenantOneVserversPerTenantTest.java46
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/BTenTenantTenVserversPerTenantTest.java46
13 files changed, 1280 insertions, 1280 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java
index 73fe2c88..e466de49 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java
@@ -48,89 +48,89 @@ import static org.junit.Assert.assertTrue;
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class ExcludeQueryTest extends AAISetup {
- @Autowired
- EdgeSerializer edgeSer;
-
- private Loader loader;
-
- @Before
- public void setup() throws Exception {
- loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- }
-
- private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException{
- return qb.createEdgeTraversal(EdgeType.TREE, "cloud-region","availability-zone").getVerticesExcludeByProperty("hypervisor-type", "hypervisortype-11").store("x").cap("x").unfold().dedup();
- }
-
- @Test
- public void gremlinQueryExcludeTest() throws AAIException {
- Graph graph = TinkerGraph.open();
- GraphTraversalSource g = graph.traversal();
-
- Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
- Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
- Vertex availibityzone11 = graph.addVertex(T.label, "availability-zone", T.id, "11", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-11", "hypervisor-type", "hypervisortype-11");
-
-
- Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
- Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
- Vertex availibityzone12 = graph.addVertex(T.label, "availability-zone", T.id, "12", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-12", "hypervisor-type", "hypervisortype-12");
-
- edgeSer.addTreeEdge(g, cloudregion, availibityzone);
- edgeSer.addTreeEdge(g, cloudregion, availibityzone11);
-
-
-
- edgeSer.addTreeEdge(g, cloudregion1, availibityzone1);
- edgeSer.addTreeEdge(g, cloudregion1, availibityzone12);
-
- List<Vertex> expected = new ArrayList<>();
- expected.add(availibityzone);
-
- GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, cloudregion);
- QueryBuilder q = buildTestQuery(qb);
-
- List<Vertex> results = q.toList();
+ @Autowired
+ EdgeSerializer edgeSer;
+
+ private Loader loader;
+
+ @Before
+ public void setup() throws Exception {
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ }
+
+ private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException{
+ return qb.createEdgeTraversal(EdgeType.TREE, "cloud-region","availability-zone").getVerticesExcludeByProperty("hypervisor-type", "hypervisortype-11").store("x").cap("x").unfold().dedup();
+ }
+
+ @Test
+ public void gremlinQueryExcludeTest() throws AAIException {
+ Graph graph = TinkerGraph.open();
+ GraphTraversalSource g = graph.traversal();
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
+ Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
+ Vertex availibityzone11 = graph.addVertex(T.label, "availability-zone", T.id, "11", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-11", "hypervisor-type", "hypervisortype-11");
+
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
+ Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
+ Vertex availibityzone12 = graph.addVertex(T.label, "availability-zone", T.id, "12", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-12", "hypervisor-type", "hypervisortype-12");
+
+ edgeSer.addTreeEdge(g, cloudregion, availibityzone);
+ edgeSer.addTreeEdge(g, cloudregion, availibityzone11);
+
+
+
+ edgeSer.addTreeEdge(g, cloudregion1, availibityzone1);
+ edgeSer.addTreeEdge(g, cloudregion1, availibityzone12);
+
+ List<Vertex> expected = new ArrayList<>();
+ expected.add(availibityzone);
+
+ GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, cloudregion);
+ QueryBuilder q = buildTestQuery(qb);
+
+ List<Vertex> results = q.toList();
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
+ assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
+ }
- @Test
- public void traversalQueryExcludeTest() throws AAIException {
- Graph graph = TinkerGraph.open();
- GraphTraversalSource g = graph.traversal();
-
-
- Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
- Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
- Vertex availibityzone11 = graph.addVertex(T.label, "availability-zone", T.id, "11", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-11", "hypervisor-type", "hypervisortype-11");
-
-
- Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
- Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
- Vertex availibityzone12 = graph.addVertex(T.label, "availability-zone", T.id, "12", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-12", "hypervisor-type", "hypervisortype-12");
-
- edgeSer.addTreeEdge(g, cloudregion, availibityzone);
- edgeSer.addTreeEdge(g, cloudregion, availibityzone11);
-
-
-
- edgeSer.addTreeEdge(g, cloudregion1, availibityzone1);
- edgeSer.addTreeEdge(g, cloudregion1, availibityzone12);
-
- List<Vertex> expected = new ArrayList<>();
- expected.add(availibityzone);
-
-
-
-
- TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, cloudregion);
- QueryBuilder<Vertex> q = buildTestQuery(qb);
-
- List<Vertex> results = q.toList();
+ @Test
+ public void traversalQueryExcludeTest() throws AAIException {
+ Graph graph = TinkerGraph.open();
+ GraphTraversalSource g = graph.traversal();
+
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
+ Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
+ Vertex availibityzone11 = graph.addVertex(T.label, "availability-zone", T.id, "11", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-11", "hypervisor-type", "hypervisortype-11");
+
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
+ Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
+ Vertex availibityzone12 = graph.addVertex(T.label, "availability-zone", T.id, "12", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-12", "hypervisor-type", "hypervisortype-12");
+
+ edgeSer.addTreeEdge(g, cloudregion, availibityzone);
+ edgeSer.addTreeEdge(g, cloudregion, availibityzone11);
+
+
+
+ edgeSer.addTreeEdge(g, cloudregion1, availibityzone1);
+ edgeSer.addTreeEdge(g, cloudregion1, availibityzone12);
+
+ List<Vertex> expected = new ArrayList<>();
+ expected.add(availibityzone);
+
+
+
+
+ TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, cloudregion);
+ QueryBuilder<Vertex> q = buildTestQuery(qb);
+
+ List<Vertex> results = q.toList();
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
+ assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
+ }
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
index 6df869fe..7873fc1b 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
@@ -26,48 +26,48 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.introspection.ModelType;
public class GremlinTraversalTest extends QueryBuilderTestAbstraction {
-
- @Override
- protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v) {
- loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- return new GremlinTraversal<>(loader, g, v);
- }
-
- @Override
- protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules() {
- loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- return new GremlinTraversal<>(loader, g);
- }
-
- @Override
- protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v) {
- return new GremlinTraversal<>(loader, g, v);
- }
-
- @Override
- protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules() {
- return new GremlinTraversal<>(loader, g);
- }
-
- @Override
- protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v) {
- return new GremlinTraversal<>(loader, g, v);
- }
+
+ @Override
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v) {
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ return new GremlinTraversal<>(loader, g, v);
+ }
+
+ @Override
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules() {
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ return new GremlinTraversal<>(loader, g);
+ }
+
+ @Override
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v) {
+ return new GremlinTraversal<>(loader, g, v);
+ }
+
+ @Override
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules() {
+ return new GremlinTraversal<>(loader, g);
+ }
+
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v) {
+ return new GremlinTraversal<>(loader, g, v);
+ }
- @Override
- protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules() {
- return new GremlinTraversal<>(loader, g);
- }
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules() {
+ return new GremlinTraversal<>(loader, g);
+ }
- @Override
- protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v) {
- return new GremlinTraversal<>(loader, g, v);
- }
+ @Override
+ protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v) {
+ return new GremlinTraversal<>(loader, g, v);
+ }
- @Override
- protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules() {
- return new GremlinTraversal<>(loader, g);
- }
+ @Override
+ protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules() {
+ return new GremlinTraversal<>(loader, g);
+ }
-
+
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
index 7c8d6c9c..a9f5a60f 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
@@ -63,14 +63,14 @@ import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
- SchemaLocationsBean.class,
- SchemaVersions.class,
- QueryTestsConfigTranslator.class,
- NodeIngestor.class,
- EdgeIngestor.class,
- EdgeSerializer.class,
- SpringContextAware.class,
- IntrospectionConfig.class
+ SchemaLocationsBean.class,
+ SchemaVersions.class,
+ QueryTestsConfigTranslator.class,
+ NodeIngestor.class,
+ EdgeIngestor.class,
+ EdgeSerializer.class,
+ SpringContextAware.class,
+ IntrospectionConfig.class
})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@TestPropertySource(properties = {
@@ -80,668 +80,668 @@ import static org.junit.Assert.*;
})
public abstract class QueryBuilderTestAbstraction {
- protected Loader loader;
- protected static Graph graph;
- protected GraphTraversalSource g;
+ protected Loader loader;
+ protected static Graph graph;
+ protected GraphTraversalSource g;
- @Autowired
- protected EdgeSerializer testEdgeSer;
+ @Autowired
+ protected EdgeSerializer testEdgeSer;
- @Autowired
- protected LoaderFactory loaderFactory;
+ @Autowired
+ protected LoaderFactory loaderFactory;
- @Autowired
- protected SchemaVersions schemaVersions;
+ @Autowired
+ protected SchemaVersions schemaVersions;
- @BeforeClass
- public static void setup() throws Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/");
- graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
- }
+ @BeforeClass
+ public static void setup() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/");
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ }
- @Before
- public void configure() throws Exception {
- loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ @Before
+ public void configure() throws Exception {
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- g = graph.traversal();
- }
+ g = graph.traversal();
+ }
- @After
- public void deConfigure() throws Exception {
- g.tx().rollback();
- }
+ @After
+ public void deConfigure() throws Exception {
+ g.tx().rollback();
+ }
- @AfterClass
- public static void teardown() throws Exception {
- graph.close();
- }
+ @AfterClass
+ public static void teardown() throws Exception {
+ graph.close();
+ }
- @Test
- public void createEdgeGVnfToVnfcTraversal() throws AAIException {
+ @Test
+ public void createEdgeGVnfToVnfcTraversal() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","myvnf").next();
- Vertex vnfc = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- testEdgeSer.addEdge(g, gvnf, vnfc, "uses");
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","myvnf").next();
+ Vertex vnfc = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ testEdgeSer.addEdge(g, gvnf, vnfc, "uses");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
- assertEquals(vnfc, tQ.next());
+ assertEquals(vnfc, tQ.next());
- }
+ }
- @Test
- public void createEdgeLinterfaceToLogicalLinkTraversal() throws AAIException {
+ @Test
+ public void createEdgeLinterfaceToLogicalLinkTraversal() throws AAIException {
- Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
- Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
- testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
+ Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
+ Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
+ testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "l-interface", "logical-link");
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "l-interface", "logical-link");
- Vertex next = tQ.next();
+ Vertex next = tQ.next();
- assertEquals(logicalLink, next);
+ assertEquals(logicalLink, next);
- }
+ }
- @SuppressWarnings("rawtypes")
- @Test
- public void createEdgeLinterfaceToLogicalLinkTraversal_tree() throws AAIException {
- Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
- Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
- testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void createEdgeLinterfaceToLogicalLinkTraversal_tree() throws AAIException {
+ Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
+ Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
+ testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
- QueryBuilder<Tree> tQ = getNewTreeTraversalWithTestEdgeRules(lInterface).createEdgeTraversal(EdgeType.COUSIN,
- loader.introspectorFromName("l-interface" ), loader.introspectorFromName("logical-link")).tree();
+ QueryBuilder<Tree> tQ = getNewTreeTraversalWithTestEdgeRules(lInterface).createEdgeTraversal(EdgeType.COUSIN,
+ loader.introspectorFromName("l-interface" ), loader.introspectorFromName("logical-link")).tree();
- Vertex lInterfaceExpected = graph.traversal().V().has("aai-node-type","l-interface").has("interface-name","l-interface-a").next();
- Vertex logicalLinkExpected = graph.traversal().V().has("aai-node-type", "logical-link").has("link-name","logical-link-a").next();
- Tree tree = tQ.next();
- assertTrue(tree.containsKey(lInterfaceExpected));
- assertTrue(((Tree) tree.get(lInterfaceExpected)).containsKey(logicalLinkExpected));
- }
+ Vertex lInterfaceExpected = graph.traversal().V().has("aai-node-type","l-interface").has("interface-name","l-interface-a").next();
+ Vertex logicalLinkExpected = graph.traversal().V().has("aai-node-type", "logical-link").has("link-name","logical-link-a").next();
+ Tree tree = tQ.next();
+ assertTrue(tree.containsKey(lInterfaceExpected));
+ assertTrue(((Tree) tree.get(lInterfaceExpected)).containsKey(logicalLinkExpected));
+ }
- @SuppressWarnings("rawtypes")
- @Test
- public void createEdgeLinterfaceToLogicalLinkTraversal_Path() throws AAIException {
- Vertex pInterface = g.addV("aai-node-type","p-interface","interface-name","p-interface-a").next();
- Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
- Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
- testEdgeSer.addEdge(g, lInterface, logicalLink);
- testEdgeSer.addTreeEdge(g, pInterface, lInterface);
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void createEdgeLinterfaceToLogicalLinkTraversal_Path() throws AAIException {
+ Vertex pInterface = g.addV("aai-node-type","p-interface","interface-name","p-interface-a").next();
+ Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
+ Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
+ testEdgeSer.addEdge(g, lInterface, logicalLink);
+ testEdgeSer.addTreeEdge(g, pInterface, lInterface);
- QueryBuilder<Path> tQ = getNewPathTraversalWithTestEdgeRules(pInterface).createEdgeTraversal(EdgeType.TREE,
- loader.introspectorFromName("p-interface" ), loader.introspectorFromName("l-interface")).createEdgeTraversal(EdgeType.COUSIN,
- loader.introspectorFromName("l-interface" ), loader.introspectorFromName("logical-link")).path();
+ QueryBuilder<Path> tQ = getNewPathTraversalWithTestEdgeRules(pInterface).createEdgeTraversal(EdgeType.TREE,
+ loader.introspectorFromName("p-interface" ), loader.introspectorFromName("l-interface")).createEdgeTraversal(EdgeType.COUSIN,
+ loader.introspectorFromName("l-interface" ), loader.introspectorFromName("logical-link")).path();
- Path path = tQ.next();
- assertThat(path.objects(), contains(pInterface, lInterface, logicalLink));
- }
+ Path path = tQ.next();
+ assertThat(path.objects(), contains(pInterface, lInterface, logicalLink));
+ }
- @SuppressWarnings("rawtypes")
- @Test
- public void parentVertexTest() throws AAIException {
- Vertex pInterface = g.addV("aai-node-type","p-interface","interface-name","p-interface-a").next();
- Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void parentVertexTest() throws AAIException {
+ Vertex pInterface = g.addV("aai-node-type","p-interface","interface-name","p-interface-a").next();
+ Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
- testEdgeSer.addTreeEdge(g, pInterface, lInterface);
+ testEdgeSer.addTreeEdge(g, pInterface, lInterface);
- QueryBuilder<Vertex> tQ = getNewEdgeTraversalWithTestEdgeRules(lInterface).getParentVertex();
+ QueryBuilder<Vertex> tQ = getNewEdgeTraversalWithTestEdgeRules(lInterface).getParentVertex();
- Vertex parent = tQ.next();
- assertThat(parent, is(pInterface));
- }
+ Vertex parent = tQ.next();
+ assertThat(parent, is(pInterface));
+ }
- @Test
- public void createEdgeLinterfaceToLogicalLinkIntrospectorTraversal() throws AAIException {
+ @Test
+ public void createEdgeLinterfaceToLogicalLinkIntrospectorTraversal() throws AAIException {
- Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
- Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
- testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
+ Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
+ Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
+ testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
- tQ.createEdgeTraversal(EdgeType.COUSIN, loader.introspectorFromName("l-interface"), loader.introspectorFromName("logical-link"));
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, loader.introspectorFromName("l-interface"), loader.introspectorFromName("logical-link"));
- Vertex next = tQ.next();
+ Vertex next = tQ.next();
- assertEquals(logicalLink, next);
+ assertEquals(logicalLink, next);
- }
+ }
- @Test
- public void createEdgeLinterfaceToLogicalLinkVertexToIntrospectorTraversal() throws AAIException {
+ @Test
+ public void createEdgeLinterfaceToLogicalLinkVertexToIntrospectorTraversal() throws AAIException {
- Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
- Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
- testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
+ Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next();
+ Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
+ testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
- tQ.createEdgeTraversal(EdgeType.COUSIN, lInterface, loader.introspectorFromName("logical-link"));
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, lInterface, loader.introspectorFromName("logical-link"));
- Vertex next = tQ.next();
+ Vertex next = tQ.next();
- assertEquals(logicalLink, next);
+ assertEquals(logicalLink, next);
- }
+ }
- @Test
- public void edgeToVertexTraversalTest() throws AAIException {
+ @Test
+ public void edgeToVertexTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- testEdgeSer.addEdge(g, gvnf, vnfc1);
+ testEdgeSer.addEdge(g, gvnf, vnfc1);
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 1 vertexes ", 1, list.size());
- assertTrue("Has vertex on the default edge ", list.contains(vnfc1));
+ assertEquals("Has 1 vertexes ", 1, list.size());
+ assertTrue("Has vertex on the default edge ", list.contains(vnfc1));
- }
+ }
- @Test
- public void edgeToVertexTraversalSingleOutRuleTest() throws AAIException {
+ @Test
+ public void edgeToVertexTraversalSingleOutRuleTest() throws AAIException {
- Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- testEdgeSer.addEdge(g, vce, vnfc1);
+ testEdgeSer.addEdge(g, vce, vnfc1);
- QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
- tQ1.createEdgeTraversal(EdgeType.COUSIN, "vce", "vnfc");
+ QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
+ tQ1.createEdgeTraversal(EdgeType.COUSIN, "vce", "vnfc");
- QueryBuilder<Vertex> tQ2 = getNewVertexTraversalWithTestEdgeRules(vnfc1);
- tQ2.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "vce");
+ QueryBuilder<Vertex> tQ2 = getNewVertexTraversalWithTestEdgeRules(vnfc1);
+ tQ2.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "vce");
- List<Vertex> list1 = tQ1.toList();
- List<Vertex> list2 = tQ2.toList();
+ List<Vertex> list1 = tQ1.toList();
+ List<Vertex> list2 = tQ2.toList();
- assertEquals("1 - Has 1 vertexes ", 1, list1.size());
- assertTrue("1 - traversal results in vnfc ", list1.contains(vnfc1));
- assertEquals("2 - Has 1 vertexes ", 1, list2.size());
- assertTrue("2 - traversal results in vce ", list2.contains(vce));
+ assertEquals("1 - Has 1 vertexes ", 1, list1.size());
+ assertTrue("1 - traversal results in vnfc ", list1.contains(vnfc1));
+ assertEquals("2 - Has 1 vertexes ", 1, list2.size());
+ assertTrue("2 - traversal results in vce ", list2.contains(vce));
- }
+ }
- @Test
- public void edgeToVertexTraversalSingleInRuleTest() throws AAIException {
+ @Test
+ public void edgeToVertexTraversalSingleInRuleTest() throws AAIException {
- Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- testEdgeSer.addEdge(g, vce, pserver);
+ testEdgeSer.addEdge(g, vce, pserver);
- QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
- tQ1.createEdgeTraversal(EdgeType.COUSIN, "vce", "pserver");
+ QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
+ tQ1.createEdgeTraversal(EdgeType.COUSIN, "vce", "pserver");
- List<Vertex> list = tQ1.toList();
+ List<Vertex> list = tQ1.toList();
- assertEquals("1 - Has 1 vertexes ", 1, list.size());
- assertTrue("1 - traversal results in vnfc ", list.contains(pserver));
+ assertEquals("1 - Has 1 vertexes ", 1, list.size());
+ assertTrue("1 - traversal results in vnfc ", list.contains(pserver));
- }
+ }
- @Test
- public void edgeToVertexMultiRuleTraversalTest() throws AAIException {
+ @Test
+ public void edgeToVertexMultiRuleTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- Vertex vnfc2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ Vertex vnfc2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
- testEdgeSer.addEdge(g, gvnf, vnfc1);
- testEdgeSer.addEdge(g, gvnf, vnfc2, "re-uses");
+ testEdgeSer.addEdge(g, gvnf, vnfc1);
+ testEdgeSer.addEdge(g, gvnf, vnfc2, "re-uses");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 2, list.size());
- assertTrue("Has vertex on the default edge ", list.contains(vnfc1));
- assertTrue("Has vertex on the re-uses edge ", list.contains(vnfc2));
+ assertEquals("Has 2 vertexes ", 2, list.size());
+ assertTrue("Has vertex on the default edge ", list.contains(vnfc1));
+ assertTrue("Has vertex on the re-uses edge ", list.contains(vnfc2));
- }
+ }
- @Test
- public void edgeToVertexMultiLabelTest() throws AAIException {
+ @Test
+ public void edgeToVertexMultiLabelTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- testEdgeSer.addEdge(g, gvnf, vnfc1);
- testEdgeSer.addEdge(g, pserver, vnfc1);
+ testEdgeSer.addEdge(g, gvnf, vnfc1);
+ testEdgeSer.addEdge(g, pserver, vnfc1);
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(vnfc1);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "generic-vnf");
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(vnfc1);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "generic-vnf");
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 1 vertexes ", 1, list.size());
- assertTrue("Only returns the generic vnf vertex", list.contains(gvnf));
+ assertEquals("Has 1 vertexes ", 1, list.size());
+ assertTrue("Only returns the generic vnf vertex", list.contains(gvnf));
- }
+ }
- @Test
- public void limitTraversalTest() throws AAIException {
+ @Test
+ public void limitTraversalTest() throws AAIException {
- g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
+ g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
- QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
- tQ.getVerticesByProperty("aai-node-type","vnfc").limit(1);
+ QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
+ tQ.getVerticesByProperty("aai-node-type","vnfc").limit(1);
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 1 vertexes ", 1, list.size());
+ assertEquals("Has 1 vertexes ", 1, list.size());
- }
+ }
- @Test
- public void getVertexesByPropertiesTraversalTest() throws AAIException {
+ @Test
+ public void getVertexesByPropertiesTraversalTest() throws AAIException {
- g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
+ g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
- QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
- tQ.getVerticesByProperty("vnfc-name", Arrays.asList("a-name", "b-name"));
+ QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
+ tQ.getVerticesByProperty("vnfc-name", Arrays.asList("a-name", "b-name"));
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 2, list.size());
+ assertEquals("Has 2 vertexes ", 2, list.size());
- }
+ }
- @Test
- public void getVertexesByIndexedPropertyTraversalTest() throws AAIException {
+ @Test
+ public void getVertexesByIndexedPropertyTraversalTest() throws AAIException {
- g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
+ g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
- QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
- tQ.getVerticesByIndexedProperty("aai-node-type","vnfc");
+ QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
+ tQ.getVerticesByIndexedProperty("aai-node-type","vnfc");
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 2, list.size());
+ assertEquals("Has 2 vertexes ", 2, list.size());
- }
+ }
- @Test
- public void dedupTraversalTest() throws AAIException {
+ @Test
+ public void dedupTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- testEdgeSer.addEdge(g, gvnf, pserver);
- testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ testEdgeSer.addEdge(g, gvnf, pserver);
+ testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").dedup();
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").dedup();
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 1, list.size());
- assertTrue("result has pserver ", list.contains(pserver));
+ assertEquals("Has 2 vertexes ", 1, list.size());
+ assertTrue("result has pserver ", list.contains(pserver));
- }
+ }
- @Test
- public void storeCapTraversalTest() throws AAIException {
+ @Test
+ public void storeCapTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- testEdgeSer.addEdge(g, gvnf, pserver);
- testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ testEdgeSer.addEdge(g, gvnf, pserver);
+ testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- GremlinTraversal<BulkSet<Vertex>> tQ = new GremlinTraversal<>(loader, g, gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").store("x").cap("x");
+ GremlinTraversal<BulkSet<Vertex>> tQ = new GremlinTraversal<>(loader, g, gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").store("x").cap("x");
- List<BulkSet<Vertex>> list = tQ.toList();
+ List<BulkSet<Vertex>> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 1, list.size());
- assertEquals("result has pserver ",pserver, list.get(0).iterator().next());
+ assertEquals("Has 2 vertexes ", 1, list.size());
+ assertEquals("result has pserver ",pserver, list.get(0).iterator().next());
- }
+ }
- @Test
- public void storeCapUnfoldTraversalTest() throws AAIException {
+ @Test
+ public void storeCapUnfoldTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- testEdgeSer.addEdge(g, gvnf, pserver);
- testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ testEdgeSer.addEdge(g, gvnf, pserver);
+ testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").store("x").cap("x").unfold();
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").store("x").cap("x").unfold();
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 2, list.size());
- assertTrue("result has pserver ", list.contains(pserver));
+ assertEquals("Has 2 vertexes ", 2, list.size());
+ assertTrue("result has pserver ", list.contains(pserver));
- }
+ }
- @Test
- public void nextAndHasNextTraversalTest() throws AAIException {
+ @Test
+ public void nextAndHasNextTraversalTest() throws AAIException {
- Vertex v1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- Vertex v2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
+ Vertex v1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ Vertex v2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
- QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
- tQ.getVerticesByProperty("aai-node-type","vnfc");
+ QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
+ tQ.getVerticesByProperty("aai-node-type","vnfc");
- List<Vertex> list = new ArrayList<>();
+ List<Vertex> list = new ArrayList<>();
- assertTrue("Has next 1 ",tQ.hasNext());
- list.add(tQ.next());
- assertTrue("Has next 2 ",tQ.hasNext());
- list.add(tQ.next());
- assertFalse("Has next 3 ",tQ.hasNext());
- assertTrue("Has all the vertexes", list.contains(v1) && list.remove(v2));
+ assertTrue("Has next 1 ",tQ.hasNext());
+ list.add(tQ.next());
+ assertTrue("Has next 2 ",tQ.hasNext());
+ list.add(tQ.next());
+ assertFalse("Has next 3 ",tQ.hasNext());
+ assertTrue("Has all the vertexes", list.contains(v1) && list.remove(v2));
- }
+ }
- @Test
- public void edgeToVertexMultiRuleOutTraversalTest() throws AAIException {
+ @Test
+ public void edgeToVertexMultiRuleOutTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- testEdgeSer.addEdge(g, gvnf, pserver);
- testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ testEdgeSer.addEdge(g, gvnf, pserver);
+ testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver");
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver");
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 2, list.size());
- assertTrue("result has pserver ", list.contains(pserver));
+ assertEquals("Has 2 vertexes ", 2, list.size());
+ assertTrue("result has pserver ", list.contains(pserver));
- }
+ }
- @Test
- public void edgeToVertexMultiRuleInTraversalTest() throws AAIException {
+ @Test
+ public void edgeToVertexMultiRuleInTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex complex = g.addV("aai-node-type","complex","physical-location-id","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex complex = g.addV("aai-node-type","complex","physical-location-id","a-name").next();
- testEdgeSer.addEdge(g, gvnf, complex);
- testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
+ testEdgeSer.addEdge(g, gvnf, complex);
+ testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "complex");
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "complex");
- List<Vertex> list = tQ.toList();
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 2, list.size());
- assertTrue("result has pserver ", list.contains(complex));
+ assertEquals("Has 2 vertexes ", 2, list.size());
+ assertTrue("result has pserver ", list.contains(complex));
- }
+ }
- @Test
- public void edgeTraversalSingleInRuleTest() throws AAIException {
+ @Test
+ public void edgeTraversalSingleInRuleTest() throws AAIException {
- Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Edge e = testEdgeSer.addEdge(g, vce, pserver);
+ Edge e = testEdgeSer.addEdge(g, vce, pserver);
- QueryBuilder<Edge> tQ1 = getNewEdgeTraversalWithTestEdgeRules(vce);
- tQ1.getEdgesBetween(EdgeType.COUSIN, "vce", "pserver");
+ QueryBuilder<Edge> tQ1 = getNewEdgeTraversalWithTestEdgeRules(vce);
+ tQ1.getEdgesBetween(EdgeType.COUSIN, "vce", "pserver");
- List<Edge> list = tQ1.toList();
+ List<Edge> list = tQ1.toList();
- assertEquals("1 - Has 1 edge ", 1, list.size());
- assertTrue("1 - traversal results in edge ", list.contains(e));
+ assertEquals("1 - Has 1 edge ", 1, list.size());
+ assertTrue("1 - traversal results in edge ", list.contains(e));
- }
+ }
- @Test
- public void edgeTraversalSingleOutRuleTest() throws AAIException {
+ @Test
+ public void edgeTraversalSingleOutRuleTest() throws AAIException {
- Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- Edge e = testEdgeSer.addEdge(g, vce, vnfc1);
+ Edge e = testEdgeSer.addEdge(g, vce, vnfc1);
- QueryBuilder<Edge> tQ1 = getNewEdgeTraversalWithTestEdgeRules(vce);
- tQ1.getEdgesBetween(EdgeType.COUSIN, "vce", "vnfc");
+ QueryBuilder<Edge> tQ1 = getNewEdgeTraversalWithTestEdgeRules(vce);
+ tQ1.getEdgesBetween(EdgeType.COUSIN, "vce", "vnfc");
- List<Edge> list1 = tQ1.toList();
+ List<Edge> list1 = tQ1.toList();
- assertEquals("1 - Has 1 edge ", 1, list1.size());
- assertTrue("1 - traversal results in edge ", list1.contains(e));
+ assertEquals("1 - Has 1 edge ", 1, list1.size());
+ assertTrue("1 - traversal results in edge ", list1.contains(e));
- }
+ }
- @Test
- public void edgeTraversalMultiRuleOutTraversalTest() throws AAIException {
+ @Test
+ public void edgeTraversalMultiRuleOutTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
- Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
+ Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "pserver");
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "pserver");
- List<Edge> list = tQ.toList();
+ List<Edge> list = tQ.toList();
- assertEquals("Has 2 edges ", 2, list.size());
- assertTrue("result has default edge ", list.contains(e1));
- assertTrue("result has other edge ", list.contains(e2));
+ assertEquals("Has 2 edges ", 2, list.size());
+ assertTrue("result has default edge ", list.contains(e1));
+ assertTrue("result has other edge ", list.contains(e2));
- }
+ }
- @Test
- public void edgeTraversalMultiRuleInTraversalTest() throws AAIException {
+ @Test
+ public void edgeTraversalMultiRuleInTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex complex = g.addV("aai-node-type","complex","physical-location-id","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex complex = g.addV("aai-node-type","complex","physical-location-id","a-name").next();
- Edge e1 = testEdgeSer.addEdge(g, gvnf, complex);
- Edge e2 = testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
+ Edge e1 = testEdgeSer.addEdge(g, gvnf, complex);
+ Edge e2 = testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "complex");
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "complex");
- List<Edge> list = tQ.toList();
+ List<Edge> list = tQ.toList();
- assertEquals("Has 2 edges ", 2, list.size());
- assertTrue("result has default edge ", list.contains(e1));
- assertTrue("result has other edge ", list.contains(e2));
+ assertEquals("Has 2 edges ", 2, list.size());
+ assertTrue("result has default edge ", list.contains(e1));
+ assertTrue("result has other edge ", list.contains(e2));
- }
+ }
- @Test
- public void edgeTraversalMultiRuleTraversalTest() throws AAIException {
+ @Test
+ public void edgeTraversalMultiRuleTraversalTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- Vertex vnfc2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ Vertex vnfc2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
- Edge e1 = testEdgeSer.addEdge(g, gvnf, vnfc1);
- Edge e2 = testEdgeSer.addEdge(g, gvnf, vnfc2, "re-uses");
+ Edge e1 = testEdgeSer.addEdge(g, gvnf, vnfc1);
+ Edge e2 = testEdgeSer.addEdge(g, gvnf, vnfc2, "re-uses");
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "vnfc");
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "vnfc");
- List<Edge> list = tQ.toList();
+ List<Edge> list = tQ.toList();
- assertEquals("Has 2 edges ", 2, list.size());
- assertTrue("result has default edge ", list.contains(e1));
- assertTrue("result has other edge ", list.contains(e2));
+ assertEquals("Has 2 edges ", 2, list.size());
+ assertTrue("result has default edge ", list.contains(e1));
+ assertTrue("result has other edge ", list.contains(e2));
- }
+ }
- @Ignore("This test is failing for TraversalQueryTest and Optimized but it passes for GremlinQueryTest")
- @Test (expected = NoEdgeRuleFoundException.class)
- public void getEdgesBetweenWithLabelsEmptyListTest() throws AAIException {
+ @Ignore("This test is failing for TraversalQueryTest and Optimized but it passes for GremlinQueryTest")
+ @Test (expected = NoEdgeRuleFoundException.class)
+ public void getEdgesBetweenWithLabelsEmptyListTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- testEdgeSer.addEdge(g, gvnf, pserver);
- testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ testEdgeSer.addEdge(g, gvnf, pserver);
+ testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.emptyList());
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.emptyList());
- }
+ }
- @Test
- public void getEdgesBetweenWithLabelsSingleItemTest() throws AAIException {
+ @Test
+ public void getEdgesBetweenWithLabelsSingleItemTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
- Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
+ Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.singletonList("generic-vnf-pserver-B"));
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.singletonList("generic-vnf-pserver-B"));
- List<Edge> list = tQ.toList();
+ List<Edge> list = tQ.toList();
- assertEquals("Has 1 edges ", 1, list.size());
- assertFalse("result does not have default edge ", list.contains(e1));
- assertTrue("result has other edge ", list.contains(e2));
+ assertEquals("Has 1 edges ", 1, list.size());
+ assertFalse("result does not have default edge ", list.contains(e1));
+ assertTrue("result has other edge ", list.contains(e2));
- }
+ }
- @Test
- public void getEdgesBetweenWithLabelsMultipleItemTest() throws AAIException {
+ @Test
+ public void getEdgesBetweenWithLabelsMultipleItemTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
- Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
+ Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Arrays.asList("generic-vnf-pserver-B", "generic-vnf-pserver-A"));
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Arrays.asList("generic-vnf-pserver-B", "generic-vnf-pserver-A"));
- List<Edge> list = tQ.toList();
+ List<Edge> list = tQ.toList();
- assertEquals("Has 2 edges ", 2, list.size());
- assertTrue("result has generic-vnf-pserver-A edge ", list.contains(e1));
- assertTrue("result has generic-vnf-pserver-B edge ", list.contains(e2));
+ assertEquals("Has 2 edges ", 2, list.size());
+ assertTrue("result has generic-vnf-pserver-A edge ", list.contains(e1));
+ assertTrue("result has generic-vnf-pserver-B edge ", list.contains(e2));
- }
+ }
- @Ignore("This test is failing for TraversalQueryTest and Optimized but it passes for GremlinQueryTest")
- @Test (expected = NoEdgeRuleFoundException.class)
- public void createEdgeTraversalWithLabelsEmptyListTest() throws AAIException {
+ @Ignore("This test is failing for TraversalQueryTest and Optimized but it passes for GremlinQueryTest")
+ @Test (expected = NoEdgeRuleFoundException.class)
+ public void createEdgeTraversalWithLabelsEmptyListTest() throws AAIException {
- Vertex gvnf = getVertex();
+ Vertex gvnf = getVertex();
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.emptyList());
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.emptyList());
- tQ.toList();
+ tQ.toList();
- }
+ }
- private Vertex getVertex() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ private Vertex getVertex() throws AAIException {
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- testEdgeSer.addEdge(g, gvnf, pserver);
- testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- return gvnf;
- }
+ testEdgeSer.addEdge(g, gvnf, pserver);
+ testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ return gvnf;
+ }
- @Test
- public void createEdgeTraversalWithLabelsSingleItemTest() throws AAIException {
+ @Test
+ public void createEdgeTraversalWithLabelsSingleItemTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
- Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
+ Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.singletonList("generic-vnf-pserver-B"));
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.singletonList("generic-vnf-pserver-B"));
- List<Edge> list = tQ.toList();
+ List<Edge> list = tQ.toList();
- assertEquals("Has 1 edges ", 1, list.size());
- assertFalse("result does not have default edge ", list.contains(e1));
- assertTrue("result has other edge ", list.contains(e2));
+ assertEquals("Has 1 edges ", 1, list.size());
+ assertFalse("result does not have default edge ", list.contains(e1));
+ assertTrue("result has other edge ", list.contains(e2));
- }
+ }
- @Test
- public void createEdgeTraversalWithLabelsMultipleItemTest() throws AAIException {
+ @Test
+ public void createEdgeTraversalWithLabelsMultipleItemTest() throws AAIException {
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
- Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver);
+ Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
- tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Arrays.asList("generic-vnf-pserver-B", "generic-vnf-pserver-A"));
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
+ tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Arrays.asList("generic-vnf-pserver-B", "generic-vnf-pserver-A"));
- List<Edge> list = tQ.toList();
+ List<Edge> list = tQ.toList();
- assertEquals("Has 2 edges ", 2, list.size());
- assertTrue("result has generic-vnf-pserver-A edge ", list.contains(e1));
- assertTrue("result has generic-vnf-pserver-B edge ", list.contains(e2));
+ assertEquals("Has 2 edges ", 2, list.size());
+ assertTrue("result has generic-vnf-pserver-A edge ", list.contains(e1));
+ assertTrue("result has generic-vnf-pserver-B edge ", list.contains(e2));
- }
+ }
- protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v);
+ protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v);
- protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules();
+ protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules();
- protected abstract QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v);
+ protected abstract QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v);
- protected abstract QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules();
+ protected abstract QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules();
- protected abstract QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v);
+ protected abstract QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v);
- protected abstract QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules();
+ protected abstract QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules();
- protected abstract QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v);
+ protected abstract QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v);
- protected abstract QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules();
+ protected abstract QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules();
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java
index 5cadb895..b1dc9df6 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java
@@ -33,22 +33,22 @@ import org.onap.aai.setup.SchemaVersions;
*/
public class QueryTestsConfigTranslator extends AbstractConfigTranslator {
- public QueryTestsConfigTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
- super(bean, schemaVersions);
- }
-
-
- /* (non-Javadoc)
- * @see org.onap.aai.setup.ConfigTranslator#getEdgeFiles()
- */
- @Override
- public Map<SchemaVersion, List<String>> getEdgeFiles() {
- String file = "src/test/resources/dbedgerules/DbEdgeRules_TraversalQueryTest.json";
- Map<SchemaVersion, List<String>> files = new TreeMap<>();
- List<String> container = new ArrayList<>();
- container.add(file);
- files.put(schemaVersions.getDefaultVersion(), container);
- return files;
- }
+ public QueryTestsConfigTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
+ super(bean, schemaVersions);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.onap.aai.setup.ConfigTranslator#getEdgeFiles()
+ */
+ @Override
+ public Map<SchemaVersion, List<String>> getEdgeFiles() {
+ String file = "src/test/resources/dbedgerules/DbEdgeRules_TraversalQueryTest.json";
+ Map<SchemaVersion, List<String>> files = new TreeMap<>();
+ List<String> container = new ArrayList<>();
+ container.add(file);
+ files.put(schemaVersions.getDefaultVersion(), container);
+ return files;
+ }
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/SimplePathTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/SimplePathTest.java
index 68340fd3..0a987c95 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/SimplePathTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/SimplePathTest.java
@@ -43,80 +43,80 @@ import static org.junit.Assert.assertTrue;
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class SimplePathTest extends AAISetup {
- public Loader loader;
-
- @Autowired
- EdgeSerializer edgeSer;
-
- @Before
- public void setup() throws Exception {
- loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- }
+ public Loader loader;
+
+ @Autowired
+ EdgeSerializer edgeSer;
+
+ @Before
+ public void setup() throws Exception {
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ }
- private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException {
- return qb.createEdgeTraversal(EdgeType.TREE, "generic-vnf", "l-interface")
- .until(qb.newInstance().getVerticesByProperty("aai-node-type", "generic-vnf"))
- .repeat(qb.newInstance().union(
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "generic-vnf", "l-interface"),
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "l-interface", "generic-vnf"),
- qb.newInstance().createEdgeTraversal(EdgeType.COUSIN, "l-interface", "logical-link"),
- qb.newInstance().createEdgeTraversal(EdgeType.COUSIN, "logical-link", "l-interface")
- ).simplePath())
- .store("x").cap("x").unfold().dedup();
- }
-
- private GraphTraversalSource setupGraph() throws AAIException{
- Graph graph = TinkerGraph.open();
- GraphTraversalSource g = graph.traversal();
-
- Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf",
- "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+ private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException {
+ return qb.createEdgeTraversal(EdgeType.TREE, "generic-vnf", "l-interface")
+ .until(qb.newInstance().getVerticesByProperty("aai-node-type", "generic-vnf"))
+ .repeat(qb.newInstance().union(
+ qb.newInstance().createEdgeTraversal(EdgeType.TREE, "generic-vnf", "l-interface"),
+ qb.newInstance().createEdgeTraversal(EdgeType.TREE, "l-interface", "generic-vnf"),
+ qb.newInstance().createEdgeTraversal(EdgeType.COUSIN, "l-interface", "logical-link"),
+ qb.newInstance().createEdgeTraversal(EdgeType.COUSIN, "logical-link", "l-interface")
+ ).simplePath())
+ .store("x").cap("x").unfold().dedup();
+ }
+
+ private GraphTraversalSource setupGraph() throws AAIException{
+ Graph graph = TinkerGraph.open();
+ GraphTraversalSource g = graph.traversal();
+
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
- Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
- "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
-
- Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
- "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
-
- Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
- "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
-
- Vertex lint3 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface",
- "interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
-
- Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf",
- "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
-
- edgeSer.addTreeEdge(g, gvnf1, lint1);
- edgeSer.addEdge(g, lint1, loglink1);
- edgeSer.addEdge(g, loglink1, lint2);
- edgeSer.addEdge(g, loglink1, lint3);
- edgeSer.addTreeEdge(g, gvnf2, lint3);
-
- return g;
- }
-
- @Test
- public void gremlinQueryTest() throws AAIException {
- GraphTraversalSource g = setupGraph();
- List<Vertex> expected = g.V("01").toList();
- Vertex start = g.V("00").toList().get(0);
-
- GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, start);
- QueryBuilder<Vertex> q = buildTestQuery(qb);
- List<Vertex> results = q.toList();
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
+ "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
+ "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
+
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
+ "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex lint3 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface",
+ "interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
+
+ edgeSer.addTreeEdge(g, gvnf1, lint1);
+ edgeSer.addEdge(g, lint1, loglink1);
+ edgeSer.addEdge(g, loglink1, lint2);
+ edgeSer.addEdge(g, loglink1, lint3);
+ edgeSer.addTreeEdge(g, gvnf2, lint3);
+
+ return g;
+ }
+
+ @Test
+ public void gremlinQueryTest() throws AAIException {
+ GraphTraversalSource g = setupGraph();
+ List<Vertex> expected = g.V("01").toList();
+ Vertex start = g.V("00").toList().get(0);
+
+ GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, start);
+ QueryBuilder<Vertex> q = buildTestQuery(qb);
+ List<Vertex> results = q.toList();
+ assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
+ }
- @Test
- public void traversalQueryTest() throws AAIException {
- GraphTraversalSource g = setupGraph();
- List<Vertex> expected = g.V("01").toList();
- Vertex start = g.V("00").toList().get(0);
-
- TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, start);
- QueryBuilder<Vertex> q = buildTestQuery(qb);
- List<Vertex> results = q.toList();
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
+ @Test
+ public void traversalQueryTest() throws AAIException {
+ GraphTraversalSource g = setupGraph();
+ List<Vertex> expected = g.V("01").toList();
+ Vertex start = g.V("00").toList().get(0);
+
+ TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, start);
+ QueryBuilder<Vertex> q = buildTestQuery(qb);
+ List<Vertex> results = q.toList();
+ assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
+ }
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
index 148f38e6..f82166bf 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
@@ -40,232 +40,232 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class TraversalQueryTest extends QueryBuilderTestAbstraction {
-
- @Override
- protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v) {
- return new TraversalQuery<>(loader, g, v);
- }
-
- @Override
- protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules() {
- return new TraversalQuery<>(loader, g);
- }
-
- @Override
- protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v) {
- return new TraversalQuery<>(loader, g, v);
- }
-
- @Override
- protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules() {
- return new TraversalQuery<>(loader, g);
- }
+
+ @Override
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalQuery<>(loader, g, v);
+ }
+
+ @Override
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules() {
+ return new TraversalQuery<>(loader, g);
+ }
+
+ @Override
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalQuery<>(loader, g, v);
+ }
+
+ @Override
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules() {
+ return new TraversalQuery<>(loader, g);
+ }
- protected QueryBuilder<Vertex> getNewVertexTraversal() {
- return new TraversalQuery<>(loader, g);
- }
-
- @Override
- protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v) {
- return new TraversalQuery<>(loader, g, v);
- }
+ protected QueryBuilder<Vertex> getNewVertexTraversal() {
+ return new TraversalQuery<>(loader, g);
+ }
+
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalQuery<>(loader, g, v);
+ }
- @Override
- protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules() {
- return new TraversalQuery<>(loader, g);
- }
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules() {
+ return new TraversalQuery<>(loader, g);
+ }
- @Override
- protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v) {
- return new TraversalQuery<>(loader, g, v);
- }
+ @Override
+ protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalQuery<>(loader, g, v);
+ }
- @Override
- protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules() {
- return new TraversalQuery<>(loader, g);
- }
-
- @Test
- public void unionQuery() {
- QueryBuilder<Vertex> tQ = getNewVertexTraversal();
- QueryBuilder<Vertex> tQ2 = getNewVertexTraversal();
- QueryBuilder<Vertex> tQ3 = getNewVertexTraversal();
- tQ.union(
- tQ2.getVerticesByProperty("test1", "value1"),
- tQ3.getVerticesByIndexedProperty("test2", "value2"));
+ @Override
+ protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules() {
+ return new TraversalQuery<>(loader, g);
+ }
+
+ @Test
+ public void unionQuery() {
+ QueryBuilder<Vertex> tQ = getNewVertexTraversal();
+ QueryBuilder<Vertex> tQ2 = getNewVertexTraversal();
+ QueryBuilder<Vertex> tQ3 = getNewVertexTraversal();
+ tQ.union(
+ tQ2.getVerticesByProperty("test1", "value1"),
+ tQ3.getVerticesByIndexedProperty("test2", "value2"));
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .union(__.has("test1", "value1"),__.has("test2", "value2"));
+ GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
+ .union(__.has("test1", "value1"),__.has("test2", "value2"));
- assertEquals("they are equal", expected, tQ.getQuery());
+ assertEquals("they are equal", expected, tQ.getQuery());
- }
+ }
- @Test
- public void traversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
- QueryBuilder<Vertex> tQ = getNewVertexTraversal();
- QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1")).getQueryBuilder();
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf");
- GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start().has("aai-node-type", "generic-vnf");
+ @Test
+ public void traversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
+ QueryBuilder<Vertex> tQ = getNewVertexTraversal();
+ QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1")).getQueryBuilder();
+ GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf");
+ GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start().has("aai-node-type", "generic-vnf");
- assertEquals("query object", expected.toString(), builder.getQuery().toString());
- assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString());
+ assertEquals("query object", expected.toString(), builder.getQuery().toString());
+ assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString());
- }
+ }
- // TODO - Identify why this unit test is failing and if this
- // is going to cause any problems
- @Test
- @Ignore("Not working ever since the change to using model driven development")
- public void nestedTraversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
+ // TODO - Identify why this unit test is failing and if this
+ // is going to cause any problems
+ @Test
+ @Ignore("Not working ever since the change to using model driven development")
+ public void nestedTraversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
- QueryBuilder<Vertex> tQ = getNewVertexTraversal();
- QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2")).getQueryBuilder();
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("vnf-id", "key1")
- .has("aai-node-type", "generic-vnf")
- .in("org.onap.relationships.inventory.BelongsTo").has(AAIProperties.NODE_TYPE, "l-interface")
- .has("interface-name", "key2");
- GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start()
- .has("vnf-id", "key1")
- .has("aai-node-type", "generic-vnf")
- .in("org.onap.relationships.inventory.BelongsTo")
- .has(AAIProperties.NODE_TYPE, "l-interface");
-
- assertEquals("query object", expected.toString(), builder.getQuery().toString());
- assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString());
-
+ QueryBuilder<Vertex> tQ = getNewVertexTraversal();
+ QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2")).getQueryBuilder();
+ GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
+ .has("vnf-id", "key1")
+ .has("aai-node-type", "generic-vnf")
+ .in("org.onap.relationships.inventory.BelongsTo").has(AAIProperties.NODE_TYPE, "l-interface")
+ .has("interface-name", "key2");
+ GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start()
+ .has("vnf-id", "key1")
+ .has("aai-node-type", "generic-vnf")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has(AAIProperties.NODE_TYPE, "l-interface");
+
+ assertEquals("query object", expected.toString(), builder.getQuery().toString());
+ assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString());
+
- }
-
- @Test
- public void abstractEdgeToVertexTraversalTest() throws AAIException {
-
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
-
- testEdgeSer.addEdge(g, gvnf, vnfc1);
-
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
-
- List<Vertex> list = tQ.toList();
+ }
+
+ @Test
+ public void abstractEdgeToVertexTraversalTest() throws AAIException {
+
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+
+ testEdgeSer.addEdge(g, gvnf, vnfc1);
+
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
+
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 1 vertexes ", 1, list.size());
- assertTrue("Has vertex on the default edge ", list.contains(vnfc1));
-
+ assertEquals("Has 1 vertexes ", 1, list.size());
+ assertTrue("Has vertex on the default edge ", list.contains(vnfc1));
+
- }
-
- @Test
- public void abstractEdgeToVertexTraversalSingleOutRuleTest() throws AAIException {
-
- Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
-
- testEdgeSer.addEdge(g, vce, vnfc1);
-
- QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
- tQ1.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
-
- QueryBuilder<Vertex> tQ2 = getNewVertexTraversalWithTestEdgeRules(vnfc1);
- tQ2.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "vnf");
-
- List<Vertex> list1 = tQ1.toList();
- List<Vertex> list2 = tQ2.toList();
-
- assertEquals("1 - Has 1 vertexes ", 1, list1.size());
- assertTrue("1 - traversal results in vnfc ", list1.contains(vnfc1));
- assertEquals("2 - Has 1 vertexes ", 1, list2.size());
- assertTrue("2 - traversal results in vce ", list2.contains(vce));
-
+ }
+
+ @Test
+ public void abstractEdgeToVertexTraversalSingleOutRuleTest() throws AAIException {
+
+ Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+
+ testEdgeSer.addEdge(g, vce, vnfc1);
+
+ QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
+ tQ1.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
+
+ QueryBuilder<Vertex> tQ2 = getNewVertexTraversalWithTestEdgeRules(vnfc1);
+ tQ2.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "vnf");
+
+ List<Vertex> list1 = tQ1.toList();
+ List<Vertex> list2 = tQ2.toList();
+
+ assertEquals("1 - Has 1 vertexes ", 1, list1.size());
+ assertTrue("1 - traversal results in vnfc ", list1.contains(vnfc1));
+ assertEquals("2 - Has 1 vertexes ", 1, list2.size());
+ assertTrue("2 - traversal results in vce ", list2.contains(vce));
+
- }
-
- @Test
- public void abstractEdgeToVertexTraversalSingleInRuleTest() throws AAIException {
-
- Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
-
- testEdgeSer.addEdge(g, vce, pserver);
-
- QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
- tQ1.createEdgeTraversal(EdgeType.COUSIN, "vnf", "pserver");
-
- List<Vertex> list = tQ1.toList();
+ }
+
+ @Test
+ public void abstractEdgeToVertexTraversalSingleInRuleTest() throws AAIException {
+
+ Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+
+ testEdgeSer.addEdge(g, vce, pserver);
+
+ QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
+ tQ1.createEdgeTraversal(EdgeType.COUSIN, "vnf", "pserver");
+
+ List<Vertex> list = tQ1.toList();
- assertEquals("1 - Has 1 vertexes ", 1, list.size());
- assertTrue("1 - traversal results in vnfc ", list.contains(pserver));
-
+ assertEquals("1 - Has 1 vertexes ", 1, list.size());
+ assertTrue("1 - traversal results in vnfc ", list.contains(pserver));
+
- }
-
- @Test
- public void abstractEdgeToVertexMultiRuleTraversalTest() throws AAIException {
-
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
- Vertex vnfc2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
-
- testEdgeSer.addEdge(g, gvnf, vnfc1);
- testEdgeSer.addEdge(g, gvnf, vnfc2, "re-uses");
-
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
-
- List<Vertex> list = tQ.toList();
+ }
+
+ @Test
+ public void abstractEdgeToVertexMultiRuleTraversalTest() throws AAIException {
+
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ Vertex vnfc2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next();
+
+ testEdgeSer.addEdge(g, gvnf, vnfc1);
+ testEdgeSer.addEdge(g, gvnf, vnfc2, "re-uses");
+
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
+
+ List<Vertex> list = tQ.toList();
- assertEquals("Has 2 vertexes ", 2, list.size());
- assertTrue("Has vertex on the default edge ", list.contains(vnfc1));
- assertTrue("Has vertex on the re-uses edge ", list.contains(vnfc2));
-
+ assertEquals("Has 2 vertexes ", 2, list.size());
+ assertTrue("Has vertex on the default edge ", list.contains(vnfc1));
+ assertTrue("Has vertex on the re-uses edge ", list.contains(vnfc2));
+
- }
-
- @Test
- public void abstractEdgeToVertexMultiRuleOutTraversalTest() throws AAIException {
-
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
-
- testEdgeSer.addEdge(g, gvnf, pserver);
- testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
-
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "pserver");
-
- List<Vertex> list = tQ.toList();
-
- assertEquals("Has 2 vertexes ", 2, list.size());
- assertTrue("result has pserver ", list.contains(pserver));
-
+ }
+
+ @Test
+ public void abstractEdgeToVertexMultiRuleOutTraversalTest() throws AAIException {
+
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+
+ testEdgeSer.addEdge(g, gvnf, pserver);
+ testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "pserver");
+
+ List<Vertex> list = tQ.toList();
+
+ assertEquals("Has 2 vertexes ", 2, list.size());
+ assertTrue("result has pserver ", list.contains(pserver));
+
- }
-
- @Test
- public void abstractEdgeToVertexMultiRuleInTraversalTest() throws AAIException {
-
- Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
- Vertex complex = g.addV("aai-node-type","complex","physical-location-id","a-name").next();
-
- testEdgeSer.addEdge(g, gvnf, complex);
- testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
-
- QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
- tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "complex");
-
- List<Vertex> list = tQ.toList();
-
- assertEquals("Has 2 vertexes ", 2, list.size());
- assertTrue("result has pserver ", list.contains(complex));
-
+ }
+
+ @Test
+ public void abstractEdgeToVertexMultiRuleInTraversalTest() throws AAIException {
+
+ Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
+ Vertex complex = g.addV("aai-node-type","complex","physical-location-id","a-name").next();
+
+ testEdgeSer.addEdge(g, gvnf, complex);
+ testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
+
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
+ tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "complex");
+
+ List<Vertex> list = tQ.toList();
+
+ assertEquals("Has 2 vertexes ", 2, list.size());
+ assertTrue("result has pserver ", list.contains(complex));
+
- }
+ }
-
+
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/TraversalURIOptimizedQueryTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/TraversalURIOptimizedQueryTest.java
index a4d0977b..8ec01aaa 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/TraversalURIOptimizedQueryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/TraversalURIOptimizedQueryTest.java
@@ -25,49 +25,49 @@ import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
public class TraversalURIOptimizedQueryTest extends TraversalQueryTest {
- @Override
- protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v) {
- return new TraversalURIOptimizedQuery<>(loader, g, v);
- }
+ @Override
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalURIOptimizedQuery<>(loader, g, v);
+ }
- @Override
- protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules() {
- return new TraversalURIOptimizedQuery<>(loader, g);
- }
+ @Override
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules() {
+ return new TraversalURIOptimizedQuery<>(loader, g);
+ }
- @Override
- protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v) {
- return new TraversalURIOptimizedQuery<>(loader, g, v);
- }
+ @Override
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalURIOptimizedQuery<>(loader, g, v);
+ }
- @Override
- protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules() {
- return new TraversalURIOptimizedQuery<>(loader, g);
- }
+ @Override
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules() {
+ return new TraversalURIOptimizedQuery<>(loader, g);
+ }
- @Override
- protected QueryBuilder<Vertex> getNewVertexTraversal() {
- return new TraversalURIOptimizedQuery<>(loader, g);
- }
+ @Override
+ protected QueryBuilder<Vertex> getNewVertexTraversal() {
+ return new TraversalURIOptimizedQuery<>(loader, g);
+ }
- @Override
- protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v) {
- return new TraversalURIOptimizedQuery<>(loader, g, v);
- }
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalURIOptimizedQuery<>(loader, g, v);
+ }
- @Override
- protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules() {
- return new TraversalURIOptimizedQuery<>(loader, g);
- }
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules() {
+ return new TraversalURIOptimizedQuery<>(loader, g);
+ }
- @Override
- protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v) {
- return new TraversalURIOptimizedQuery<>(loader, g, v);
- }
+ @Override
+ protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalURIOptimizedQuery<>(loader, g, v);
+ }
- @Override
- protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules() {
- return new TraversalURIOptimizedQuery<>(loader, g);
- }
+ @Override
+ protected QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules() {
+ return new TraversalURIOptimizedQuery<>(loader, g);
+ }
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java
index cb67500a..c5290375 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java
@@ -45,71 +45,71 @@ import static org.junit.Assert.assertTrue;
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class UntilTest extends AAISetup {
- private Loader loader;
-
- @Autowired
- EdgeSerializer edgeSer;
-
- @Before
- public void setup() throws Exception {
- loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- }
-
- private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException{
- return qb.until(qb.newInstance().getVerticesByProperty("aai-node-type", "l-interface")).repeat(
- qb.newInstance().union(
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "cloud-region", "tenant"),
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "tenant", "vserver"),
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "vserver", "l-interface")
- )).store("x").cap("x").unfold().dedup();
- }
-
- @Test
- public void gremlinQueryUntilTest() throws AAIException {
- Graph graph = TinkerGraph.open();
- GraphTraversalSource g = graph.traversal();
-
- Vertex v1 = graph.addVertex(T.id, 1, "aai-node-type", "cloud-region");
- Vertex v2 = graph.addVertex(T.id, 2, "aai-node-type", "tenant");
- Vertex v3 = graph.addVertex(T.id, 3, "aai-node-type", "vserver");
- Vertex v4 = graph.addVertex(T.id, 4, "aai-node-type", "l-interface");
- edgeSer.addTreeEdge(g, v1, v2);
- edgeSer.addTreeEdge(g, v2, v3);
- edgeSer.addTreeEdge(g, v3, v4);
- List<Vertex> expected = new ArrayList<>();
- expected.add(v4);
-
- GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, v1);
- QueryBuilder q = buildTestQuery(qb);
-
- List<Vertex> results = q.toList();
+ private Loader loader;
+
+ @Autowired
+ EdgeSerializer edgeSer;
+
+ @Before
+ public void setup() throws Exception {
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ }
+
+ private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException{
+ return qb.until(qb.newInstance().getVerticesByProperty("aai-node-type", "l-interface")).repeat(
+ qb.newInstance().union(
+ qb.newInstance().createEdgeTraversal(EdgeType.TREE, "cloud-region", "tenant"),
+ qb.newInstance().createEdgeTraversal(EdgeType.TREE, "tenant", "vserver"),
+ qb.newInstance().createEdgeTraversal(EdgeType.TREE, "vserver", "l-interface")
+ )).store("x").cap("x").unfold().dedup();
+ }
+
+ @Test
+ public void gremlinQueryUntilTest() throws AAIException {
+ Graph graph = TinkerGraph.open();
+ GraphTraversalSource g = graph.traversal();
+
+ Vertex v1 = graph.addVertex(T.id, 1, "aai-node-type", "cloud-region");
+ Vertex v2 = graph.addVertex(T.id, 2, "aai-node-type", "tenant");
+ Vertex v3 = graph.addVertex(T.id, 3, "aai-node-type", "vserver");
+ Vertex v4 = graph.addVertex(T.id, 4, "aai-node-type", "l-interface");
+ edgeSer.addTreeEdge(g, v1, v2);
+ edgeSer.addTreeEdge(g, v2, v3);
+ edgeSer.addTreeEdge(g, v3, v4);
+ List<Vertex> expected = new ArrayList<>();
+ expected.add(v4);
+
+ GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, v1);
+ QueryBuilder q = buildTestQuery(qb);
+
+ List<Vertex> results = q.toList();
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
+ assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
+ }
- @Test
- public void traversalQueryUntilTest() throws AAIException {
- Graph graph = TinkerGraph.open();
- GraphTraversalSource g = graph.traversal();
-
- Vertex v1 = graph.addVertex(T.id, 1, "aai-node-type", "cloud-region");
- Vertex v2 = graph.addVertex(T.id, 2, "aai-node-type", "tenant");
- Vertex v3 = graph.addVertex(T.id, 3, "aai-node-type", "vserver");
- Vertex v4 = graph.addVertex(T.id, 4, "aai-node-type", "l-interface");
- edgeSer.addTreeEdge(g, v1, v2);
- edgeSer.addTreeEdge(g, v2, v3);
- edgeSer.addTreeEdge(g, v3, v4);
- List<Vertex> expected = new ArrayList<>();
- expected.add(v4);
-
- TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, v1);
- QueryBuilder<Vertex> q = buildTestQuery(qb);
-
- List<Vertex> results = q.toList();
+ @Test
+ public void traversalQueryUntilTest() throws AAIException {
+ Graph graph = TinkerGraph.open();
+ GraphTraversalSource g = graph.traversal();
+
+ Vertex v1 = graph.addVertex(T.id, 1, "aai-node-type", "cloud-region");
+ Vertex v2 = graph.addVertex(T.id, 2, "aai-node-type", "tenant");
+ Vertex v3 = graph.addVertex(T.id, 3, "aai-node-type", "vserver");
+ Vertex v4 = graph.addVertex(T.id, 4, "aai-node-type", "l-interface");
+ edgeSer.addTreeEdge(g, v1, v2);
+ edgeSer.addTreeEdge(g, v2, v3);
+ edgeSer.addTreeEdge(g, v3, v4);
+ List<Vertex> expected = new ArrayList<>();
+ expected.add(v4);
+
+ TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, v1);
+ QueryBuilder<Vertex> q = buildTestQuery(qb);
+
+ List<Vertex> results = q.toList();
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
-
-
+ assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
+ }
+
+
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java
index 29ca7425..c8134b2d 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java
@@ -51,159 +51,159 @@ import static org.junit.Assert.assertEquals;
public abstract class AbstractGraphTraversalBuilderOptmizationTest extends AAISetup{
- protected static final List<String> RANDOM_VALUES = Arrays.asList("A","B","C","D","E");
-
- protected static final String crUriPattern = "/cloud-infrastructure/cloud-regions/cloud-region/%s/%s";
- protected static final String tenantUriPatternSuffix = "/tenants/tenant/%s";
- protected static final String tenantUriPattern = crUriPattern + tenantUriPatternSuffix;
- protected static final String vserverUriPatternSuffix = "/vservers/vserver/%s";
- protected static final String vserverUriPattern = tenantUriPattern + vserverUriPatternSuffix;
-
- public static final String VSERVER_ID = "vserver-id";
- public static final String TENANT_ID = "tenant-id";
- public static final String TENANT_NAME = "tenant-name";
- public static final String PROV_STATUS = "prov-status";
- public static final String VSERVER_NAME = "vserver-name";
- public static final String VSERVER_SELFLINK = "vserver-selflink";
- public static final String TENANT = "tenant";
- public static final String VSERVER = "vserver";
- public static final String CLOUD_REGION = "cloud-region";
- public static final String CLOUD_REGION_ID = "cloud-region-id";
- public static final String CLOUD_OWNER = "cloud-owner";
-
- private static final ModelType introspectorFactoryType = ModelType.MOXY;
- private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private static final DBConnectionType type = DBConnectionType.REALTIME;
- private static TransactionalGraphEngine dbEngine;
- private static DBSerializer dbser;
- protected static Loader loader;
- protected static Graph graph;
- protected static GraphTraversalSource g;
- @Autowired
- private static EdgeSerializer edgeSer;
-
- protected static Random rand;
-
-
- protected void setupData(int tenantNum, int vserverPerTenantNum, String prefix) throws Exception{
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
- graph = AAIGraph.getInstance().getGraph();
-
- dbEngine = new JanusGraphDBEngine(queryStyle, type, loader);
- g = dbEngine.startTransaction().traversal();
- dbser = new DBSerializer(schemaVersions.getDefaultVersion(), dbEngine, introspectorFactoryType, "AAI-TEST-" + prefix);
-
- rand = new Random();
-
- Vertex cr;
- Vertex tenant;
- Vertex vserver;
- String crUri;
- String tenantUri;
- String vserverUri;
- System.out.println("Data load started");
- long startTime = System.currentTimeMillis();
- for (int crCtr = 0; crCtr < 3; crCtr++) {
- crUri = String.format(crUriPattern, prefix + "cloud-owner-" + crCtr, prefix + "cloud-region-id-" + crCtr);
- //System.out.println(crUri);
- cr = g.addV(AAIProperties.NODE_TYPE, CLOUD_REGION,
- CLOUD_REGION_ID, prefix + "cloud-region-id-" + crCtr,
- CLOUD_OWNER, prefix + "cloud-owner-" + crCtr,
- AAIProperties.AAI_URI, crUri
- ).next();
- for (int i = 0; i < tenantNum; i++) {
- Introspector intro = loader.introspectorFromName(TENANT);
- tenant = dbser.createNewVertex(intro);
- edgeSer.addTreeEdge(g, cr, tenant);
- intro.setValue(TENANT_ID, prefix + "tenant-id-" + i);
- intro.setValue(TENANT_NAME, prefix + "tenant-name-" + i);
- dbser.serializeSingleVertex(tenant, intro, "AAI-TEST-" + prefix);
- //System.out.println("Tenant " + crCtr + " " + i);
- for (int j = 0; j < vserverPerTenantNum; j++) {
- intro = loader.introspectorFromName(VSERVER);
- vserver = dbser.createNewVertex(intro);
- edgeSer.addTreeEdge(g, tenant, vserver);
- intro.setValue(VSERVER_ID, prefix + "vserver-id-" + i + "-" + j);
- intro.setValue(VSERVER_NAME, prefix + "vserver-name-" + i + "-" + j);
- intro.setValue(PROV_STATUS, RANDOM_VALUES.get(rand.nextInt(RANDOM_VALUES.size())));
- intro.setValue(VSERVER_SELFLINK, RANDOM_VALUES.get(rand.nextInt(RANDOM_VALUES.size())));
- dbser.serializeSingleVertex(vserver, intro, "AAI-TEST-" + prefix);
- //System.out.println("Vserver " + crCtr + " " + i + " " + j);
- }
- }
- }
- //g.V().forEachRemaining(v -> v.properties().forEachRemaining(p -> System.out.println(p.key() + " : " + p.value())));
- //g.E().forEachRemaining(e -> System.out.println(e.outVertex().property(AAIProperties.NODE_TYPE).value() + " : " + e.inVertex().property(AAIProperties.NODE_TYPE).value()));
- long time = System.currentTimeMillis()-startTime;
- System.out.println("Data load ended\n" + time);
-
- }
-
- @After
- public void deConfigure() throws Exception {
- }
-
- @AfterClass
- public static void teardown() throws Exception {
- dbEngine.rollback();
- System.out.println("Done");
- }
-
- protected void execute(Method getQueryMethod, int numResultsExpected) throws Exception{
-
- int iterations = numOfTimesToRun();
- long noneTimer = 0;
- long uriTimer = 0;
- for (int i = 0; i < iterations+1 ; i++) {
- if (i == 0 ) { // dont use incase initial cold starts
- timeQuery(getQuery(getQueryMethod, OptimizeEnum.NONE), numResultsExpected, OptimizeEnum.NONE);
- timeQuery(getQuery(getQueryMethod, OptimizeEnum.URI), numResultsExpected, OptimizeEnum.URI);
- } else {
- noneTimer += timeQuery(getQuery(getQueryMethod, OptimizeEnum.NONE), numResultsExpected, OptimizeEnum.NONE);
- uriTimer += timeQuery(getQuery(getQueryMethod, OptimizeEnum.URI), numResultsExpected, OptimizeEnum.URI);
- }
- }
-
- noneTimer /= iterations;
- uriTimer /= iterations;
- System.out.println(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getQueryMethod.getName()).replace("-query", "") + "\t" + (noneTimer)/100000.0 + "\t" + (uriTimer)/100000.0);
- //System.out.println((noneTimer)/100000.0 + " ms, (Not optimized)");
- //System.out.println((uriTimer)/100000.0 + " ms, (URI optimized)");
-
- }
-
- private QueryBuilder<Vertex> getQuery(Method getQueryMethod, OptimizeEnum optimization) throws InvocationTargetException, IllegalAccessException {
- return (QueryBuilder<Vertex>) getQueryMethod.invoke(this, optimization);
- }
-
-
- private long timeQuery(QueryBuilder<Vertex> query, int numResultsExpected, OptimizeEnum optimized) {
-
- //System.out.println(optimized.toString());
-
- long startTime = System.nanoTime();
- List<Vertex> result = query.toList();
- long endTime = System.nanoTime();
-
-// if (!optimized) {
-// result.get(0).properties().forEachRemaining(p -> System.out.println(p.key() + " : " + p.value()));
-// }
- //System.out.println("Result size: " + result.size());
- if (numResultsExpected != Integer.MIN_VALUE) {
- assertEquals( optimized.toString() + " optimized" + " query results in " + numResultsExpected + " vserver ", numResultsExpected, result.size());
- }
-
- return endTime - startTime;
-
- }
-
- protected abstract int getTenantNum();
-
- protected abstract int getVserverNumPerTenant();
-
- protected int numOfTimesToRun() {
- return 500;
- }
+ protected static final List<String> RANDOM_VALUES = Arrays.asList("A","B","C","D","E");
+
+ protected static final String crUriPattern = "/cloud-infrastructure/cloud-regions/cloud-region/%s/%s";
+ protected static final String tenantUriPatternSuffix = "/tenants/tenant/%s";
+ protected static final String tenantUriPattern = crUriPattern + tenantUriPatternSuffix;
+ protected static final String vserverUriPatternSuffix = "/vservers/vserver/%s";
+ protected static final String vserverUriPattern = tenantUriPattern + vserverUriPatternSuffix;
+
+ public static final String VSERVER_ID = "vserver-id";
+ public static final String TENANT_ID = "tenant-id";
+ public static final String TENANT_NAME = "tenant-name";
+ public static final String PROV_STATUS = "prov-status";
+ public static final String VSERVER_NAME = "vserver-name";
+ public static final String VSERVER_SELFLINK = "vserver-selflink";
+ public static final String TENANT = "tenant";
+ public static final String VSERVER = "vserver";
+ public static final String CLOUD_REGION = "cloud-region";
+ public static final String CLOUD_REGION_ID = "cloud-region-id";
+ public static final String CLOUD_OWNER = "cloud-owner";
+
+ private static final ModelType introspectorFactoryType = ModelType.MOXY;
+ private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private static final DBConnectionType type = DBConnectionType.REALTIME;
+ private static TransactionalGraphEngine dbEngine;
+ private static DBSerializer dbser;
+ protected static Loader loader;
+ protected static Graph graph;
+ protected static GraphTraversalSource g;
+ @Autowired
+ private static EdgeSerializer edgeSer;
+
+ protected static Random rand;
+
+
+ protected void setupData(int tenantNum, int vserverPerTenantNum, String prefix) throws Exception{
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ graph = AAIGraph.getInstance().getGraph();
+
+ dbEngine = new JanusGraphDBEngine(queryStyle, type, loader);
+ g = dbEngine.startTransaction().traversal();
+ dbser = new DBSerializer(schemaVersions.getDefaultVersion(), dbEngine, introspectorFactoryType, "AAI-TEST-" + prefix);
+
+ rand = new Random();
+
+ Vertex cr;
+ Vertex tenant;
+ Vertex vserver;
+ String crUri;
+ String tenantUri;
+ String vserverUri;
+ System.out.println("Data load started");
+ long startTime = System.currentTimeMillis();
+ for (int crCtr = 0; crCtr < 3; crCtr++) {
+ crUri = String.format(crUriPattern, prefix + "cloud-owner-" + crCtr, prefix + "cloud-region-id-" + crCtr);
+ //System.out.println(crUri);
+ cr = g.addV(AAIProperties.NODE_TYPE, CLOUD_REGION,
+ CLOUD_REGION_ID, prefix + "cloud-region-id-" + crCtr,
+ CLOUD_OWNER, prefix + "cloud-owner-" + crCtr,
+ AAIProperties.AAI_URI, crUri
+ ).next();
+ for (int i = 0; i < tenantNum; i++) {
+ Introspector intro = loader.introspectorFromName(TENANT);
+ tenant = dbser.createNewVertex(intro);
+ edgeSer.addTreeEdge(g, cr, tenant);
+ intro.setValue(TENANT_ID, prefix + "tenant-id-" + i);
+ intro.setValue(TENANT_NAME, prefix + "tenant-name-" + i);
+ dbser.serializeSingleVertex(tenant, intro, "AAI-TEST-" + prefix);
+ //System.out.println("Tenant " + crCtr + " " + i);
+ for (int j = 0; j < vserverPerTenantNum; j++) {
+ intro = loader.introspectorFromName(VSERVER);
+ vserver = dbser.createNewVertex(intro);
+ edgeSer.addTreeEdge(g, tenant, vserver);
+ intro.setValue(VSERVER_ID, prefix + "vserver-id-" + i + "-" + j);
+ intro.setValue(VSERVER_NAME, prefix + "vserver-name-" + i + "-" + j);
+ intro.setValue(PROV_STATUS, RANDOM_VALUES.get(rand.nextInt(RANDOM_VALUES.size())));
+ intro.setValue(VSERVER_SELFLINK, RANDOM_VALUES.get(rand.nextInt(RANDOM_VALUES.size())));
+ dbser.serializeSingleVertex(vserver, intro, "AAI-TEST-" + prefix);
+ //System.out.println("Vserver " + crCtr + " " + i + " " + j);
+ }
+ }
+ }
+ //g.V().forEachRemaining(v -> v.properties().forEachRemaining(p -> System.out.println(p.key() + " : " + p.value())));
+ //g.E().forEachRemaining(e -> System.out.println(e.outVertex().property(AAIProperties.NODE_TYPE).value() + " : " + e.inVertex().property(AAIProperties.NODE_TYPE).value()));
+ long time = System.currentTimeMillis()-startTime;
+ System.out.println("Data load ended\n" + time);
+
+ }
+
+ @After
+ public void deConfigure() throws Exception {
+ }
+
+ @AfterClass
+ public static void teardown() throws Exception {
+ dbEngine.rollback();
+ System.out.println("Done");
+ }
+
+ protected void execute(Method getQueryMethod, int numResultsExpected) throws Exception{
+
+ int iterations = numOfTimesToRun();
+ long noneTimer = 0;
+ long uriTimer = 0;
+ for (int i = 0; i < iterations+1 ; i++) {
+ if (i == 0 ) { // dont use incase initial cold starts
+ timeQuery(getQuery(getQueryMethod, OptimizeEnum.NONE), numResultsExpected, OptimizeEnum.NONE);
+ timeQuery(getQuery(getQueryMethod, OptimizeEnum.URI), numResultsExpected, OptimizeEnum.URI);
+ } else {
+ noneTimer += timeQuery(getQuery(getQueryMethod, OptimizeEnum.NONE), numResultsExpected, OptimizeEnum.NONE);
+ uriTimer += timeQuery(getQuery(getQueryMethod, OptimizeEnum.URI), numResultsExpected, OptimizeEnum.URI);
+ }
+ }
+
+ noneTimer /= iterations;
+ uriTimer /= iterations;
+ System.out.println(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getQueryMethod.getName()).replace("-query", "") + "\t" + (noneTimer)/100000.0 + "\t" + (uriTimer)/100000.0);
+ //System.out.println((noneTimer)/100000.0 + " ms, (Not optimized)");
+ //System.out.println((uriTimer)/100000.0 + " ms, (URI optimized)");
+
+ }
+
+ private QueryBuilder<Vertex> getQuery(Method getQueryMethod, OptimizeEnum optimization) throws InvocationTargetException, IllegalAccessException {
+ return (QueryBuilder<Vertex>) getQueryMethod.invoke(this, optimization);
+ }
+
+
+ private long timeQuery(QueryBuilder<Vertex> query, int numResultsExpected, OptimizeEnum optimized) {
+
+ //System.out.println(optimized.toString());
+
+ long startTime = System.nanoTime();
+ List<Vertex> result = query.toList();
+ long endTime = System.nanoTime();
+
+// if (!optimized) {
+// result.get(0).properties().forEachRemaining(p -> System.out.println(p.key() + " : " + p.value()));
+// }
+ //System.out.println("Result size: " + result.size());
+ if (numResultsExpected != Integer.MIN_VALUE) {
+ assertEquals( optimized.toString() + " optimized" + " query results in " + numResultsExpected + " vserver ", numResultsExpected, result.size());
+ }
+
+ return endTime - startTime;
+
+ }
+
+ protected abstract int getTenantNum();
+
+ protected abstract int getVserverNumPerTenant();
+
+ protected int numOfTimesToRun() {
+ return 500;
+ }
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderTestQueryiesToRun.java b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderTestQueryiesToRun.java
index 8038d15f..8a80fb94 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderTestQueryiesToRun.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderTestQueryiesToRun.java
@@ -33,149 +33,149 @@ import java.net.URI;
public abstract class AbstractGraphTraversalBuilderTestQueryiesToRun extends AbstractGraphTraversalBuilderOptmizationTest {
- protected static final String CLOUD_OWNER_1 = "cloud-owner-1";
- protected static final String CLOUD_REGION_ID_1 = "cloud-region-id-1";
- protected String tenantId;
- protected String vserverId;
- protected String vserverName;
- protected String randomFromList;
-
- @Before
- public void config() throws Exception {
- int tenantNum = rand.nextInt(getTenantNum());
- tenantId = getPrefix() + "tenant-id-" + tenantNum;
- vserverId = getPrefix() + "vserver-id-" + tenantNum + "-" + rand.nextInt(getVserverNumPerTenant());
- vserverName = getPrefix() + "vserver-name-" + tenantNum + "-" + rand.nextInt(getVserverNumPerTenant());
-
- randomFromList = RANDOM_VALUES.get(rand.nextInt(RANDOM_VALUES.size()));
- }
-
- protected abstract String getPrefix();
-
-
- private QueryBuilder<Vertex> getQueryBuilder(OptimizeEnum optimized) {
- if (OptimizeEnum.URI.equals(optimized)) {
- return new TraversalURIOptimizedQuery<>(loader, g);
- } else {
- return new TraversalQuery<>(loader, g);
- }
- }
-
- private void callTest(String methodName, int numResultsExpected) throws Exception {
- String queryMethodName = methodName.replace("Test", "Query");
- Method method = AbstractGraphTraversalBuilderTestQueryiesToRun.class.getMethod(queryMethodName, OptimizeEnum.class);
- this.execute(method, numResultsExpected);
- }
-
- @Test
- public void vserverTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, 1);
- }
-
- public QueryBuilder<Vertex> vserverQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(vserverUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId, vserverId));
- return getQueryBuilder(optimized).createQueryFromURI(uri).getQueryBuilder();
- }
-
- @Test
- public void vserversUnderATenantTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, getVserverNumPerTenant());
- }
-
- public QueryBuilder<Vertex> vserversUnderATenantQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(tenantUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId) + "/vservers");
- return getQueryBuilder(optimized).createQueryFromURI(uri).getQueryBuilder();
- }
-
- @Test
- public void vserversUnderATenantWithNonIndexPropertyTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, Integer.MIN_VALUE);
- }
-
- public QueryBuilder<Vertex> vserversUnderATenantWithNonIndexPropertyQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(tenantUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId) + "/vservers");
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle(VSERVER_SELFLINK, randomFromList);
- return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
- }
-
- @Test
- public void vserversUnderATenantWithIndexPropertyWhereValueIsInMultipleTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, Integer.MIN_VALUE);
- }
-
- public QueryBuilder<Vertex> vserversUnderATenantWithIndexPropertyWhereValueIsInMultipleQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(tenantUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId) + "/vservers");
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle(PROV_STATUS, randomFromList);
- return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
- }
-
- @Test
- public void vserversUnderATenantWithIndexPropertyWhereValueIsSemiUniqueTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, Integer.MIN_VALUE);
- }
-
- public QueryBuilder<Vertex> vserversUnderATenantWithIndexPropertyWhereValueIsSemiUniqueQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(tenantUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId) + "/vservers");
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle(VSERVER_NAME, vserverName);
- return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
-
- }
-
- @Test
- public void nonExistentVserverTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, 0);
- }
-
- public QueryBuilder<Vertex> nonExistentVserverQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(vserverUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId, "does-not-exist"));
- return getQueryBuilder(optimized).createQueryFromURI(uri).getQueryBuilder();
- }
-
- @Test
- public void vserverWithNonExistentTenantTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, 0);
- }
-
- public QueryBuilder<Vertex> vserverWithNonExistentTenantQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(vserverUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, "does-not-exist", vserverId));
- return getQueryBuilder(optimized).createQueryFromURI(uri).getQueryBuilder();
- }
-
- @Test
- public void vserverWithValidQueryParameterTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, 1);
- }
-
- public QueryBuilder<Vertex> vserverWithValidQueryParameterQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(vserverUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId, vserverId));
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("vserver-name2", "someName");
- return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
- }
-
- @Test
- public void cloudRegionTest() throws Exception {
- String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
- callTest(methodName, 1);
- }
-
- public QueryBuilder<Vertex> cloudRegionQuery(OptimizeEnum optimized) throws Exception {
- URI uri = new URI(String.format(crUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1));
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("in-maint", "false");
- return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
- }
+ protected static final String CLOUD_OWNER_1 = "cloud-owner-1";
+ protected static final String CLOUD_REGION_ID_1 = "cloud-region-id-1";
+ protected String tenantId;
+ protected String vserverId;
+ protected String vserverName;
+ protected String randomFromList;
+
+ @Before
+ public void config() throws Exception {
+ int tenantNum = rand.nextInt(getTenantNum());
+ tenantId = getPrefix() + "tenant-id-" + tenantNum;
+ vserverId = getPrefix() + "vserver-id-" + tenantNum + "-" + rand.nextInt(getVserverNumPerTenant());
+ vserverName = getPrefix() + "vserver-name-" + tenantNum + "-" + rand.nextInt(getVserverNumPerTenant());
+
+ randomFromList = RANDOM_VALUES.get(rand.nextInt(RANDOM_VALUES.size()));
+ }
+
+ protected abstract String getPrefix();
+
+
+ private QueryBuilder<Vertex> getQueryBuilder(OptimizeEnum optimized) {
+ if (OptimizeEnum.URI.equals(optimized)) {
+ return new TraversalURIOptimizedQuery<>(loader, g);
+ } else {
+ return new TraversalQuery<>(loader, g);
+ }
+ }
+
+ private void callTest(String methodName, int numResultsExpected) throws Exception {
+ String queryMethodName = methodName.replace("Test", "Query");
+ Method method = AbstractGraphTraversalBuilderTestQueryiesToRun.class.getMethod(queryMethodName, OptimizeEnum.class);
+ this.execute(method, numResultsExpected);
+ }
+
+ @Test
+ public void vserverTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, 1);
+ }
+
+ public QueryBuilder<Vertex> vserverQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(vserverUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId, vserverId));
+ return getQueryBuilder(optimized).createQueryFromURI(uri).getQueryBuilder();
+ }
+
+ @Test
+ public void vserversUnderATenantTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, getVserverNumPerTenant());
+ }
+
+ public QueryBuilder<Vertex> vserversUnderATenantQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(tenantUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId) + "/vservers");
+ return getQueryBuilder(optimized).createQueryFromURI(uri).getQueryBuilder();
+ }
+
+ @Test
+ public void vserversUnderATenantWithNonIndexPropertyTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, Integer.MIN_VALUE);
+ }
+
+ public QueryBuilder<Vertex> vserversUnderATenantWithNonIndexPropertyQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(tenantUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId) + "/vservers");
+ MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
+ map.putSingle(VSERVER_SELFLINK, randomFromList);
+ return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
+ }
+
+ @Test
+ public void vserversUnderATenantWithIndexPropertyWhereValueIsInMultipleTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, Integer.MIN_VALUE);
+ }
+
+ public QueryBuilder<Vertex> vserversUnderATenantWithIndexPropertyWhereValueIsInMultipleQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(tenantUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId) + "/vservers");
+ MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
+ map.putSingle(PROV_STATUS, randomFromList);
+ return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
+ }
+
+ @Test
+ public void vserversUnderATenantWithIndexPropertyWhereValueIsSemiUniqueTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, Integer.MIN_VALUE);
+ }
+
+ public QueryBuilder<Vertex> vserversUnderATenantWithIndexPropertyWhereValueIsSemiUniqueQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(tenantUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId) + "/vservers");
+ MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
+ map.putSingle(VSERVER_NAME, vserverName);
+ return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
+
+ }
+
+ @Test
+ public void nonExistentVserverTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, 0);
+ }
+
+ public QueryBuilder<Vertex> nonExistentVserverQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(vserverUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId, "does-not-exist"));
+ return getQueryBuilder(optimized).createQueryFromURI(uri).getQueryBuilder();
+ }
+
+ @Test
+ public void vserverWithNonExistentTenantTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, 0);
+ }
+
+ public QueryBuilder<Vertex> vserverWithNonExistentTenantQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(vserverUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, "does-not-exist", vserverId));
+ return getQueryBuilder(optimized).createQueryFromURI(uri).getQueryBuilder();
+ }
+
+ @Test
+ public void vserverWithValidQueryParameterTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, 1);
+ }
+
+ public QueryBuilder<Vertex> vserverWithValidQueryParameterQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(vserverUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1, tenantId, vserverId));
+ MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
+ map.putSingle("vserver-name2", "someName");
+ return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
+ }
+
+ @Test
+ public void cloudRegionTest() throws Exception {
+ String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
+ callTest(methodName, 1);
+ }
+
+ public QueryBuilder<Vertex> cloudRegionQuery(OptimizeEnum optimized) throws Exception {
+ URI uri = new URI(String.format(crUriPattern, getPrefix() + CLOUD_OWNER_1, getPrefix() + CLOUD_REGION_ID_1));
+ MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
+ map.putSingle("in-maint", "false");
+ return getQueryBuilder(optimized).createQueryFromURI(uri, map).getQueryBuilder();
+ }
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/OptimizeEnum.java b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/OptimizeEnum.java
index cfc39260..907f4ff5 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/OptimizeEnum.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/OptimizeEnum.java
@@ -20,5 +20,5 @@
package org.onap.aai.query.builder.optimization;
public enum OptimizeEnum {
- URI,NONE
+ URI,NONE
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/AOneTenantOneVserversPerTenantTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/AOneTenantOneVserversPerTenantTest.java
index f004827a..c65dbb4e 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/AOneTenantOneVserversPerTenantTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/AOneTenantOneVserversPerTenantTest.java
@@ -26,28 +26,28 @@ import org.onap.aai.query.builder.optimization.AbstractGraphTraversalBuilderTest
@Ignore
public class AOneTenantOneVserversPerTenantTest extends AbstractGraphTraversalBuilderTestQueryiesToRun {
- private static int tenantNum = 1;
- private static int vserverPerTenantNum = 1;
- private static String prefix = AOneTenantOneVserversPerTenantTest.class.getSimpleName() + "-";
-
- @BeforeClass
- public void setup() throws Exception {
- setupData(tenantNum,vserverPerTenantNum, prefix);
- }
-
- @Override
- protected int getTenantNum() {
- return tenantNum;
- }
-
- @Override
- protected int getVserverNumPerTenant() {
- return vserverPerTenantNum;
- }
-
- @Override
- protected String getPrefix() {
- return prefix;
- }
+ private static int tenantNum = 1;
+ private static int vserverPerTenantNum = 1;
+ private static String prefix = AOneTenantOneVserversPerTenantTest.class.getSimpleName() + "-";
+
+ @BeforeClass
+ public void setup() throws Exception {
+ setupData(tenantNum,vserverPerTenantNum, prefix);
+ }
+
+ @Override
+ protected int getTenantNum() {
+ return tenantNum;
+ }
+
+ @Override
+ protected int getVserverNumPerTenant() {
+ return vserverPerTenantNum;
+ }
+
+ @Override
+ protected String getPrefix() {
+ return prefix;
+ }
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/BTenTenantTenVserversPerTenantTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/BTenTenantTenVserversPerTenantTest.java
index 64f02d09..83c965e4 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/BTenTenantTenVserversPerTenantTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/tests/BTenTenantTenVserversPerTenantTest.java
@@ -26,28 +26,28 @@ import org.onap.aai.query.builder.optimization.AbstractGraphTraversalBuilderTest
@Ignore
public class BTenTenantTenVserversPerTenantTest extends AbstractGraphTraversalBuilderTestQueryiesToRun {
- private static int tenantNum = 10;
- private static int vserverPerTenantNum = 10;
- private static String prefix = BTenTenantTenVserversPerTenantTest.class.getSimpleName() + "-";
-
- @BeforeClass
- public void setup() throws Exception {
- setupData(tenantNum,vserverPerTenantNum, prefix);
- }
-
- @Override
- protected int getTenantNum() {
- return tenantNum;
- }
-
- @Override
- protected int getVserverNumPerTenant() {
- return vserverPerTenantNum;
- }
-
- @Override
- protected String getPrefix() {
- return prefix;
- }
+ private static int tenantNum = 10;
+ private static int vserverPerTenantNum = 10;
+ private static String prefix = BTenTenantTenVserversPerTenantTest.class.getSimpleName() + "-";
+
+ @BeforeClass
+ public void setup() throws Exception {
+ setupData(tenantNum,vserverPerTenantNum, prefix);
+ }
+
+ @Override
+ protected int getTenantNum() {
+ return tenantNum;
+ }
+
+ @Override
+ protected int getVserverNumPerTenant() {
+ return vserverPerTenantNum;
+ }
+
+ @Override
+ protected String getPrefix() {
+ return prefix;
+ }
}