aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test/java/org/openecomp
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-09-22 12:33:52 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-09-22 14:02:16 -0400
commit8eb3893cf74e9efab9c8ee45c8b2be135fc80fdb (patch)
tree3ca7fc8b3253f1435ad854a9687e9ed39192658c /aai-traversal/src/test/java/org/openecomp
parent5e40a5c56e98a0125a721b00cb6674c31e58a7a3 (diff)
Add stored queries for port mirroring
Issue-ID: AAI-373 Change-Id: I3356400a0d63791c0f959053e8a2d9fb784de456 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-traversal/src/test/java/org/openecomp')
-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
7 files changed, 559 insertions, 0 deletions
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");
+ }
+
+
+}