aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aai-traversal/bundleconfig-local/etc/query/stored-queries.properties79
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java63
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java68
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java75
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java103
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java101
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java82
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java67
8 files changed, 627 insertions, 11 deletions
diff --git a/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties b/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
index 243c218..6a7c344 100644
--- a/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
+++ b/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
@@ -207,7 +207,7 @@ vserverlogicallink-frompServer=builder.createEdgeTraversal(EdgeType.COUSIN, 'pse
.createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface')\
.createEdgeTraversal(EdgeType.COUSIN, 'l-interface', 'logical-link')\
.store('x').cap('x').unfold().dedup()
-
+
service-fromPserverandSubsName=builder.createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'vserver')\
.createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf')\
.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').where(\
@@ -238,15 +238,7 @@ spaas-topology-fromServiceInstance=builder.createEdgeTraversal(EdgeType.COUSIN,
vnfs-fromServiceInstance=builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf')\
.store('x').cap('x').unfold().dedup()
-
-
-vnfs-fromPserver=builder.where(\
- builder.newInstance().union(\
- builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pserver').getVerticesByProperty('hostname', hostname),\
- builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').getVerticesByProperty('hostname', hostname)\
- )\
- ).store('x').cap('x').unfold().dedup()
-
+
linked-devices=builder.store('x').union(\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface'),\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'lag-interface'),\
@@ -272,6 +264,33 @@ linked-devices=builder.store('x').union(\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver')\
).dedup().simplePath()\
).store('x').cap('x').unfold().dedup()
+vnfs-fromPserver=builder.where(\
+ builder.newInstance().union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pserver').getVerticesByProperty('hostname', hostname),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').getVerticesByProperty('hostname', hostname)\
+ )\
+ ).store('x').cap('x').unfold().dedup()
+
+network-name-fromNetwork-role=builder.createEdgeTraversal(EdgeType.COUSIN, 'cloud-region', 'l3-network')\
+ .getVerticesByProperty('network-role', networkRole).store('x')\
+ .createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'network-policy').store('x')\
+ .cap('x').unfold().dedup()
+
+vserver-fromVnf=builder.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc')\
+ .getVerticesByProperty('nfc-function', nfcFunction).store('x')\
+ .createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x')\
+ .createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x')\
+ .union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x')\
+ ).cap('x').unfold().dedup()
+
+cloud-region-fromVnf=builder.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x')\
+ .createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x')\
+ .createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x')\
+ .createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x')\
+ .cap('x').unfold().dedup()
+
topology-detail-fromVserver=builder.store('x').union(\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x').union(\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x')\
@@ -343,10 +362,48 @@ pending-topology-detail=builder.store('x').union(\
).dedup()\
).cap('x').unfold().dedup()
+pserver-fromConfiguration=builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link')\
+ .union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'pserver').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x')\
+ ).cap('x').unfold().dedup()
+
+pserver-fromConfigurationFilterInterfaceId=builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link')\
+ .where(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').getVerticesByProperty('interface-id', interfaceId).store('x')\
+ )\
+ .union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'pserver').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x')\
+ ).cap('x').unfold().dedup()
+
+fn-topology=builder.union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'line-of-business', 'generic-vnf').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').store('x')\
+ ).dedup()\
+ .union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pserver').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')\
+ )\
+ .cap('x').unfold().dedup()
so-request-vfModule=builder.store('x').union(\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vf-module', 'generic-vnf').store('x')\
.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x'),\
builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vf-module', 'vserver')\
.createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),\
builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vf-module', 'volume-group').store('x')\
- ).cap('x').unfold().dedup() \ No newline at end of file
+ ).cap('x').unfold().dedup()
+
+owning-entity-fromService-instance=builder.createEdgeTraversal(EdgeType.COUSIN,'service-instance', 'owning-entity').store('x').cap('x').unfold().dedup()
+
+queryvnfFromModelbyRegion=builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf')\
+ .where(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver')\
+ .createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant')\
+ .createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region')\
+ .getVerticesByProperty('cloud-region-id', cloudRegionId)\
+ ).store('x')\
+ .cap('x').unfold().dedup() \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java
new file mode 100644
index 0000000..5e0ecd5
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java
@@ -0,0 +1,63 @@
+package org.openecomp.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionFromVnfTest extends QueryTest {
+
+ public CloudRegionFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gv = graph.addVertex(T.id, "00", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "name", "vnf-type", "type");
+ Vertex vnfc = graph.addVertex(T.id, "10", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
+ Vertex vserv = graph.addVertex(T.id, "20", "aai-node-type", "vserver",
+ "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
+ Vertex cr = graph.addVertex(T.id, "30", "aai-node-type", "cloud-region", "cloud-owner", "some guy", "cloud-region-id", "crId");
+ Vertex tenant = graph.addVertex(T.id, "40", "aai-node-type", "tenant", "tenant-id", "ten1", "tenant-name", "tenName");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gv, vnfc);
+ rules.addEdge(g, vnfc, vserv);
+ rules.addTreeEdge(g, cr, tenant);
+ rules.addTreeEdge(g, tenant, vserv);
+
+ expectedResult.add(cr);
+ expectedResult.add(tenant);
+ expectedResult.add(vnfc);
+ expectedResult.add(vserv);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloud-region-fromVnf";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvId");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ // N/A for this query
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java
new file mode 100644
index 0000000..ce88b01
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java
@@ -0,0 +1,68 @@
+package org.openecomp.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class NetworkNameFromNetworkRoleQueryTest extends QueryTest {
+
+ public NetworkNameFromNetworkRoleQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex cr1 = graph.addVertex(T.id, "00", "aai-node-type", "cloud-region", "cloud-owner", "foo", "cloud-region-id", "cr1");
+ Vertex cr2 = graph.addVertex(T.id, "01", "aai-node-type", "cloud-region", "cloud-owner", "bar", "cloud-region-id", "cr2");
+
+ Vertex l3net1 = graph.addVertex(T.id, "10", "aai-node-type", "l3-network",
+ "network-id", "net1", "network-name", "netname1", "network-role", "correct-role");
+ Vertex l3net2 = graph.addVertex(T.id, "11", "aai-node-type", "l3-network",
+ "network-id", "net2", "network-name", "netname2", "network-role", "wrong-role");
+ Vertex l3net3 = graph.addVertex(T.id, "12", "aai-node-type", "l3-network",
+ "network-id", "net3", "network-name", "netname3", "network-role", "correct-role");
+
+ Vertex np1 = graph.addVertex(T.id, "20", "aai-node-type", "network-policy", "network-policy-id", "npId1");
+ Vertex np2 = graph.addVertex(T.id, "21", "aai-node-type", "network-policy", "network-policy-id", "npId2");
+ Vertex np3 = graph.addVertex(T.id, "22", "aai-node-type", "network-policy", "network-policy-id", "npId3");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, cr1, l3net1);
+ rules.addEdge(g, l3net1, np1);
+ rules.addEdge(g, cr1, l3net2);
+ rules.addEdge(g, l3net2, np2);
+ rules.addEdge(g, cr2, l3net3);
+ rules.addEdge(g, l3net3, np3);
+
+ expectedResult.add(l3net1);
+ expectedResult.add(np1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "network-name-fromNetwork-role";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "cloud-region").has("cloud-owner", "foo").has("cloud-region-id", "cr1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("networkRole", "correct-role");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java
new file mode 100644
index 0000000..d6704fa
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class OwningEntityfromServiceInstance extends QueryTest {
+ public OwningEntityfromServiceInstance () throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex service_instance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-1");
+ Vertex owning_entity = graph.addVertex(T.label, "owning-entity", T.id, "2", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-1", "owning-entity-name", "owning-entity-name1");
+
+ // adding extra vertices and edges which shouldn't be picked.
+ Vertex service_instance2 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id", "service-instance-2");
+ Vertex owning_entity2 = graph.addVertex(T.label, "owning-entity", T.id, "4", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-2", "owning-entity-name", "owning-entity-name2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, owning_entity, service_instance);
+ rules.addEdge(g, owning_entity2, service_instance2);
+
+ expectedResult.add(owning_entity);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "owning-entity-fromService-instance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("service-instance-id", "service-instance-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
new file mode 100644
index 0000000..2dc023b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
+ public PserverfromConfigurationFilterInterfaceIdTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex config1 = graph.addVertex(T.label, "configuration", T.id, "1", "aai-node-type", "configuration", "configuration-id", "configuration1");
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "loglink1", "in-maint", "false",
+ "link-type", "link-type1");
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored", "true",
+ "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
+
+ // Following are extra nodes that should not be picked up in
+ // expectedResults
+ Vertex config2 = graph.addVertex(T.label, "configuration", T.id, "11", "aai-node-type", "configuration", "configuration-id", "configuration2");
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "12", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "13", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "14", "aai-node-type", "logical-link", "link-name", "loglink2", "in-maint", "false",
+ "link-type", "link-type2");
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored",
+ "true", "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, config1, loglink1);
+ rules.addEdge(g, config1, loglink2);
+ rules.addEdge(g, lint1, loglink1);
+ rules.addEdge(g, lint2, loglink1);
+ rules.addEdge(g, loglink1, pserver1);
+ rules.addEdge(g, loglink1, gvnf1);
+
+ // These should not be picked up in expectedResults
+ //rules.addEdge(g, config2, loglink2);
+ rules.addEdge(g, lint2, loglink2);
+ rules.addEdge(g, loglink2, pserver2);
+ rules.addEdge(g, loglink2, gvnf2);
+
+ // Note lint2 is not in expectedResults as the filter is based on
+ // interface-id1
+ expectedResult.add(config1);
+ expectedResult.add(lint1);
+ expectedResult.add(pserver1);
+ expectedResult.add(gvnf1);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pserver-fromConfigurationFilterInterfaceId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("configuration-id", "configuration1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("interfaceId", "interface-id1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java
new file mode 100644
index 0000000..fd23bc4
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserverfromConfigurationTest extends QueryTest {
+ public PserverfromConfigurationTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex config1 = graph.addVertex(T.label, "configuration", T.id, "1", "aai-node-type", "configuration", "configuration-id", "configuration1");
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "loglink1", "in-maint", "false",
+ "link-type", "link-type1");
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored", "true",
+ "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
+
+ // Following are extra nodes that should not be picked up in
+ // expectedResults
+ Vertex config2 = graph.addVertex(T.label, "configuration", T.id, "11", "aai-node-type", "configuration", "configuration-id", "configuration2");
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "12", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "13", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "14", "aai-node-type", "logical-link", "link-name", "loglink2", "in-maint", "false",
+ "link-type", "link-type2");
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "16", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored",
+ "true", "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, config1, loglink1);
+ rules.addEdge(g, lint1, loglink1);
+ rules.addEdge(g, lint2, loglink1);
+ rules.addEdge(g, loglink1, pserver1);
+ rules.addEdge(g, loglink1, gvnf1);
+
+ // These should not be picked up in expectedResults
+ rules.addEdge(g, config2, loglink2);
+ rules.addEdge(g, lint2, loglink2);
+ rules.addEdge(g, loglink2, pserver2);
+ rules.addEdge(g, loglink2, gvnf2);
+
+ expectedResult.add(config1);
+ expectedResult.add(lint1);
+ expectedResult.add(lint2);
+ expectedResult.add(pserver1);
+ expectedResult.add(gvnf1);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pserver-fromConfiguration";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("configuration-id", "configuration1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java
new file mode 100644
index 0000000..6fe7872
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java
@@ -0,0 +1,82 @@
+package org.openecomp.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class QueryVnfFromModelByRegionTest extends QueryTest {
+ public QueryVnfFromModelByRegionTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex serviceInst1 = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance",
+ "service-instance-id", "service-instance1", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst2 = graph.addVertex(T.label, "service-instance", T.id, "12", "aai-node-type", "service-instance",
+ "service-instance-id", "service-instance2", "model-invariant-id", "miid2", "model-version-id", "mvid2");
+
+ Vertex genericVnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "generic-vnf-id", "generic-vnf1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserver1");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "4", "aai-node-type", "tenant", "tenant-id", "tenant1");
+ Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region1");
+
+ // Right invariant and version IDs, wrong cloud region
+ Vertex genericVnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf",
+ "generic-vnf-id", "generic-vnf2");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserver2");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant", T.id, "8", "aai-node-type", "tenant", "tenant-id", "tenant2");
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "9", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region2");
+
+ // On both the right and the wrong service-instance, with the right cloud-region
+ Vertex genericVnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "10", "aai-node-type", "generic-vnf",
+ "generic-vnf-id", "generic-vnf3");
+ Vertex vserver3 = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-id", "vserver3");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, serviceInst1, genericVnf1);
+ rules.addEdge(g, genericVnf1, vserver1);
+ rules.addTreeEdge(g, tenant1, vserver1);
+ rules.addTreeEdge(g, cloudRegion1, tenant1);
+
+ rules.addEdge(g, serviceInst1, genericVnf2);
+ rules.addEdge(g, genericVnf2, vserver2);
+ rules.addTreeEdge(g, tenant2, vserver2);
+ rules.addTreeEdge(g, cloudRegion2, tenant2);
+
+ rules.addEdge(g, serviceInst2, genericVnf3);
+ rules.addEdge(g, genericVnf3, vserver3);
+ rules.addTreeEdge(g, tenant1, vserver3);
+
+ rules.addEdge(g, serviceInst1, genericVnf3);
+
+ expectedResult.add(genericVnf1);
+ expectedResult.add(genericVnf3);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "queryvnfFromModelbyRegion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("model-invariant-id", "miid1").has("model-version-id", "mvid1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionId", "cloud-region1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java
new file mode 100644
index 0000000..9d6ad2e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java
@@ -0,0 +1,67 @@
+package org.openecomp.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VserverFromVnfQueryTest extends QueryTest {
+
+ public VserverFromVnfQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gv = graph.addVertex(T.id, "00", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "gvName", "vnf-type", "some-type");
+ Vertex vnfc = graph.addVertex(T.id, "10", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
+ Vertex vserv = graph.addVertex(T.id, "20", "aai-node-type", "vserver",
+ "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
+ Vertex lint = graph.addVertex(T.id, "30", "aai-node-type", "l-interface", "interface-name", "lintName");
+ Vertex ipv4 = graph.addVertex(T.id, "40", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "0.0.0.0");
+ Vertex ipv6 = graph.addVertex(T.id, "50", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "0.0.0.0");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gv, vnfc);
+ rules.addEdge(g, vserv, vnfc);
+ rules.addTreeEdge(g, vserv, lint);
+ rules.addTreeEdge(g, lint, ipv4);
+ rules.addTreeEdge(g, lint, ipv6);
+
+ expectedResult.add(vserv);
+ expectedResult.add(lint);
+ expectedResult.add(ipv4);
+ expectedResult.add(ipv6);
+ expectedResult.add(vnfc);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vserver-fromVnf";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvId");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("nfcFunction", "correct-function");
+ }
+
+
+}