aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test/java/org/onap/aai/rest/search
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal/src/test/java/org/onap/aai/rest/search')
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java124
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java77
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java85
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java115
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java82
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java80
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java138
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java8
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java52
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java105
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java8
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java81
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java111
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java67
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java3
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java156
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java1
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java24
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java94
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java149
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java85
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java80
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java86
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java87
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java11
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java9
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java122
35 files changed, 2285 insertions, 41 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java
new file mode 100644
index 0000000..f6f2a63
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java
@@ -0,0 +1,124 @@
+/**
+* ============LICENSE_START=======================================================
+* org.onap.aai
+* ================================================================================
+* Copyright © 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=========================================================
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+*/
+package org.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class AccessServiceFromServiceInstanceTest extends QueryTest {
+
+ public AccessServiceFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-type", "service-subcription-1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "global-customer-id", "customer-id-1", "subscriber-name", "customer-name1", "subscriber-type", "customer-type1");
+ Vertex forwardingPath = graph.addVertex(T.label, "forwarding-path", T.id, "4", "aai-node-type", "forwarding-path", "forwarding-path-id", "forwarding-path-id-1", "forwarding-path-name", "forwarding-path-name-1");
+ Vertex configuration = graph.addVertex(T.label, "configuration", T.id, "5", "aai-node-type", "configuration", "configuration-id", "configuration-1", "configuration-type", "configuration-type-1", "configuration-sub-type", "configuration-sub-type-1");
+ Vertex evc = graph.addVertex(T.label, "evc", T.id, "6", "aai-node-type", "evc", "evc-id", "evc-1");
+ Vertex forwarder = graph.addVertex(T.label, "forwarder", T.id,"7", "aai-node-type", "forwarder", "sequence", "forwarder-1");
+ Vertex forwarderEvc = graph.addVertex(T.label, "forwarder-evc", T.id, "8", "aai-node-type", "forwarder-evc", "forwarder-evc-id", "forwarder-evc-1");
+ Vertex pInterface = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "p-interface-1");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "10", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex lagInterface = graph.addVertex(T.label, "lag-interface", T.id, "11", "aai-node-type", "lag-interface","interface-name", "lagint1");
+ Vertex logicalLink = graph.addVertex(T.label, "logical-link", T.id, "12", "aai-node-type", "logical-link", "link-name", "logical-link-1", "link-type", "LAG");
+ Vertex badLogicalLink = graph.addVertex(T.label, "logical-link", T.id, "13", "aai-node-type", "logical-link", "link-name", "logical-link-bad", "link-type", "BAD");
+ Vertex wrongInterfaceOne = graph.addVertex(T.label, "l-interface", T.id, "14", "aai-node-type", "l-interface", "interface-name", "wrong-interface-1");
+ Vertex wrongInterfaceTwo = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "interface-name", "wrong-interface-2");
+ Vertex wrongInterfaceThree = graph.addVertex(T.label, "l-interface", T.id, "16", "aai-node-type", "l-interface", "interface-name", "wrong-interface-3");
+ Vertex wrongInterfaceFour = graph.addVertex(T.label, "l-interface", T.id, "17", "aai-node-type", "l-interface", "interface-name", "wrong-interface-4");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, serviceInstance, serviceSubscription);
+ rules.addTreeEdge(g, serviceSubscription, customer);
+ rules.addEdge(g, serviceInstance,forwardingPath);
+ rules.addEdge(g, forwardingPath, configuration);
+ rules.addTreeEdge(g, configuration,evc);
+ rules.addTreeEdge(g, forwardingPath,forwarder);
+ rules.addEdge(g, forwarder, configuration);
+ rules.addTreeEdge(g, configuration,forwarderEvc);
+ rules.addEdge(g, forwarder, pInterface);
+ rules.addTreeEdge(g, pnf,pInterface);
+ rules.addEdge(g, forwarder, lagInterface);
+ rules.addTreeEdge(g, lagInterface,pnf);
+ rules.addEdge(g, logicalLink,lagInterface);
+
+ //incorrect nodes
+ rules.addEdge(g, badLogicalLink, lagInterface);
+ rules.addEdge(g, configuration, wrongInterfaceOne);
+ rules.addEdge(g, forwarder, wrongInterfaceTwo);
+ rules.addTreeEdge(g, pInterface, wrongInterfaceThree);
+ rules.addTreeEdge(g, lagInterface, wrongInterfaceFour);
+
+
+ expectedResult.add(serviceInstance);
+ expectedResult.add(serviceSubscription);
+ expectedResult.add(customer);
+ expectedResult.add(forwardingPath);
+ expectedResult.add(configuration);
+ expectedResult.add(evc);
+ expectedResult.add(forwarder);
+ expectedResult.add(forwarderEvc);
+ expectedResult.add(pInterface);
+ expectedResult.add(pnf);
+ expectedResult.add(lagInterface);
+ expectedResult.add(logicalLink);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "access-service-fromServiceInstance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "customer").has("global-customer-id", "customer-id-1").in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "service-subscription").has("service-type", "service-subcription-1").in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java
new file mode 100644
index 0000000..295194f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java
@@ -0,0 +1,77 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class AvailabilityZoneAndComplexfromCloudRegionQueryTest extends QueryTest {
+ public AvailabilityZoneAndComplexfromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ 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 complex = graph.addVertex(T.label, "complex", T.id, "2", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1","country","country1");
+
+ 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 complex1 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex", "physical-location-id", "physical-location-id-20","country","country20");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, cloudregion, availibityzone);
+ rules.addEdge(g, cloudregion,complex);
+
+ rules.addTreeEdge(g, cloudregion1, availibityzone1);
+ rules.addEdge(g, cloudregion1,complex1);
+
+ expectedResult.add(availibityzone);
+ expectedResult.add(complex);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "availabilityZoneAndComplex-fromCloudRegion";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","cloud-region").has("cloud-owner","cloud-owner-1").has("cloud-region-id","cloud-region-id-1");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java
new file mode 100644
index 0000000..59d2167
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionSitesQueryTest extends QueryTest {
+
+ public CloudRegionSitesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region3 = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region4 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner2");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "4", "aai-node-type", "complex");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex");
+ Vertex complex3 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, region1, complex1);
+ rules.addEdge(g, region2, complex1);
+ rules.addEdge(g, region3, complex2);
+ rules.addEdge(g, region4, complex3);
+
+ expectedResult.add(region1);
+ expectedResult.add(region2);
+ expectedResult.add(region3);
+ expectedResult.add(complex1);
+ expectedResult.add(complex2);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloud-region-sites";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "cloud-region");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("owner", "cloudOwner1");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java
new file mode 100644
index 0000000..9cffc37
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java
@@ -0,0 +1,115 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ColocatedDevicesQueryTest extends QueryTest {
+ public ColocatedDevicesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserverint1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "3", "aai-node-type", "pnf", "pnf-name", "pnfname1");
+ Vertex pnfint1 = graph.addVertex(T.label, "p-interface", T.id, "4", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "5", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex", "physical-location-id", "clli2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "xe0/0/1");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "9", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex pserverint3 = graph.addVertex(T.label, "p-interface", T.id, "10", "aai-node-type", "p-interface", "interface-name", "xe0/0/3");
+ Vertex plink2 = graph.addVertex(T.label, "physical-link", T.id, "11", "aai-node-type", "physical-link", "link-name", "xe0/0/1-to-xe0/0/3");
+
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "12", "aai-node-type", "pnf", "pnf-name", "pnfname2");
+ Vertex pnfint2 = graph.addVertex(T.label, "p-interface", T.id, "13", "aai-node-type", "p-interface", "interface-name", "ge0/0/2");
+ Vertex pnf3 = graph.addVertex(T.label, "pnf", T.id, "14", "aai-node-type", "pnf", "pnf-name", "pnfname3");
+ Vertex pnfint3 = graph.addVertex(T.label, "p-interface", T.id, "15", "aai-node-type", "p-interface", "interface-name", "ge0/0/3");
+ Vertex plink3 = graph.addVertex(T.label, "physical-link", T.id, "16", "aai-node-type", "physical-link", "link-name", "ge0/0/2-to-ge0/0/3");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver1, complex1);
+ rules.addTreeEdge(g, pserver1, pserverint1);
+ rules.addEdge(g, pnf1, complex1);
+ rules.addTreeEdge(g, pnf1, pnfint1);
+ rules.addEdge(g, pserverint1, plink1);
+ rules.addEdge(g, pnfint1, plink1);
+
+ rules.addEdge(g, pserver2, complex1);
+ rules.addTreeEdge(g, pserver2, pserverint2);
+ rules.addEdge(g, pserver3, complex2);
+ rules.addTreeEdge(g, pserver3, pserverint3);
+ rules.addEdge(g, pserverint2, plink2);
+ rules.addEdge(g, pserverint3, plink2);
+
+ rules.addEdge(g, pnf2, complex2);
+ rules.addTreeEdge(g, pnf2, pnfint2);
+ rules.addEdge(g, pnf3, complex2);
+ rules.addTreeEdge(g, pnf3, pnfint3);
+ rules.addEdge(g, pnfint2, plink3);
+ rules.addEdge(g, pnfint3, plink3);
+
+
+ expectedResult.add(pnf1);
+ expectedResult.add(pnfint1);
+ expectedResult.add(pserver1);
+ expectedResult.add(pserverint1);
+ expectedResult.add(plink1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserverint2);
+ expectedResult.add(plink2);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "colocated-devices";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java
new file mode 100644
index 0000000..e0ae06c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ComplexFromVnfTest extends QueryTest {
+ public ComplexFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "1", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "hostname-1");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1", "country", "US");
+
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "hostname-2");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2", "country", "US");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gnvf1, vserver1);
+ rules.addEdge(g, vserver1, pserver1);
+ rules.addEdge(g, pserver1, complex1);
+ rules.addEdge(g, gnvf1, pserver2);
+ rules.addEdge(g, pserver2, complex2);
+
+ expectedResult.add(gnvf1);
+ expectedResult.add(pserver1);
+ expectedResult.add(complex1);
+ expectedResult.add(pserver2);
+ expectedResult.add(complex2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "complex-fromVnf";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-name", "vnf-name-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java
new file mode 100644
index 0000000..523693e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java
@@ -0,0 +1,80 @@
+/**
+* ============LICENSE_START=======================================================
+* org.onap.aai
+* ================================================================================
+* Copyright © 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=========================================================
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+*/
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CountVnfByVnfTypeTest extends QueryTest {
+
+ public CountVnfByVnfTypeTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run(true);
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex genericVnfTypeA1 = graph.addVertex(T.label, "genric-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1", "vnf-type", "A");
+ Vertex genericVnfTypeB1 = graph.addVertex(T.label, "genric-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name-2", "vnf-type", "B");
+ Vertex genericVnfTypeC1 = graph.addVertex(T.label, "genric-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-3", "vnf-name", "vnf-name-3", "vnf-type", "C");
+ Vertex genericVnfTypeA2 = graph.addVertex(T.label, "genric-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-4", "vnf-name", "vnf-name-4", "vnf-type", "A");
+ Vertex genericVnfTypeB2 = graph.addVertex(T.label, "genric-vnf", T.id, "5", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-5", "vnf-name", "vnf-name-5", "vnf-type", "B");
+ Vertex genericVnfTypeA3 = graph.addVertex(T.label, "genric-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-6", "vnf-name", "vnf-name-6", "vnf-type", "A");
+ Vertex genericVnfTypeA4 = graph.addVertex(T.label, "genric-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-7", "vnf-name", "vnf-name-7", "vnf-type", "A");
+
+ GraphTraversalSource g = graph.traversal();
+
+ expectedResultForMaps = expectedResultForMaps + "[A=4, B=2, C=1]";
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "count-vnf-byVnfType";
+ }
+
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ return;
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java
new file mode 100644
index 0000000..f3d374c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java
@@ -0,0 +1,138 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GFPVnfDataTest extends QueryTest {
+ public GFPVnfDataTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0","vnf-name", "vnf-name-1", "nf-type", "sample-nf-type");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "3", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-0");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "4", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-0");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "5", "aai-node-type", "vlan","vlan-interface", "vlan1");
+ Vertex vnfImage = graph.addVertex(T.label, "vnf-image", T.id, "6", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid");
+ Vertex networkProfile = graph.addVertex(T.label, "network-profile", T.id, "7","aai-node-type", "network-profile","nm-profile-name", "nm-profile-name-1");
+ Vertex lagint = graph.addVertex(T.label, "lag-interface", T.id, "8", "aai-node-type", "lag-interface","interface-name", "lagint1");
+
+ Vertex lagint0 = graph.addVertex(T.label, "lag-interface", T.id, "11", "aai-node-type", "lag-interface","interface-name", "lagint31");
+ Vertex linterface0 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id30", "l-interface-name", "l-interface-name30");
+ Vertex vlan0 = graph.addVertex(T.label, "vlan", T.id, "13", "aai-node-type", "vlan","vlan-interface", "vlan31");
+ Vertex l3inter1ipv4addresslist0 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "14", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-30");
+ Vertex l3inter1ipv6addresslist0 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "15", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-30");
+
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "10", "aai-node-type", "generic-vnf", "vnf-id", "vnfid10","vnf-name", "vnf-name-11", "nf-type", "sample-nf-type11");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "20", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id10", "l-interface-name", "l-interface-name10");
+ Vertex l3inter1ipv4addresslist1 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "30", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-10");
+ Vertex l3inter1ipv6addresslist1 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "40", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-10");
+ Vertex vlan1 = graph.addVertex(T.label, "vlan", T.id, "50", "aai-node-type", "vlan","vlan-interface", "vlan11");
+ Vertex vnfImage1 = graph.addVertex(T.label, "vnf-image", T.id, "60", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid11");
+ Vertex networkProfile1 = graph.addVertex(T.label, "network-profile", T.id, "70","aai-node-type", "network-profile","nm-profile-name", "nm-profile-name-11");
+ Vertex lagint1 = graph.addVertex(T.label, "lag-interface", T.id, "80", "aai-node-type", "lag-interface","interface-name", "lagint11");
+
+
+ Vertex lagint2 = graph.addVertex(T.label, "lag-interface", T.id, "21", "aai-node-type", "lag-interface","interface-name", "lagint312");
+ Vertex linterface2 = graph.addVertex(T.label, "l-interface", T.id, "22", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id30", "l-interface-name", "l-interface-name302");
+ Vertex vlan2 = graph.addVertex(T.label, "vlan", T.id, "23", "aai-node-type", "vlan","vlan-interface", "vlan312");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "24", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-302");
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "25", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-302");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, genericvnf, linterface);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addTreeEdge(g, linterface,vlan);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, vlan);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, vlan);
+
+ rules.addTreeEdge(g, genericvnf, lagint0);
+ rules.addTreeEdge(g, lagint0,linterface0);
+ rules.addTreeEdge(g, linterface0,vlan0);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist0, linterface0);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist0, linterface0);
+
+ rules.addEdge(g, genericvnf, vnfImage);
+ rules.addEdge(g, genericvnf, networkProfile);
+
+
+
+ //false
+ rules.addTreeEdge(g, genericvnf1, linterface1);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist1, linterface1);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist1, linterface1);
+ rules.addTreeEdge(g, linterface1,vlan1);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist1, vlan1);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist1, vlan1);
+
+ rules.addTreeEdge(g, genericvnf1, lagint2);
+ rules.addTreeEdge(g, linterface2,lagint2);
+ rules.addTreeEdge(g, linterface2,vlan2);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist2, linterface2);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist2, linterface2);
+
+ rules.addEdge(g, genericvnf1, vnfImage1);
+ rules.addEdge(g, genericvnf1, networkProfile1);
+
+
+ expectedResult.add(genericvnf);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(vlan);
+ expectedResult.add(linterface0);
+ expectedResult.add(vnfImage);
+ expectedResult.add(networkProfile);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "gfp-vnf-data";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-name", "vnf-name-1").has("vnf-id", "vnfid0");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
index 58c5876..9001f48 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
@@ -2,6 +2,8 @@ package org.onap.aai.rest.search;
import static org.junit.Assert.*;
+import java.util.ArrayList;
+
import org.junit.Before;
import org.junit.Test;
@@ -43,7 +45,7 @@ public class GetCustomQueryConfigTest {
CustomQueryConfig cqc = getCustomQueryConfig.getStoredQuery("queryName2");
assertEquals(Lists.newArrayList("prop5"), cqc.getQueryOptionalProperties());
- assertEquals(null, cqc.getQueryRequiredProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryRequiredProperties());
assertEquals("out('bar').has('stuff','baz')", cqc.getQuery());
}
@@ -54,8 +56,8 @@ public class GetCustomQueryConfigTest {
GetCustomQueryConfig getCustomQueryConfig = new GetCustomQueryConfig(configJson);
CustomQueryConfig cqc = getCustomQueryConfig.getStoredQuery("queryName3");
- assertEquals(null, cqc.getQueryOptionalProperties());
- assertEquals(null, cqc.getQueryRequiredProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryOptionalProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryRequiredProperties());
assertEquals("out('bar1').has('stuff','baz1')", cqc.getQuery());
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
new file mode 100644
index 0000000..2c67917
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
@@ -0,0 +1,84 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GfpVserverDataQueryTest extends QueryTest {
+ public GfpVserverDataQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0", "nf-type", "sample-nf-type");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "2", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "4", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "5", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-0");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-0");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "9", "aai-node-type", "vlan", "vlan-interface", "vlan-interface0");
+ Vertex sriovVf = graph.addVertex(T.label, "sriov-vf", T.id, "10", "aai-node-type", "sriov-vf", "pci-id", "pci-id0");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addEdge(g, genericvnf, vserver);
+ rules.addTreeEdge(g, linterface, vserver);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addTreeEdge(g, vlan, linterface);
+ rules.addTreeEdge(g, sriovVf, linterface);
+
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(vlan);
+ }
+ @Override
+ protected String getQueryName() {
+ return "gfp-vserver-data";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vserver");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
index 5c6a45f..1ef953a 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
@@ -135,7 +135,7 @@ public class GremlinServerImplTest {
loader);
GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
builder.queryFrom(URI.create("te"));
-builder.queryFrom("te");
+builder.queryFrom("te", "gremlin");
builder.create();
builder.processWith(QueryProcessorType.GREMLIN_SERVER);
builder.processWith(QueryProcessorType.LOCAL_GROOVY);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
index 3735e97..f1eacc6 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
@@ -135,7 +135,7 @@ public class GroovyShellImplTest {
loader);
GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
builder.queryFrom(URI.create("te"));
-builder.queryFrom("te");
+builder.queryFrom("te", "gremlin");
builder.create();
builder.processWith(QueryProcessorType.GREMLIN_SERVER);
builder.processWith(QueryProcessorType.LOCAL_GROOVY);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
index dcc3d32..e57c698 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
@@ -70,7 +70,7 @@ public class LinkedDevices_NewvceVserverTest extends QueryTest {
"interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region",
- "cloud-owner", "att", "cloud-region-id", "crId");
+ "cloud-owner", "onap", "cloud-region-id", "crId");
Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "60", "aai-node-type", "tenant",
"tenant-id", "tenId", "tenant-name", "verity");
Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "30", "aai-node-type", "vserver",
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
index ea5bc85..9ab7bc5 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
@@ -95,6 +95,8 @@ public class ModelAndNamedQueryRestProviderTest {
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
+ when(uriInfo.getPath()).thenReturn("JUNITURI");
+
headersMultiMap = new MultivaluedHashMap<>();
queryParameters = Mockito.spy(new MultivaluedHashMap<>());
@@ -143,7 +145,8 @@ public class ModelAndNamedQueryRestProviderTest {
Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
httpHeaders,
request,
- queryParameters
+ queryParameters,
+ uriInfo
);
assertNotNull(response);
@@ -164,13 +167,58 @@ public class ModelAndNamedQueryRestProviderTest {
Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
httpHeaders,
null,
- "cloud-region"
+ "cloud-region",
+ uriInfo
);
assertNotNull(response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
+ @Test
+ public void testNamedQueryCallTimeoutThrown() throws Exception {
+
+ String queryParameters = getPayload("payloads/named-queries/named-query.json");
+ HttpServletRequest request = mock(HttpServletRequest.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(request.getContentType()).thenReturn("application/json");
+
+ Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
+ httpHeaders,
+ request,
+ queryParameters,
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testNamedQueryCallTimeoutBypassed() throws Exception {
+
+ String queryParameters = getPayload("payloads/named-queries/named-query.json");
+ HttpServletRequest request = mock(HttpServletRequest.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(request.getContentType()).thenReturn("application/json");
+
+ Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
+ httpHeaders,
+ request,
+ queryParameters,
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ }
+
public String getPayload(String filename) throws IOException {
InputStream inputStream = getClass()
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java
new file mode 100644
index 0000000..226c9fc
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java
@@ -0,0 +1,105 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PnfTopologyQueryTest extends QueryTest {
+
+ public PnfTopologyQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "0", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "1", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pnf1int1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex pnf1int2 = graph.addVertex(T.label, "p-interface", T.id, "3", "aai-node-type", "p-interface", "interface-name", "ge0/0/1");
+ Vertex pnf1int3 = graph.addVertex(T.label, "p-interface", T.id, "4", "aai-node-type", "p-interface", "interface-name", "ge0/0/2");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "7", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "8", "aai-node-type", "pnf", "pnf-name", "pnf2name");
+ Vertex pnf2int = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "ge0/1/0");
+ Vertex plink2 = graph.addVertex(T.label, "physical-link", T.id, "10", "aai-node-type", "physical-link", "link-name", "ge0/0/1-to-ge0/1/0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "xe0/0/1");
+ Vertex pnf2int2 = graph.addVertex(T.label, "p-interface", T.id, "13", "aai-node-type", "p-interface", "interface-name", "ge0/1/0");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pnf1, complex);
+ rules.addTreeEdge(g, pnf1, pnf1int1);
+ rules.addTreeEdge(g, pnf1, pnf1int2);
+ rules.addTreeEdge(g, pnf1, pnf1int3);
+ rules.addEdge(g, pserver, complex);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addEdge(g, pnf1int1, plink1);
+ rules.addEdge(g, pserverint, plink1);
+ rules.addEdge(g, pnf2, complex);
+ rules.addTreeEdge(g, pnf2, pnf2int);
+ rules.addEdge(g, pnf1int2, plink2);
+ rules.addEdge(g, pnf2int, plink2);
+ rules.addEdge(g, vserver, pserver);
+ rules.addTreeEdge(g, pserver, pserverint2);
+ rules.addTreeEdge(g, pnf2, pnf2int2);
+
+ expectedResult.add(pnf1);
+ expectedResult.add(complex);
+ expectedResult.add(pnf1int1);
+ expectedResult.add(pnf1int2);
+ expectedResult.add(pserver);
+ expectedResult.add(pserverint);
+ expectedResult.add(plink1);
+ expectedResult.add(pnf2);
+ expectedResult.add(pnf2int);
+ expectedResult.add(plink2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ // TODO Auto-generated method stub
+ return "pnf-topology";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("pnf-name", "pnf1name");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
index 9a427ca..d445a51 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
@@ -53,6 +53,8 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
"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");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
// Following are extra nodes that should not be picked up in
// expectedResults
@@ -71,10 +73,10 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
rules.addEdge(g, lint2, loglink1);
rules.addEdge(g, loglink1, pserver1);
rules.addEdge(g, loglink1, gvnf1);
+ rules.addEdge(g, gvnf1, pnf1);
// 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);
@@ -84,6 +86,7 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
expectedResult.add(lint1);
expectedResult.add(pserver1);
expectedResult.add(gvnf1);
+ expectedResult.add(pnf1);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
index 9638cfd..d4fe7d9 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
@@ -53,6 +53,8 @@ public class PserverfromConfigurationTest extends QueryTest {
"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");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
// Following are extra nodes that should not be picked up in
// expectedResults
@@ -63,6 +65,8 @@ public class PserverfromConfigurationTest extends QueryTest {
"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");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "18", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor2", "equip-model",
+ "equip-model2");
GraphTraversalSource g = graph.traversal();
rules.addEdge(g, config1, loglink1);
@@ -70,18 +74,20 @@ public class PserverfromConfigurationTest extends QueryTest {
rules.addEdge(g, lint2, loglink1);
rules.addEdge(g, loglink1, pserver1);
rules.addEdge(g, loglink1, gvnf1);
+ rules.addEdge(g, gvnf1, pnf1);
// 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);
+ rules.addEdge(g, gvnf2, pnf2);
expectedResult.add(config1);
expectedResult.add(lint1);
expectedResult.add(lint2);
expectedResult.add(pserver1);
expectedResult.add(gvnf1);
+ expectedResult.add(pnf1);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java
new file mode 100644
index 0000000..64971d6
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserversWithNoComplexTest extends QueryTest {
+
+ public PserversWithNoComplexTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex pserver4 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername4");
+ Vertex pserver5 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername5");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex",
+ "physical-location-id", "physical-location-id-1", "country", "US");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "7", "aai-node-type", "complex",
+ "physical-location-id", "physical-location-id-2", "country", "USA");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver4,complex1);
+ rules.addEdge(g, pserver5,complex2);
+
+ expectedResult.add(pserver1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserver3);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pservers-withNoComplex";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ return;
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java
new file mode 100644
index 0000000..c9a83e7
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java
@@ -0,0 +1,111 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class QueryPnfFromModelByRegionTest extends QueryTest {
+ public QueryPnfFromModelByRegionTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //serviceInstance 1,2,3 are good and 4 is bad based upon the filters
+ 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, "2", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance2", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst3 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance3", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst4 = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance4", "model-invariant-id", "miid2", "model-version-id", "mvid2");
+
+ //pnf 1,2 & 3 are good based upon the filters
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "5", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "6", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf3 = graph.addVertex(T.label, "pnf", T.id, "7", "aai-node-type", "pnf", "pnf-name", "pnf3name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf4 = graph.addVertex(T.label, "pnf", T.id, "12", "aai-node-type", "pnf", "pnf-name", "pnf4name", "equip-vendor", "equip-vendor4",
+ "equip-model", "equip-model4");
+
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "9", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
+
+ //cr 1 is good based upon the filter
+ Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region1");
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "11", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region2");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, serviceInst1, pnf1);
+ rules.addEdge(g, serviceInst2, pnf2);
+ rules.addEdge(g, serviceInst3, pnf3);
+ rules.addEdge(g, serviceInst4, pnf4);
+
+ rules.addEdge(g, pnf1, complex1);
+ rules.addEdge(g, pnf2, complex1);
+ rules.addEdge(g, pnf3, complex2);
+ rules.addEdge(g, pnf4, complex2);
+
+ rules.addEdge(g, cloudRegion1, complex1);
+ rules.addEdge(g, cloudRegion2, complex2);
+
+
+ expectedResult.add(pnf1);
+ expectedResult.add(pnf2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pnf-fromModel-byRegion";
+ }
+
+ @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");
+ params.put("equipVendor", "equip-vendor1");
+ params.put("equipModel", "equip-model1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
index a7c8470..ae54449 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
@@ -21,15 +21,21 @@
*/
package org.onap.aai.rest.search;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -48,18 +54,23 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
public abstract class QueryTest {
-
+
+ private EELFLogger logger;
protected Graph graph;
private GremlinServerSingleton gremlinServerSingleton;
private GremlinGroovyShellSingleton shell;
@Mock private TransactionalGraphEngine dbEngine;
protected final List<Vertex> expectedResult = new ArrayList<>();
+ //expectedResultForMaps is for when the query returns a HashMap, not a Vertex
+ protected String expectedResultForMaps = new String();
protected final EdgeRules rules = EdgeRules.getInstance();
protected Loader loader;
public QueryTest() throws AAIException, NoEdgeRuleFoundException {
setUp();
+ logger = EELFManager.getInstance().getLogger(getClass());
}
+
public void setUp() throws AAIException, NoEdgeRuleFoundException {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
@@ -72,23 +83,61 @@ public abstract class QueryTest {
}
public void run() {
+ this.run(false);
+ }
+
+ public void run(boolean isHashMap) {
String query = gremlinServerSingleton.getStoredQueryFromConfig(getQueryName());
Map<String, Object> params = new HashMap<>();
addParam(params);
when(dbEngine.getQueryBuilder(any(QueryStyle.class))).thenReturn(new GremlinTraversal<>(loader, graph.traversal()));
+ logger.info("Stored query in abstraction form {}", query);
query = GroovyQueryBuilderSingleton.getInstance().executeTraversal(dbEngine, query, params);
+ logger.info("After converting to gremlin query {}", query);
query = "g" + query;
GraphTraversal<Vertex, Vertex> g = graph.traversal().V();
addStartNode(g);
params.put("g", g);
- GraphTraversal<Vertex, Vertex> result = (GraphTraversal<Vertex, Vertex>)shell.executeTraversal(query, params);
- List<Vertex> vertices = result.toList();
- assertTrue("all vertices found", vertices.containsAll(expectedResult) && expectedResult.containsAll(vertices));
+ //Certain custom queries return HashMaps instead of Vertex; different code must used for both cases to avoid a ClassCastException
+ if(!isHashMap) {
+ GraphTraversal<Vertex, Vertex> result = (GraphTraversal<Vertex, Vertex>)shell.executeTraversal(query, params);
+
+ List<Vertex> vertices = result.toList();
+
+ logger.info("Expected result set of vertexes [{}]", convert(expectedResult));
+ logger.info("Actual Result set of vertexes [{}]", convert(vertices));
+ List<Vertex> nonDuplicateExpectedResult = new ArrayList<>(new HashSet<>(expectedResult));
+ vertices = new ArrayList<>(new HashSet<>(vertices));
+
+ nonDuplicateExpectedResult.sort(Comparator.comparing(vertex -> vertex.id().toString()));
+ vertices.sort(Comparator.comparing(vertex -> vertex.id().toString()));
+
+ // Use this instead of the assertTrue as this provides more useful
+ // debugging information such as this when expected and actual differ:
+ // java.lang.AssertionError: Expected all the vertices to be found
+ // Expected :[v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]]
+ // Actual :[v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]]
+ assertEquals("Expected all the vertices to be found", nonDuplicateExpectedResult, vertices);
+ }
+ else {
+ GraphTraversal<HashMap<String,Long>, HashMap<String,Long>> result = (GraphTraversal<HashMap<String,Long>, HashMap<String,Long>>)shell.executeTraversal(query, params);
+
+ String map = result.toList().toString();
+ System.out.println(map);
+ assertTrue("all hash maps found", map.equals(expectedResultForMaps) && expectedResultForMaps.equals(map));
+ }
}
-
+
+ private String convert(List<Vertex> vertices){
+ return vertices
+ .stream()
+ .map(vertex -> vertex.property("aai-node-type").value().toString())
+ .collect(Collectors.joining(","));
+ }
+
protected abstract void createGraph() throws AAIException, NoEdgeRuleFoundException;
protected abstract String getQueryName();
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
index 67f7d11..6d6cf10 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
@@ -80,10 +80,7 @@ public class QueryVnfFromModelByRegionTest extends QueryTest {
rules.addEdge(g, genericVnf3, vserver3);
rules.addTreeEdge(g, tenant1, vserver3);
- rules.addEdge(g, serviceInst1, genericVnf3);
-
expectedResult.add(genericVnf1);
- expectedResult.add(genericVnf3);
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
index 8633cb4..bb04653 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
@@ -91,6 +91,8 @@ public class SearchProviderTest {
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
+ when(uriInfo.getPath()).thenReturn("JUNITURI");
+
headersMultiMap = new MultivaluedHashMap<>();
queryParameters = Mockito.spy(new MultivaluedHashMap<>());
@@ -146,7 +148,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -158,7 +161,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- "latest"
+ "latest",
+ uriInfo
);
assertNotNull(response);
@@ -188,7 +192,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -196,6 +201,73 @@ public class SearchProviderTest {
}
@Test
+ public void testNodesQueryTimeoutThrown() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getNodesQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("7406"));
+ }
+
+ @Test
+ public void testNodesQueryTimeoutBypassed() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getNodesQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("4009"));
+ }
+
+
+ @Test
public void testGenericQueryInvalidData() throws Exception {
List<String> keys = new ArrayList<>();
@@ -214,7 +286,8 @@ public class SearchProviderTest {
keys,
includeStrings,
0,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -226,7 +299,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- "latest"
+ "latest",
+ uriInfo
);
assertNotNull(response);
@@ -257,11 +331,81 @@ public class SearchProviderTest {
keys,
includeStrings,
0,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
+ @Test
+ public void testGenericQueryTimeoutThrown() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getGenericQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ 0,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("7406"));
+ }
+
+ @Test
+ public void testGenericQueryBypassTimeout() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getGenericQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ 0,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("4009"));
+ }
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
index 3be5b34..26b34a4 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
@@ -78,7 +78,6 @@ public class ServiceFromPserverAndSubsNameTest extends QueryTest {
rules.addEdge(g, vserver2, pserver1); //true
rules.addEdge(g, vnf2, vserver2); //true
rules.addEdge(g, vnf2, servinst2); //true
- rules.addEdge(g, vnf2, servinst3); //false
rules.addTreeEdge(g, servinst2, servsub2); //true
rules.addTreeEdge(g, servsub2, customer1); //true
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
index abf9139..93a8195 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
@@ -47,16 +47,24 @@ public class ServiceModelsByDistributionStatusTest extends QueryTest {
Vertex modelver11 = graph.addVertex(T.label, "model-ver", T.id, "21", "aai-node-type", "model-ver", "model-version-id", "model-version-id-11","model-name","model-name11", "model-version","model-version-1", "distribution-status", "distribution-status2");
Vertex model2 = graph.addVertex(T.label, "model", T.id, "3", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-2", "model-type", "resource");
- Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver", "model-version-id", "model-version-id-2","model-name","model-name2", "model-version","model-version-1", "distribution-status", "distribution-status2");
- GraphTraversalSource g = graph.traversal();
+ Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver", "model-version-id", "model-version-id-2","model-name","model-name2", "model-version","model-version-22", "distribution-status", "distribution-status2");
+
+ Vertex model3 = graph.addVertex(T.label, "model", T.id, "5", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-3", "model-type", "service");
+ Vertex modelver3 = graph.addVertex(T.label, "model-ver", T.id, "6", "aai-node-type", "model-ver", "model-version-id", "model-version-id-13","model-name","model-name3", "model-version","model-version-3", "distribution-status", "distribution-status1");
+ Vertex modelver13 = graph.addVertex(T.label, "model-ver", T.id, "7", "aai-node-type", "model-ver", "model-version-id", "model-version-id-33","model-name","model-name33", "model-version","model-version-33", "distribution-status", "distribution-status2");
+
+ GraphTraversalSource g = graph.traversal();
- rules.addTreeEdge(g, modelver1, model1);
- rules.addTreeEdge(g, modelver11, model1);
- rules.addTreeEdge(g, modelver2, model1);
+ rules.addTreeEdge(g, modelver2,model2);
+
+ rules.addTreeEdge(g, modelver3, model3);
+ rules.addTreeEdge(g, modelver13, model3);
+ rules.addTreeEdge(g, modelver11, model3);
- expectedResult.add(model1);
+ expectedResult.add(model3);
+ expectedResult.add(modelver13);
expectedResult.add(modelver11);
- expectedResult.add(modelver2);
+
}
@Override
@@ -65,7 +73,7 @@ public class ServiceModelsByDistributionStatusTest extends QueryTest {
}
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1");
+ g.has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-3");
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java
new file mode 100644
index 0000000..55510fa
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ServiceSitesQueryTest extends QueryTest {
+
+ public ServiceSitesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "0", "aai-node-type", "customer", "global-customer-id", "customer1");
+ Vertex customer2 = graph.addVertex(T.label, "customer", T.id, "1", "aai-node-type", "customer", "global-customer-id", "customer2");
+ Vertex service1 = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-type", "service1");
+ Vertex service2 = graph.addVertex(T.label, "service-subscription", T.id, "3", "aai-node-type", "service-subscription", "service-type", "service2");
+ Vertex instance = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance");
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "5", "aai-node-type", "generic-vnf");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "9", "aai-node-type", "tenant");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, customer1, service1);
+ rules.addTreeEdge(g, customer1, service2);
+ rules.addTreeEdge(g, service1, instance);
+ rules.addEdge(g, vnf, instance);
+ rules.addEdge(g, vnf, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, region);
+ rules.addEdge(g, region, complex);
+ rules.addEdge(g, vserver, pserver);
+ rules.addEdge(g, pserver, complex);
+
+ expectedResult.add(instance);
+ expectedResult.add(vnf);
+ expectedResult.add(region);
+ expectedResult.add(complex);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "service-sites";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "customer");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("customerId", "customer1");
+ params.put("type", "service1");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java
new file mode 100644
index 0000000..92d925b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java
@@ -0,0 +1,149 @@
+package org.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class ServiceTopologyTest extends QueryTest {
+ public ServiceTopologyTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex servinst = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "servInstId01", "service-type", "servType01");
+ Vertex gv = graph.addVertex(T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "name", "vnf-type", "type");
+ Vertex vnfc = graph.addVertex(T.id, "3", "aai-node-type", "vnfc","vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
+
+ Vertex vipipv4addresslist1 = graph.addVertex(T.label, "vip-ipv4-address-list", T.id, "4", "aai-node-type", "vip-ipv4-address-list", "vip-ipv4-addres", "vip-ipv4-address1");
+ Vertex subnet1 = graph.addVertex(T.label, "subnet", T.id, "5", "aai-node-type", "subnet", "subnet-id", "subnet1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network", "network-id", "network1-id1", "network-name", "network1-name1");
+
+ Vertex vipipv6addresslist1 = graph.addVertex(T.label, "vip-ipv6-address-list", T.id, "7", "aai-node-type", "vip-ipv6-address-list", "vip-ipv6-address", "vip-ipv6-address2");
+ Vertex subnet2 = graph.addVertex(T.label, "subnet", T.id, "8", "aai-node-type", "subnet", "subnet-id", "subnet2");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "network-id", "network1-id2", "network-name", "network2-name2");
+
+ Vertex l3inter1ipv4addresslist1 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address1");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "11", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name3");
+ Vertex subnet3 = graph.addVertex(T.label, "subnet", T.id, "12", "aai-node-type", "subnet", "subnet-id", "subnet3");
+ Vertex l3network3_2 = graph.addVertex(T.label, "l3-network", T.id, "13", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network3_2-name3_2");
+
+ Vertex l3inter1ipv6addresslist1 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "14", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address1");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "15", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name4");
+ Vertex subnet4 = graph.addVertex(T.label, "subnet", T.id, "16", "aai-node-type", "subnet", "subnet-id", "subnet4");
+ Vertex l3network4_2 = graph.addVertex(T.label, "l3-network", T.id, "17", "aai-node-type", "l3-network", "network-id", "network3-id4", "network-name", "network4_2-name4_2");
+
+
+ Vertex vserv1 = graph.addVertex(T.id, "18", "aai-node-type", "vserver", "vserver-id", "vservId1", "vserver-name", "vservName1");
+ Vertex tenant1 = graph.addVertex(T.id, "19", "aai-node-type", "tenant", "tenant-id", "ten1", "tenant-name", "tenName1");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "20", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "21", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address2");
+ Vertex l3network5 = graph.addVertex(T.label, "l3-network", T.id, "22", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name3");
+ Vertex subnet5 = graph.addVertex(T.label, "subnet", T.id, "23", "aai-node-type", "subnet", "subnet-id", "subnet3");
+ Vertex l3network5_2 = graph.addVertex(T.label, "l3-network", T.id, "24", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network3_2-name3_2");
+
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "25", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address1");
+ Vertex l3network6 = graph.addVertex(T.label, "l3-network", T.id, "26", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name4");
+ Vertex subnet6 = graph.addVertex(T.label, "subnet", T.id, "27", "aai-node-type", "subnet", "subnet-id", "subnet4");
+ Vertex l3network6_2 = graph.addVertex(T.label, "l3-network", T.id, "28", "aai-node-type", "l3-network", "network-id", "network3-id4", "network-name", "network4_2-name4_2");
+
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "29", "aai-node-type", "pserver", "hostname", "pservername1");
+
+
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "30", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "31", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "32", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, servinst , gv);
+ rules.addEdge(g,gv,vnfc);
+ rules.addEdge(g,vnfc,vipipv4addresslist1);
+ rules.addEdge(g,vipipv4addresslist1,subnet1);
+ rules.addTreeEdge(g,subnet1,l3network1);
+ rules.addEdge(g,vnfc,vipipv6addresslist1);
+ rules.addEdge(g,vipipv6addresslist1,subnet2);
+ rules.addTreeEdge(g,subnet2,l3network2);
+ rules.addTreeEdge(g,vnfc,l3inter1ipv4addresslist1);
+ rules.addEdge(g,l3inter1ipv4addresslist1,l3network3);
+ rules.addEdge(g,l3inter1ipv4addresslist1,subnet3);
+ rules.addTreeEdge(g,subnet3,l3network3_2);
+ rules.addTreeEdge(g,vnfc,l3inter1ipv6addresslist1);
+ rules.addEdge(g,l3inter1ipv6addresslist1,l3network4);
+ rules.addEdge(g,l3inter1ipv6addresslist1,subnet4);
+ rules.addTreeEdge(g,subnet4,l3network4_2);
+ rules.addEdge(g,gv,vserv1);
+ rules.addTreeEdge(g,vserv1,tenant1);
+ rules.addTreeEdge(g,vserv1,linterface1);
+ rules.addTreeEdge(g,linterface1,l3inter1ipv4addresslist2);
+ rules.addEdge(g,l3inter1ipv4addresslist2,l3network5);
+ rules.addEdge(g,l3inter1ipv4addresslist2,subnet5);
+ rules.addTreeEdge(g,subnet5,l3network5_2);
+ rules.addTreeEdge(g,linterface1,l3inter1ipv6addresslist2);
+ rules.addEdge(g,l3inter1ipv6addresslist2,l3network6);
+ rules.addEdge(g,l3inter1ipv6addresslist2,subnet6);
+ rules.addTreeEdge(g,subnet6,l3network6_2);
+ rules.addEdge(g,vserv1,pserver1);
+ rules.addEdge(g,gv,pserver2);
+ rules.addTreeEdge(g,pserver2,pserverint);
+ rules.addEdge(g,pserverint,plink1);
+
+ expectedResult.add(servinst);
+ expectedResult.add(gv);
+ expectedResult.add(vnfc);
+ expectedResult.add(vipipv4addresslist1);
+ expectedResult.add(subnet1);
+ expectedResult.add(l3network1);
+ expectedResult.add(vipipv6addresslist1);
+ expectedResult.add(subnet2);
+ expectedResult.add(l3network2);
+ expectedResult.add(l3inter1ipv4addresslist1);
+ expectedResult.add(l3network3);
+ expectedResult.add(subnet3);
+ expectedResult.add(l3network3_2);
+ expectedResult.add(l3inter1ipv6addresslist1);
+ expectedResult.add(l3network4);
+ expectedResult.add(subnet4);
+ expectedResult.add(l3network4_2);
+ expectedResult.add(vserv1);
+ expectedResult.add(tenant1);
+ expectedResult.add(linterface1);
+ expectedResult.add(l3inter1ipv4addresslist2);
+ expectedResult.add(l3network5);
+ expectedResult.add(subnet5);
+ expectedResult.add(l3network5_2);
+ expectedResult.add(l3inter1ipv6addresslist2);
+ expectedResult.add(l3network6);
+ expectedResult.add(subnet6);
+ expectedResult.add(l3network6_2);
+ expectedResult.add(pserver1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserverint);
+ expectedResult.add(plink1);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "service-topology";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java
new file mode 100644
index 0000000..2d37d13
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SiteL3NetworkCloudRegionQueryTest extends QueryTest {
+
+ public SiteL3NetworkCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "clli2");
+ Vertex network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region");
+ Vertex network3 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, network);
+ rules.addEdge(g, region, network);
+ rules.addEdge(g, complex, network3);
+ rules.addEdge(g, complex2, network2);
+ rules.addEdge(g, region2, network2);
+
+ expectedResult.add(complex);
+ expectedResult.add(network);
+ expectedResult.add(region);
+ expectedResult.add(network3);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "site-l3network-cloudRegion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("physical-location-id", "clli");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java
new file mode 100644
index 0000000..9ddff8a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCloudRegionIdQueryTest extends QueryTest {
+
+ public SitesByCloudRegionIdQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex");
+ Vertex network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-region-id", "regionuuid");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex");
+ Vertex network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "regionuuid2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, network);
+ rules.addEdge(g, region, network);
+ rules.addEdge(g, complex2, network2);
+ rules.addEdge(g, region2, network2);
+
+ expectedResult.add(complex);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCloudRegionId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("cloud-region-id", "regionuuid");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java
new file mode 100644
index 0000000..3f7d404
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCountryFilterCloudRegionIdQueryTest extends QueryTest {
+
+
+ public SitesByCountryFilterCloudRegionIdQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli-100", "country", "countrycode-100");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network", "network-id", "networkId-100", "network-name", "networkName-100",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-100", "cloud-region-id", "cloudRegionId-100");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-200", "cloud-region-id", "cloudRegionId-200");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network", "network-id", "networkId-200", "network-name", "networkName-200",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex", "physical-location-id", "clli-200", "country", "countrycode-100");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, l3network);
+ rules.addEdge(g, cloudregion, l3network);
+ rules.addEdge(g, complex2, l3network2);
+ rules.addEdge(g, cloudregion2, l3network2);
+
+ expectedResult.add(complex);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCountryFilterCloudRegionId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "complex").has("country", "countrycode-100");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionId", "cloudRegionId-100");
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java
new file mode 100644
index 0000000..5c0e7fc
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java
@@ -0,0 +1,87 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCountryFilterCloudRegionVerQueryTest extends QueryTest {
+
+
+ public SitesByCountryFilterCloudRegionVerQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli-100", "country", "countrycode-100");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network", "network-id", "networkId-100", "network-name", "networkName-100",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-100", "cloud-region-id", "cloudRegionId-100",
+ "cloud-region-version", "cloudRegionVer-3.0");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "clli-200", "country", "countrycode-100");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network", "network-id", "networkId-200", "network-name", "networkName-200",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-200", "cloud-region-id", "cloudRegionId-200",
+ "cloud-region-version", "cloudRegionVer-2.5");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, l3network);
+ rules.addEdge(g, cloudregion, l3network);
+ rules.addEdge(g, complex2, l3network2);
+ rules.addEdge(g, cloudregion2, l3network2);
+
+ expectedResult.add(complex);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCountryFilterCloudRegionVer";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "complex").has("country", "countrycode-100");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionVersion", "cloudRegionVer-3.0");
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
index a99fa8f..5e3f7f5 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
@@ -108,8 +108,17 @@ public class TopologyDetailFromVserverQueryTest extends QueryTest {
}
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "cloud-region").has("cloud-region-id", "regionid0").has("cloud-owner", "cloudOwnername0").out("has").has("aai-node-type","tenant").has("tenant-id", "tenantid0").out("owns").has("aai-node-type","vserver").has("vserver-id", "vserverid0");
+ g.has("aai-node-type", "cloud-region")
+ .has("cloud-region-id", "regionid0")
+ .has("cloud-owner", "cloudOwnername0")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","tenant")
+ .has("tenant-id", "tenantid0")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","vserver")
+ .has("vserver-id", "vserverid0");
}
+
@Override
protected void addParam(Map<String, Object> params) {
return;
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
index 1891914..3b70fe1 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
@@ -95,7 +95,7 @@ public class TopologyDetailsQueryTest extends QueryTest {
rules.addEdge(g, owningentity, servinst);
rules.addEdge(g, project, servinst);
rules.addEdge(g, genericvnf, vnfc);
- rules.addEdge(g, vnfc, vserver);
+ rules.addEdge(g, genericvnf,vserver);
rules.addTreeEdge(g, linterface, vserver);
rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
rules.addEdge(g, l3inter1ipv4addresslist, subnet4);
@@ -116,7 +116,7 @@ public class TopologyDetailsQueryTest extends QueryTest {
rules.addEdge(g, owningentity1, servinst1);
rules.addEdge(g, project1, servinst1);
rules.addEdge(g, genericvnf1, vnfc1);
- rules.addEdge(g, vnfc1, vserver1);
+ rules.addEdge(g, genericvnf1,vserver1);
rules.addTreeEdge(g, linterface1, vserver1);
rules.addTreeEdge(g, l3inter1ipv4addresslist1, linterface1);
rules.addEdge(g, l3inter1ipv4addresslist1, subnet41);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
index b10abf3..12a7fd2 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
@@ -240,7 +240,14 @@ public class TopologyFromSubscriberNameAndServiceTypeTest extends QueryTest {
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "customer").has("global-customer-id", "global-customer-id-1").out("subscribesTo").has("aai-node-type","service-subscription").has("service-type", "service-type-1").out("hasInstance").has("aai-node-type","service-instance");
+ g
+ .has("aai-node-type", "customer")
+ .has("global-customer-id", "global-customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","service-subscription")
+ .has("service-type", "service-type-1")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","service-instance");
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java
new file mode 100644
index 0000000..1622f2e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologySummaryQueryTest extends QueryTest {
+
+ public TopologySummaryQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnfuuid");
+ Vertex vnfint = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface", "interface-name", "xe0/0/0");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "1", "aai-node-type", "vnfc");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver");
+ Vertex vserverint = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "xe0/0/0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "3", "aai-node-type", "tenant");
+ Vertex region = graph.addVertex(T.label, "could-region", T.id, "4", "aai-node-type", "cloud-region");
+ Vertex image = graph.addVertex(T.label, "image", T.id, "5", "aai-node-type", "image");
+ Vertex flavor = graph.addVertex(T.label, "flavor", T.id, "6", "aai-node-type", "flavor");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, vnf, vnfc);
+ rules.addEdge(g, vnf, vserver);
+ rules.addEdge(g, vnfc, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, region);
+ rules.addEdge(g, vserver, image);
+ rules.addEdge(g, vserver, flavor);
+ rules.addEdge(g, vserver, pserver);
+ rules.addEdge(g, pserver, complex);
+ rules.addEdge(g, region, complex);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addTreeEdge(g, vnf, vnfint);
+ rules.addTreeEdge(g, vserver, vserverint);
+
+ expectedResult.add(vnf);
+ expectedResult.add(vnfc);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(region);
+ expectedResult.add(image);
+ expectedResult.add(flavor);
+ expectedResult.add(pserver);
+ expectedResult.add(complex);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "topology-summary";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-id", "vnfuuid");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java
new file mode 100644
index 0000000..c434eb0
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class UcpeInstanceQueryTest extends QueryTest {
+
+ public UcpeInstanceQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "11", "aai-node-type", "pnf", "pnf-name", "pnfname");
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnfuuid");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pnfint = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver, complex);
+ rules.addEdge(g, pnf, complex);
+ rules.addEdge(g, vnf, pserver);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addTreeEdge(g, pnf, pnfint);
+
+ expectedResult.add(complex);
+ expectedResult.add(pserver);
+ //expectedResult.add(pnf);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "ucpe-instance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername");
+ //g.has("pnf-name", "pnfname");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
new file mode 100644
index 0000000..59aa3af
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
@@ -0,0 +1,122 @@
+/*-
+ * ============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.onap.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.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class UcpeTopologyQueryTest extends QueryTest {
+ public UcpeTopologyQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pserverint1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "3", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "4", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "5", "aai-node-type", "tenant", "tenant-id", "tenantuuid", "tenant-name", "tenantname");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "6", "aai-node-type", "cloud-region", "cloud-region-id", "clouduuid", "cloud-region-owner", "cloudOwnername");
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf1uuid");
+ Vertex vnf1image = graph.addVertex(T.label, "vnf-image", T.id, "8", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnf1uuid");
+ Vertex vnf2image = graph.addVertex(T.label, "vnf-image", T.id, "10", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf2imageuuid");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "11", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex pnfint = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "13", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+ Vertex servinst1 = graph.addVertex(T.label, "service-instance", T.id, "14", "aai-node-type", "service-instance", "service-instance-id", "servinst1uuid");
+ Vertex servsub1 = graph.addVertex(T.label, "service-subscription", T.id, "15", "aai-node-type", "service-subscription", "service-type", "servType1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "16", "aai-node-type", "customer", "global-customer-id", "custuuid");
+ Vertex servinst2 = graph.addVertex(T.label, "service-instance", T.id, "17", "aai-node-type", "service-instance", "service-instance-id", "servinst2uuid");
+ Vertex servsub2 = graph.addVertex(T.label, "service-subscription", T.id, "18", "aai-node-type", "service-subscription", "service-type", "servType2");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver, complex);
+ rules.addTreeEdge(g, pserver, pserverint1);
+ rules.addTreeEdge(g, pserver, pserverint2);
+ rules.addEdge(g, pnf, complex);
+ rules.addTreeEdge(g, pnf, pnfint);
+ rules.addEdge(g, pserverint1, plink1);
+ rules.addEdge(g, pnfint, plink1);
+ rules.addEdge(g, vserver, pserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, pserver, vnf1);
+ rules.addEdge(g, vserver, vnf2);
+ rules.addEdge(g, vnf1, vnf1image);
+ rules.addEdge(g, vnf2, vnf2image);
+ rules.addEdge(g, vnf1, servinst1);
+ rules.addTreeEdge(g, servinst1, servsub1);
+ rules.addTreeEdge(g, servsub1, customer);
+ rules.addEdge(g, vnf2, servinst2);
+ rules.addTreeEdge(g, servinst2, servsub2);
+ rules.addTreeEdge(g, servsub2, customer);
+
+ expectedResult.add(pnf);
+ expectedResult.add(complex);
+ expectedResult.add(pnfint);
+ expectedResult.add(pserver);
+ expectedResult.add(pserverint1);
+ expectedResult.add(plink1);
+ expectedResult.add(vnf1);
+ expectedResult.add(vnf1image);
+ expectedResult.add(vnf2);
+ expectedResult.add(vnf2image);
+ expectedResult.add(servinst1);
+ expectedResult.add(servinst2);
+ expectedResult.add(servsub1);
+ expectedResult.add(servsub2);
+ expectedResult.add(customer);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "ucpe-topology";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}