summaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test/java/org
diff options
context:
space:
mode:
authorLaMont, William (wl2432) <wl2432@att.com>2019-01-11 15:21:39 -0500
committerLaMont, William (wl2432) <wl2432@us.att.com>2019-01-16 11:56:04 -0500
commit16b48ab05e63fca707585b4ecee466b8b7721a1b (patch)
treebca44c248860f73d65031162a6f5581c4fef649b /aai-traversal/src/test/java/org
parentc0365f15a25aed95f7e812dc1d7e7ac588ebbed5 (diff)
Update traversal to support v15
Issue-ID: AAI-2073 Change-Id: I1c3df218d1333bdebc984947edc100607958ab60 Signed-off-by: LaMont, William (wl2432) <wl2432@us.att.com>
Diffstat (limited to 'aai-traversal/src/test/java/org')
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java18
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java19
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java12
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java213
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java26
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java43
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java31
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionsByGenericVnfHGPairsTest.java209
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/FabricInformationFromVnfTest.java105
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GenericVnfsFromPserverTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexAndPserversTest.java76
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomerVPNBondingServiceDetailsTest.java161
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetNetworksByServiceInstanceTest.java120
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedHashMapQueryTest.java39
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinterfacesCPFromVnfcTest.java101
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java212
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java13
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java3
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java1
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java14
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfSummaryFromVnfTest.java111
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfToEsrSystemInfoQueryTest.java96
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java141
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfVserverFromCustomerTest.java85
27 files changed, 1892 insertions, 66 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
index 9d3a615..7148ca3 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
@@ -25,30 +25,30 @@ import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.aai.AAISetup;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.exceptions.AAIException;
import org.springframework.beans.factory.annotation.Autowired;
-@Ignore
-public class SearchGraphEdgeRuleTest {
+
+public class SearchGraphEdgeRuleTest extends AAISetup{
@Rule
public ExpectedException expectedEx = ExpectedException.none();
- @Autowired
- SearchGraph searchGraph;
+
@Test
public void getEdgeLabelTest() throws AAIException, EdgeRuleNotFoundException {
String[] label = searchGraph.getEdgeLabel("customer", "service-subscription");
- assertEquals("subscribesTo", label[0]);
+ assertEquals("org.onap.relationships.inventory.BelongsTo", label[0]);
}
@Test
public void getEdgeLabelThrowsExceptionWhenNoRuleExists() throws Exception {
String nodeTypeA = "complex";
String nodeTypeB = "service";
- expectedEx.expect(AAIException.class);
- expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: complex, service.");
+ expectedEx.expect(org.onap.aai.edges.exceptions.EdgeRuleNotFoundException.class);
+ expectedEx.expectMessage("No rules found for EdgeRuleQuery with filter params node type: complex, node type: service, type: any, isPrivate");
searchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
}
@@ -56,8 +56,8 @@ public class SearchGraphEdgeRuleTest {
public void getEdgeLabelThrowsExceptionWhenNodeTypesDoNotExist() throws Exception {
String nodeTypeA = "A";
String nodeTypeB = "B";
- expectedEx.expect(AAIException.class);
- expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: A, B.");
+ expectedEx.expect(org.onap.aai.edges.exceptions.EdgeRuleNotFoundException.class);
+ expectedEx.expectMessage("No rules found for EdgeRuleQuery with filter params node type: A, node type: B, type: any, isPrivate");
searchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
}
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
index 0e539ba..347e21b 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
@@ -40,6 +40,7 @@ import org.junit.Test;
import org.onap.aai.PayloadUtil;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.TraversalConstants;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -109,5 +110,23 @@ public class DslConsumerTest extends AbstractSpringRestTest {
assertEquals("Expected the response to be 400", HttpStatus.INTERNAL_SERVER_ERROR,
responseEntity.getStatusCode());
}
+
+ @Test
+ public void testDslQueryOverride() throws Exception {
+ Map<String, String> dslQuerymap = new HashMap<>();
+ dslQuerymap.put("dsl-query", "pserver*");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQuerymap);
+
+ ResponseEntity responseEntity = null;
+
+ String endpoint = "/aai/v11/dsl?format=console";
+
+ headers.add("X-DslOverride", AAIConfig.get(TraversalConstants.DSL_OVERRIDE));
+ httpEntity = new HttpEntity(payload, headers);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ assertEquals("Expected the response to be 404", HttpStatus.NOT_FOUND,
+ responseEntity.getStatusCode());
+ }
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
index 841b18e..7a6f101 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
@@ -169,7 +169,9 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{
"no_op",
httpHeaders,
uriInfo,
- httpServletRequest
+ httpServletRequest,
+ "-1",
+ "-1"
);
String entity = response.getEntity().toString();
@@ -206,7 +208,9 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{
"no_op",
httpHeaders,
uriInfo,
- httpServletRequest
+ httpServletRequest,
+ "-1",
+ "-1"
);
String entity = response.getEntity().toString();
@@ -244,7 +248,9 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{
"no_op",
httpHeaders,
uriInfo,
- httpServletRequest
+ httpServletRequest,
+ "-1",
+ "-1"
);
String entity = response.getEntity().toString();
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java
new file mode 100644
index 0000000..80efe37
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java
@@ -0,0 +1,213 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.HttpTestUtil;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.TraversalApp;
+import org.onap.aai.TraversalTestConfiguration;
+import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.exceptions.AAIException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Import;
+import org.springframework.http.*;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.client.RestTemplate;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.core.Response;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
+@TestPropertySource(locations = "classpath:application-test.properties")
+@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
+@Import(TraversalTestConfiguration.class)
+public class QueryConsumerTest {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(QueryConsumerTest.class);
+ private HttpTestUtil httpTestUtil;
+
+ private String pserverUri;
+
+ @Autowired
+ RestTemplate restTemplate;
+
+ @LocalServerPort
+ int randomPort;
+
+ private HttpEntity httpEntity;
+
+ private HttpHeaders headers;
+
+ private String baseUrl;
+
+ private String cloudRegionUri;
+
+ @Before
+ public void setup() throws Exception {
+
+ headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Real-Time", "true");
+ headers.add("X-FromAppId", "JUNIT");
+ headers.add("X-TransactionId", "JUNIT");
+ String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
+ headers.add("Authorization", "Basic " + authorization);
+ baseUrl = "https://localhost:" + randomPort;
+ httpTestUtil = new HttpTestUtil();
+ addPserver();
+
+ }
+
+ private void addPserver() throws Exception, UnsupportedEncodingException, AAIException {
+ String hostname = "test-" + UUID.randomUUID().toString();
+ pserverUri = "/aai/v11/cloud-infrastructure/pservers/pserver/" + hostname;
+ Map<String, String> pserverMap = new HashMap<>();
+ pserverMap.put("hostname", hostname);
+ String payload = PayloadUtil.getTemplatePayload("pserver.json", pserverMap);
+ httpTestUtil.doPut(pserverUri, payload);
+ }
+
+ private void addCloudRegion(Map<String, String> cloudRegionMap, String cloudRegionUri)
+ throws Exception, UnsupportedEncodingException, AAIException {
+ String cloudRegionPayload = PayloadUtil.getTemplatePayload("cloud-region-with-vserver.json", cloudRegionMap);
+ Response response = httpTestUtil.doPut(cloudRegionUri, cloudRegionPayload);
+ }
+
+ private void addComplex(Map<String, String> complexMap, String complexUri)
+ throws Exception, UnsupportedEncodingException, AAIException {
+ String complexPayload = PayloadUtil.getTemplatePayload("complex.json", complexMap);
+ Response response = httpTestUtil.doPut(complexUri, complexPayload);
+ }
+
+ //@Test
+ public void testRequiredAGood() throws Exception {
+ String endpoint = "/aai/v14/query?format=pathed";
+ Map<String, String> cloudRegionMap = new HashMap<>();
+ cloudRegionMap.put("cloud-owner", "test-owner-id1111");
+ cloudRegionMap.put("cloud-region-id", "test-region-id1111");
+ cloudRegionMap.put("tenant-id", "test-tenant-id1111");
+ cloudRegionMap.put("tenant-name", "test-tenant-name-id1111");
+ cloudRegionMap.put("vserver-id", "some-vserver-id-id1111");
+ cloudRegionMap.put("vserver-name", "test-vserver-name-id1111");
+ cloudRegionMap.put("pserver-uri", pserverUri);
+ cloudRegionUri = "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/test-owner-id1111/test-region-id1111";
+ addCloudRegion(cloudRegionMap, cloudRegionUri);
+
+ Map<String, String> complexMap = new HashMap<>();
+ complexMap.put("physical-location-id", "location-1111");
+ complexMap.put("cloud-region-uri", cloudRegionUri);
+ String complexUri = "/aai/v14/cloud-infrastructure/complexes/complex/location-1111";
+ addComplex(complexMap, complexUri);
+
+ Map<String, String> customQueryMap = new HashMap<>();
+
+ customQueryMap.put("start", "cloud-infrastructure/cloud-regions");
+ customQueryMap.put("query", "cloud-region-sites?owner=test-owner-id1111");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", customQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity,
+ String.class);
+ LOGGER.info("Response of custom query : {}", responseEntity.getBody().toString());
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+
+ // assertThat(responseEntity.getBody().toString(),
+ // containsString(customerUri2));
+ }
+
+ @Test
+ public void testRequiredBad() throws Exception {
+ String endpoint = "/aai/v14/query?format=pathed";
+ Map<String, String> cloudRegionMap = new HashMap<>();
+ cloudRegionMap.put("cloud-owner", "test-owner-id2222");
+ cloudRegionMap.put("cloud-region-id", "test-region-id2222");
+ cloudRegionMap.put("tenant-id", "test-tenant-id2222");
+ cloudRegionMap.put("tenant-name", "test-tenant-name-id2222");
+ cloudRegionMap.put("vserver-id", "some-vserver-id-id2222");
+ cloudRegionMap.put("vserver-name", "test-vserver-name-id2222");
+ cloudRegionMap.put("pserver-uri", pserverUri);
+ cloudRegionUri = "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/test-owner-id2222/test-region-id2222";
+ addCloudRegion(cloudRegionMap, cloudRegionUri);
+
+ Map<String, String> customQueryMap = new HashMap<>();
+
+ customQueryMap.put("start", "cloud-infrastructure/cloud-regions");
+ customQueryMap.put("query", "cloud-region-sites?owner=test-owner-id2222&extra=extraParam");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", customQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity,
+ String.class);
+ LOGGER.info("Response of custom query : {}", responseEntity.getBody().toString());
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.BAD_REQUEST));
+
+ assertThat(responseEntity.getBody().toString(), containsString("3022"));
+ }
+
+ @After
+ public void tearDown() {
+
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ g.V().has("source-of-truth", "JUNIT").toList().forEach(v -> v.remove());
+
+ } catch (Exception ex) {
+ success = false;
+ LOGGER.error("Unable to remove the vertexes", ex);
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to teardown the graph");
+ }
+ }
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java
index ff2c98f..43ac7c2 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java
@@ -51,6 +51,32 @@ public class RecentApiTest extends AbstractSpringRestTest {
}
@Test
+ public void testRecentsHoursWrongNumber() {
+ String endpoint = "/aai/recents/v14/pserver";
+ httpEntity = new HttpEntity(headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint).queryParam("hours", "1900000000000000000000000000000000000000000000000");
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
+ String.class);
+
+ LOGGER.debug("Response for PUT request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
+ }
+
+ @Test
+ public void testRecentsStartTimeWrongNumber() {
+ String endpoint = "/aai/recents/v14/pserver";
+ httpEntity = new HttpEntity(headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint).queryParam("date-time", "190000000000000000000000000000000000000000000");
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
+ String.class);
+
+ LOGGER.debug("Response for PUT request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
+ }
+
+ @Test
public void testRecentsQueryException() {
String endpoint = "/aai/recents/v14/xserver";
httpEntity = new HttpEntity(headers);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
index abd98e9..e6665fd 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
@@ -34,7 +34,6 @@ import org.onap.aai.exceptions.AAIException;
*/
public class DslQueryProcessorTest extends AAISetup {
-
@Test
public void cloudRegion1Test() throws AAIException {
String aaiQuery = "cloud-region* !('cloud-owner','coid')('cloud-region-id','cr id') LIMIT 10";
@@ -49,11 +48,9 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void cloudRegion_entitlementTest() throws AAIException {
- String aaiQuery = "generic-vnf (> vserver > tenant > cloud-region*('cloud-region-id','One')) > entitlement*";
- String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').where("
- + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
- + ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant')"
- + ".createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ String aaiQuery = "generic-vnf('vnf-id','vnfId') (> vserver > tenant > cloud-region*('cloud-region-id','One')) > entitlement*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ ".getVerticesByProperty('cloud-region-id','One').store('x'))"
+ ".createEdgeTraversal(EdgeType.TREE, 'generic-vnf','entitlement').store('x').cap('x').unfold().dedup()";
@@ -77,9 +74,9 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void cloudRegion_fromComplex1Test() throws AAIException {
- String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('country','count-name')"
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('data-center-code','data-center-code-name')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x').cap('x').unfold().dedup()";
- String aaiQuery = "complex('country','count-name') > cloud-region*";
+ String aaiQuery = "complex('data-center-code','data-center-code-name') > cloud-region*";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
@@ -88,10 +85,10 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void cloudRegion_fromComplex2Test() throws AAIException {
- String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('country','count-name')"
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('data-center-code','data-center-code-name')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').getVerticesByProperty('cloud-region-version','crv')"
+ ".store('x').cap('x').unfold().dedup()";
- String aaiQuery = "complex('country','count-name') > cloud-region*('cloud-region-version','crv')";
+ String aaiQuery = "complex('data-center-code','data-center-code-name') > cloud-region*('cloud-region-version','crv')";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
@@ -161,7 +158,7 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void complex_fromVnf2Test() throws AAIException {
- String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-Id','vnfId').store('x').union("
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').store('x').union("
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x'),"
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
@@ -169,7 +166,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ ").cap('x').unfold().dedup()";
- String aaiQuery = "generic-vnf*('vnf-Id','vnfId') > " + "[ pserver* > complex*, "
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') > " + "[ pserver* > complex*, "
+ " vserver > pserver* > complex* " + "]";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
@@ -180,7 +177,7 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void complex_fromVnfTest() throws AAIException {
- String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-Id','vnfId').store('x').union("
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').store('x').union("
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x'),"
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
@@ -188,7 +185,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ ").cap('x').unfold().dedup()";
- String aaiQuery = "generic-vnf*('vnf-Id','vnfId') > " + "[ pserver* > complex*, "
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') > " + "[ pserver* > complex*, "
+ " vserver > pserver* > complex* " + "]";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
@@ -199,8 +196,8 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void fn_topology1Test() throws AAIException {
- String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'business')"
- + ".getVerticesByProperty('customer-id','a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb')"
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'customer')"
+ + ".getVerticesByProperty('global-customer-id','a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb')"
+ ".createEdgeTraversal(EdgeType.TREE, 'customer','service-subscription').getVerticesByProperty('service-subscription-id','Nimbus')"
+ ".createEdgeTraversal(EdgeType.TREE, 'service-subscription','service-instance').getVerticesByProperty('service-instance-id','sid')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'service-instance','generic-vnf').store('x')"
@@ -209,7 +206,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x'),"
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pnf').store('x')).cap('x').unfold().dedup()";
- String aaiQuery = "business > customer('customer-id', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') > service-subscription('service-subscription-id', 'Nimbus') "
+ String aaiQuery = "customer('global-customer-id', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') > service-subscription('service-subscription-id', 'Nimbus') "
+ " > service-instance('service-instance-id','sid') > generic-vnf* "
+ " > [ vnfc* , vserver*, pserver* , pnf* ]";
@@ -221,11 +218,11 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void vnf_Dsl() throws AAIException {
- String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').where(builder.newInstance().union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver')"
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where(builder.newInstance().union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver')"
+ ".getVerticesByProperty('hostname','hostname1'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'))).store('x').cap('x').unfold().dedup()";
- String aaiQuery = "generic-vnf* (> [pserver('hostname','hostname1'), "
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') (> [pserver('hostname','hostname1'), "
+ "vserver > pserver('hostname','hostname1')])";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
@@ -269,6 +266,14 @@ public class DslQueryProcessorTest extends AAISetup {
}
@Test
+ public void hasPropertyIntegerTest() throws AAIException {
+ String aaiQuery = "cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'MTN61a') > vlan-range > vlan-tag*('vlan-id-inner', 20)";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','att-nc').getVerticesByProperty('cloud-region-id','MTN61a').getVerticesByProperty('vlan-id-inner',20).store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
public void hasNotPropertyTest() throws AAIException {
String aaiQuery = "cloud-region* !('cloud-owner')";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner').store('x').cap('x').unfold().dedup()";
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
index ebb8a19..8275959 100644
--- 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
@@ -17,27 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-/**
-* ============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.*;
@@ -82,7 +61,8 @@ public class AccessServiceFromServiceInstanceTest extends QueryTest {
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");
+ Vertex wrongInterfaceFour = graph.addVertex(T.label, "l-interface", T.id, "17", "aai-node-type", "l-interface", "interface-name", "wrong-interface-4");
+ Vertex vlanMapping = graph.addVertex(T.label, "vlan-mapping", T.id, "18", "aai-node-type", "vlan-mapping", "vlan-mapping-id", "vlan-mapping-1");
GraphTraversalSource g = graph.traversal();
@@ -93,7 +73,8 @@ public class AccessServiceFromServiceInstanceTest extends QueryTest {
rules.addTreeEdge(g, configuration,evc);
rules.addTreeEdge(g, forwardingPath,forwarder);
rules.addEdge(g, forwarder, configuration);
- rules.addTreeEdge(g, configuration,forwarderEvc);
+ rules.addTreeEdge(g, configuration,forwarderEvc);
+ rules.addTreeEdge(g, vlanMapping,forwarderEvc);
rules.addEdge(g, forwarder, pInterface);
rules.addTreeEdge(g, pnf,pInterface);
rules.addEdge(g, forwarder, lagInterface);
@@ -105,8 +86,7 @@ public class AccessServiceFromServiceInstanceTest extends QueryTest {
rules.addEdge(g, configuration, wrongInterfaceOne);
rules.addEdge(g, forwarder, wrongInterfaceTwo);
rules.addTreeEdge(g, pInterface, wrongInterfaceThree);
- rules.addTreeEdge(g, lagInterface, wrongInterfaceFour);
-
+ rules.addTreeEdge(g, lagInterface, wrongInterfaceFour);
expectedResult.add(serviceInstance);
expectedResult.add(serviceSubscription);
@@ -116,6 +96,7 @@ public class AccessServiceFromServiceInstanceTest extends QueryTest {
expectedResult.add(evc);
expectedResult.add(forwarder);
expectedResult.add(forwarderEvc);
+ expectedResult.add(vlanMapping);
expectedResult.add(pInterface);
expectedResult.add(pnf);
expectedResult.add(lagInterface);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionsByGenericVnfHGPairsTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionsByGenericVnfHGPairsTest.java
new file mode 100644
index 0000000..1bfff46
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionsByGenericVnfHGPairsTest.java
@@ -0,0 +1,209 @@
+package org.onap.aai.rest.search;
+
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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=========================================================
+ */
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+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 CloudRegionsByGenericVnfHGPairsTest extends LinkedHashMapQueryTest{
+
+ public CloudRegionsByGenericVnfHGPairsTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ String expectedServiceInstanceUri = "service-instance-id1";
+ String[] expectedCloudRegions = {"c1oud-region-1","c1oud-region-3","c1oud-region-4"};
+ String[] actualCloudRegions = new String[3];
+ assertEquals("Number of results is correct", hashMapList.size(), 3);
+ for(int i = 0; i < hashMapList.size(); i++) {
+ LinkedHashMap currentMap = hashMapList.get(i);
+ assertEquals("Result " + i + " has correct service-instance",
+ currentMap.get("a").toString(), expectedServiceInstanceUri);
+ actualCloudRegions[i] = currentMap.get("b").toString();
+ }
+ Arrays.sort(expectedCloudRegions);
+ Arrays.sort(actualCloudRegions);
+ assertTrue("Cloud regions are correct", Arrays.equals(actualCloudRegions, expectedCloudRegions));
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ // Set up the test graph
+ Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "0", "aai-node-type",
+ "service-subscription", "service-type", "DHV");
+ Vertex servicesubscription1 = graph.addVertex(T.label, "service-subscription", T.id, "1", "aai-node-type",
+ "service-subscription", "service-type", "HNGATEWAY");
+ Vertex servicesubscription2 = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type",
+ "service-subscription", "service-type", "service-type-2");
+
+ Vertex servicesubscription3 = graph.addVertex(T.label, "service-subscription", T.id, "3", "aai-node-type",
+ "service-subscription", "service-type", "HNGATEWAY");
+ Vertex servicesubscription4 = graph.addVertex(T.label, "service-subscription", T.id, "4", "aai-node-type",
+ "service-subscription", "service-type", "HNGATEWAY");
+ Vertex servicesubscription5 = graph.addVertex(T.label, "service-subscription", T.id, "5", "aai-node-type",
+ "service-subscription", "service-type", "HNGATEWAY");
+
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "6", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id1", "aai-uri", "service-instance-id1");
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "7", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id2", "aai-uri", "service-instance-id2");
+ Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "8", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id3", "aai-uri", "service-instance-id3");
+ Vertex serviceinstance3 = graph.addVertex(T.label, "service-instance", T.id, "9", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id4", "aai-uri", "service-instance-id4");
+
+ Vertex serviceinstance4 = graph.addVertex(T.label, "service-instance", T.id, "10", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id5", "aai-uri", "service-instance-id5");
+ Vertex serviceinstance5 = graph.addVertex(T.label, "service-instance", T.id, "11", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id6", "aai-uri", "service-instance-id6");
+ Vertex serviceinstance6 = graph.addVertex(T.label, "service-instance", T.id, "12", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id7", "aai-uri", "service-instance-id7");
+
+ Vertex serviceinstance7 = graph.addVertex(T.label, "service-instance", T.id, "13", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id8", "aai-uri", "service-instance-id8");
+ Vertex serviceinstance8 = graph.addVertex(T.label, "service-instance", T.id, "14", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id9", "aai-uri", "service-instance-id9");
+ Vertex serviceinstance9 = graph.addVertex(T.label, "service-instance", T.id, "15", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id10", "aai-uri", "service-instance-id10");
+
+ Vertex allottedresource = graph.addVertex(T.label, "allotted-resource", T.id, "16", "aai-node-type",
+ "allotted-resource");
+ Vertex allottedresource1 = graph.addVertex(T.label, "allotted-resource", T.id, "17", "aai-node-type",
+ "allotted-resource");
+ Vertex allottedresource2 = graph.addVertex(T.label, "allotted-resource", T.id, "18", "aai-node-type",
+ "allotted-resource");
+ Vertex allottedresource3 = graph.addVertex(T.label, "allotted-resource", T.id, "35", "aai-node-type",
+ "allotted-resource");
+
+ Vertex gvnf = graph.addVertex(T.label, "generic-vnf", T.id, "19", "aai-node-type", "generic-vnf", "vnf-id",
+ "vnf-id-0", "vnf-type", "HG");
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "20", "aai-node-type", "generic-vnf", "vnf-id",
+ "vnf-id-1", "vnf-type", "vnf-type-1");
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "21", "aai-node-type", "generic-vnf", "vnf-id",
+ "vnf-id-2", "vnf-type", "HG");
+ Vertex gvnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "22", "aai-node-type", "generic-vnf", "vnf-id",
+ "vnf-id-2", "vnf-type", "HG");
+ Vertex gvnf4 = graph.addVertex(T.label, "generic-vnf", T.id, "36", "aai-node-type", "generic-vnf", "vnf-id",
+ "vnf-id-2", "vnf-type", "HP");
+
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "23", "aai-node-type", "vserver");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "24", "aai-node-type", "vserver");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "25", "aai-node-type", "vserver");
+ Vertex vserver3 = graph.addVertex(T.label, "vserver", T.id, "26", "aai-node-type", "vserver");
+ Vertex vserver4 = graph.addVertex(T.label, "vserver", T.id, "38", "aai-node-type", "vserver");
+
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "27", "aai-node-type", "tenant");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "28", "aai-node-type", "tenant");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant", T.id, "29", "aai-node-type", "tenant");
+ Vertex tenant3 = graph.addVertex(T.label, "tenant", T.id, "30", "aai-node-type", "tenant");
+ Vertex tenant4 = graph.addVertex(T.label, "tenant", T.id, "39", "aai-node-type", "tenant");
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "31", "aai-node-type", "cloud-region",
+ "aai-uri", "c1oud-region-1");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "32", "aai-node-type", "cloud-region",
+ "aai-uri", "c1oud-region-2");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "33", "aai-node-type", "cloud-region",
+ "aai-uri", "c1oud-region-3");
+ Vertex cloudregion3 = graph.addVertex(T.label, "cloud-region", T.id, "34", "aai-node-type", "cloud-region",
+ "aai-uri", "c1oud-region-4");
+ Vertex cloudregion4 = graph.addVertex(T.label, "cloud-region", T.id, "40", "aai-node-type", "cloud-region",
+ "aai-uri", "c1oud-region-5");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, servicesubscription, serviceinstance);
+
+ rules.addEdge(g, serviceinstance, allottedresource);
+ rules.addEdge(g, serviceinstance, allottedresource1);
+ rules.addEdge(g, serviceinstance, allottedresource2);
+ rules.addEdge(g, serviceinstance, allottedresource3);
+
+ rules.addTreeEdge(g, allottedresource, serviceinstance1);
+ rules.addTreeEdge(g, serviceinstance1, servicesubscription1);
+ rules.addTreeEdge(g, servicesubscription1, serviceinstance2);
+ rules.addEdge(g, serviceinstance2, gvnf);
+ rules.addEdge(g, gvnf, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+
+ rules.addTreeEdge(g, allottedresource1, serviceinstance4);
+ rules.addTreeEdge(g, serviceinstance4, servicesubscription3);
+ rules.addTreeEdge(g, servicesubscription3, serviceinstance5);
+ rules.addEdge(g, serviceinstance5, gvnf2);
+ rules.addEdge(g, gvnf2, vserver2);
+ rules.addTreeEdge(g, vserver2, tenant2);
+ rules.addTreeEdge(g, tenant2, cloudregion2);
+
+ rules.addTreeEdge(g, allottedresource2, serviceinstance6);
+ rules.addTreeEdge(g, serviceinstance6, servicesubscription4);
+ rules.addTreeEdge(g, servicesubscription4, serviceinstance7);
+ rules.addEdge(g, serviceinstance7, gvnf3);
+ rules.addEdge(g, gvnf3, vserver3);
+ rules.addTreeEdge(g, vserver3, tenant3);
+ rules.addTreeEdge(g, tenant3, cloudregion3);
+
+ rules.addTreeEdge(g, allottedresource3, serviceinstance8);
+ rules.addTreeEdge(g, serviceinstance8, servicesubscription5);
+ rules.addTreeEdge(g, servicesubscription5, serviceinstance9);
+ rules.addEdge(g, serviceinstance9, gvnf4);
+ rules.addEdge(g, gvnf4, vserver4);
+ rules.addTreeEdge(g, vserver4, tenant4);
+ rules.addTreeEdge(g, tenant4, cloudregion4);// Not expected in output as vnf-type is not HG
+
+
+ rules.addTreeEdge(g, servicesubscription2, serviceinstance3);
+ rules.addEdge(g, serviceinstance3, allottedresource);
+ rules.addEdge(g, serviceinstance2, gvnf1);
+ rules.addEdge(g, gvnf1, vserver1);
+ rules.addTreeEdge(g, vserver1, tenant1);
+ rules.addTreeEdge(g, tenant1, cloudregion1);// Not expected in output as service-subscription is not DHV
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloud-regions-by-generic-vnf-HG-pairs";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-subscription").has("service-type", "DHV");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/FabricInformationFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/FabricInformationFromVnfTest.java
new file mode 100644
index 0000000..68393c5
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/FabricInformationFromVnfTest.java
@@ -0,0 +1,105 @@
+package org.onap.aai.rest.search;
+
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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=========================================================
+ */
+
+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 FabricInformationFromVnfTest extends QueryTest{
+
+ public FabricInformationFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex gvnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-0", "vnf-name", "vnf-name-0", "vnf-type", "vnf-type-0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "1", "aai-node-type", "vserver", "vserver-id", "vserver-id-0", "vserver-name", "vserver-name-0", "vserver-selflink", "vserver-selflink-0");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "interface-name", "interface-name-0");
+ Vertex sriovvf = graph.addVertex(T.label, "sriov-vf", T.id, "3", "aai-node-type", "sriov-vf", "pci-id", "pci-id-0");
+ Vertex sriovpf = graph.addVertex(T.label, "sriov-pf", T.id, "4", "aai-node-type", "sriov-pf", "pf-pci-id", "pf-pci-id-0");
+ Vertex pinterface = graph.addVertex(T.label, "p-interface", T.id, "5", "aai-node-type", "p-interface", "interface-name", "interface-name-0");
+ Vertex pserver = graph.addVertex(T.label, "p-server", T.id, "6", "aai-node-type", "pserver", "hostname", "hostname-0");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "7", "aai-node-type", "vnfc", "vnfc-name", "vnfc-name-0", "nfc-naming-code", "nfc-naming-code-0", "nfc-naming-function", "nfc-naming-function-0");
+ Vertex cp = graph.addVertex(T.label, "cp", T.id, "8", "aai-node-type", "cp", "cp-instance-id", "cp-instance-id-0");
+ Vertex vlantag = graph.addVertex(T.label, "vlan-tag", T.id, "9", "aai-node-type", "vlan-tag","vlan-tag-id", "vlan-tag-id-0");
+
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "16", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1", "vnf-type", "vnf-type-1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "10", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-0", "vserver-selflink", "vserver-selflink-0");
+ Vertex vlantag1 = graph.addVertex(T.label, "vlan-tag", T.id, "11", "aai-node-type", "vlan-tag","vlan-tag-id", "vlan-tag-id-1");
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc", T.id, "14", "aai-node-type", "vnfc", "vnfc-name", "vnfc-name-1", "nfc-naming-code", "nfc-naming-code-1", "nfc-naming-function", "nfc-naming-function-1");
+ Vertex cp1 = graph.addVertex(T.label, "cp", T.id, "15", "aai-node-type", "cp", "cp-instance-id", "cp-instance-id-1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gvnf, vserver);
+ rules.addTreeEdge(g, vserver, linterface);
+ rules.addTreeEdge(g, linterface, sriovvf);
+ rules.addEdge(g, sriovvf, sriovpf);
+ rules.addTreeEdge(g, sriovpf, pinterface);
+ rules.addTreeEdge(g, pinterface, pserver);
+ rules.addEdge(g, vserver, vnfc);
+ rules.addTreeEdge(g, vnfc, cp);
+ rules.addEdge(g, cp, vlantag);
+
+ rules.addEdge(g, gvnf1, vserver1);
+ rules.addEdge(g, vserver1, vnfc1);
+ rules.addTreeEdge(g, vnfc1, cp1);
+ rules.addEdge(g, cp1, vlantag1);//false
+
+
+ expectedResult.add(gvnf);
+ expectedResult.add(vserver);
+ expectedResult.add(pinterface);
+ expectedResult.add(pserver);
+ expectedResult.add(vnfc);
+ expectedResult.add(vlantag);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "fabric-information-fromVnf";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "vnf-id-0");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GenericVnfsFromPserverTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GenericVnfsFromPserverTest.java
new file mode 100644
index 0000000..4d42fce
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GenericVnfsFromPserverTest.java
@@ -0,0 +1,103 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 GenericVnfsFromPserverTest extends QueryTest {
+ public GenericVnfsFromPserverTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1", "vnf-type", "test", "nf-function", "test"
+ ,"nf-role", "test", "nf-naming-code", "test");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name-2", "vnf-type", "test", "nf-function", "test"
+ ,"nf-role", "test", "nf-naming-code", "test");
+ Vertex vnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-3", "vnf-name", "vnf-name-3", "vnf-type", "test", "nf-function", "test"
+ ,"nf-role", "test", "nf-naming-code", "test");
+ Vertex vnf4 = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-4", "vnf-name", "vnf-name-4", "vnf-type", "test", "nf-function", "test"
+ ,"nf-role", "test", "nf-naming-code", "test");
+ Vertex badVnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnf-bad-1", "vnf-name", "vnf-bad-1", "vnf-type", "test");
+ Vertex badVnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "5", "aai-node-type", "generic-vnf", "vnf-id", "vnf-bad-2", "vnf-name", "vnf-bad-2", "nf-function", "test");
+ Vertex badVnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnf-bad-3", "vnf-name", "vnf-bad-3", "vnf-type", "bad", "nf-function", "bad");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "8", "aai-node-type", "vserver", "vserver-id", "vserver-id-2", "vserver-name", "vserver-name-2");
+ Vertex badVserver = graph.addVertex(T.label, "vserver", T.id, "9", "aai-node-type", "vserver", "vserver-id", "vserver-bad", "vserver-name", "vserver-bad");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "10", "aai-node-type", "pserver", "hostname", "hostname-1", "fqdn", "fqdn");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "11", "aai-node-type", "pserver", "hostname", "hostname-2", "fqdn", "fqdn");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "12", "aai-node-type", "pserver", "hostname", "hostname-3", "fqdn", "fqdn");
+ Vertex badPserver1 = graph.addVertex(T.label, "pserver", T.id, "13", "aai-node-type", "pserver", "hostname", "hostname-bad-1", "fqdn", "fqdn");
+ Vertex badPserver2 = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "hostname-bad-2", "fqdn", "fqdn");
+ Vertex badPserver3 = graph.addVertex(T.label, "pserver", T.id, "15", "aai-node-type", "pserver", "hostname", "hostname-bad-3", "fqdn", "fqdn");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver1, vnf1);
+ rules.addEdge(g, pserver2, vserver1);
+ rules.addEdge(g, vserver1, vnf2);
+ rules.addEdge(g, pserver3, vnf3);
+ rules.addEdge(g, pserver3, vserver2);
+ rules.addEdge(g, vserver2, vnf4);
+ rules.addEdge(g, badPserver1, badVnf1);
+ rules.addEdge(g, badPserver2, badVserver);
+ rules.addEdge(g, badVserver, badVnf2);
+ rules.addEdge(g, badPserver3, badVnf3);
+
+ expectedResult.add(vnf1);
+ expectedResult.add(vnf2);
+ expectedResult.add(vnf3);
+ expectedResult.add(vnf4);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "genericVnfs-fromPserver";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "pserver").has("fqdn", "fqdn");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("vnfType","test");
+ params.put("nfFunction","test");
+ params.put("nfRole","test");
+ params.put("nfNamingCode", "test");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java
index 9ddd2e3..e1cd663 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java
@@ -74,7 +74,7 @@ public class GetClfiRoadmTailSummaryTest extends QueryTest {
rules.addEdge(g, logicalLink1, lInterface1);//false
- expectedResult.add(logicalLink1);
+ //expectedResult.add(logicalLink1);
expectedResult.add(pInterface1);
expectedResult.add(pnf1);
expectedResult.add(pInterface2);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexAndPserversTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexAndPserversTest.java
new file mode 100644
index 0000000..5b17f32
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexAndPserversTest.java
@@ -0,0 +1,76 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 GetComplexAndPserversTest extends QueryTest {
+ public GetComplexAndPserversTest() 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, "1", "aai-node-type", "complex", "complex-id", "complex-1");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername1");
+
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "complex-id", "complex-2");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername2");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, complex, pserver );
+
+ //Not expected in result
+ rules.addEdge(g, complex1, pserver1 );
+ //Not expected in result
+
+ expectedResult.add(complex);
+ expectedResult.add(pserver);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getComplexAndPservers";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "complex").has("complex-id", "complex-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomerVPNBondingServiceDetailsTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomerVPNBondingServiceDetailsTest.java
new file mode 100644
index 0000000..d080016
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomerVPNBondingServiceDetailsTest.java
@@ -0,0 +1,161 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 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 GetCustomerVPNBondingServiceDetailsTest extends QueryTest {
+
+ public GetCustomerVPNBondingServiceDetailsTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "1", "aai-node-type", "service-subscription",
+ "service-type", "start-test");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "2", "aai-node-type", "customer",
+ "global-customer-id", "customer-test", "subscriber-name", "test-name", "subscriber-type", "test-type");
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance",
+ "service-instance-id", "test-instance");
+ Vertex configurationOne = graph.addVertex(T.label, "configuration", T.id, "4", "aai-node-type", "configuration",
+ "configuration-id", "test-config-1", "configuration-type", "VLAN-NETWORK-RECEPTOR");
+ Vertex configurationTwo = graph.addVertex(T.label, "configuration", T.id, "5", "aai-node-type", "configuration",
+ "configuration-id", "test-config-2", "configuration-type", "VLAN-NETWORK-RECEPTOR");
+ Vertex badConfiguration = graph.addVertex(T.label, "configuration", T.id, "6", "aai-node-type", "configuration",
+ "configuration-id", "bad-config", "configuration-type", "bad");
+ Vertex genericVnfOne = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf",
+ "vnf-id", "test-generic-vnf-1", "vnf-type", "right-relationship");
+ Vertex genericVnfTwo = graph.addVertex(T.label, "generic-vnf", T.id, "8", "aai-node-type", "generic-vnf",
+ "vnf-id", "test-generic-vnf-2", "vnf-type", "wrong-relationship");
+ Vertex rightInstanceGroup = graph.addVertex(T.label, "instance-group", T.id, "9", "aai-node-type", "instance-group",
+ "id", "test-group-right", "description", "MemberOf relationship", "instance-group-type", "lower case ha for high availability");
+ Vertex wrongInstanceGroup = graph.addVertex(T.label, "instance-group", T.id, "10", "aai-node-type", "instance-group",
+ "id", "test-group-wrong", "description", "Uses relationship", "instance-group-type", "lower case ha for high availability");
+ Vertex l3Network = graph.addVertex(T.label, "l3-network", T.id, "11", "aai-node-type", "l3-network",
+ "network-id", "test-l3");
+ Vertex subnet = graph.addVertex(T.label, "subnet", T.id, "12", "aai-node-type", "subnet",
+ "subnet-id", "test-subnet");
+ Vertex l3InterfaceIpv6AddressList = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "13", "aai-node-type", "l3-interface-ipv6-address-list",
+ "l3-interface-ipv6-address", "test-ipv6");
+ Vertex l3InterfaceIpv4AddressList = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "14", "aai-node-type", "l3-interface-ipv4-address-list",
+ "l3-interface-ipv4-address", "test-ipv4");
+ Vertex l3VpnBinding = graph.addVertex(T.label, "vpn-binding", T.id, "15", "aai-node-type", "vpn-binding",
+ "vpn-id", "test-binding", "vpn-name", "test");
+ Vertex l3RouteTarget = graph.addVertex(T.label, "route-target", T.id, "16", "aai-node-type", "route-target",
+ "global-route-target", "test-target", "route-target-role", "test");
+ Vertex parentLInterface = graph.addVertex(T.label, "l-interface", T.id, "17", "aai-node-type", "l-interface",
+ "interface-name", "parent-test-l-interface");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "18", "aai-node-type", "vlan",
+ "vlan-interface", "test-vlan");
+ Vertex childLInterface = graph.addVertex(T.label, "l-interface", T.id, "19", "aai-node-type", "l-interface",
+ "interface-name", "child-test-l-interface");
+ Vertex configurationThree = graph.addVertex(T.label, "configuration", T.id, "20", "aai-node-type", "configuration",
+ "configuration-id", "test-config-3", "configuration-type", "VRF ENTRY");
+ Vertex configVpnBinding = graph.addVertex(T.label, "vpn-binding", T.id, "21", "aai-node-type", "vpn-binding",
+ "vpn-id", "test-binding-config", "vpn-name", "test");
+ Vertex configRouteTarget = graph.addVertex(T.label, "route-target", T.id, "22", "aai-node-type", "route-target",
+ "global-route-target", "test-target-config", "route-target-role", "test");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "23", "aai-node-type", "pnf",
+ "pnf-name", "test-pnf", "nf-role", "D2IPE");
+ Vertex badPnf = graph.addVertex(T.label, "pnf", T.id, "24", "aai-node-type", "pnf",
+ "pnf-name", "test-pnf", "nf-role", "none");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, customer, serviceSubscription);
+ rules.addTreeEdge(g, serviceSubscription, serviceInstance);
+ rules.addEdge(g, serviceInstance, configurationOne);
+ rules.addEdge(g, serviceInstance, configurationTwo);
+ rules.addEdge(g, serviceInstance, badConfiguration);
+ rules.addEdge(g, configurationOne, genericVnfOne);
+ rules.addEdge(g, configurationTwo, genericVnfTwo);
+ rules.addEdge(g, genericVnfOne, rightInstanceGroup, "org.onap.relationships.inventory.MemberOf");
+ rules.addEdge(g, genericVnfTwo, wrongInstanceGroup, "org.onap.relationships.inventory.Uses");
+ rules.addEdge(g, configurationOne, l3Network);
+ rules.addTreeEdge(g, l3Network, subnet);
+ rules.addEdge(g, subnet, l3InterfaceIpv6AddressList);
+ rules.addEdge(g, subnet, l3InterfaceIpv4AddressList);
+ rules.addEdge(g, l3Network, l3VpnBinding);
+ rules.addTreeEdge(g, l3VpnBinding, l3RouteTarget);
+ rules.addEdge(g, configurationOne, parentLInterface);
+ rules.addTreeEdge(g, parentLInterface, vlan);
+ rules.addTreeEdge(g, parentLInterface, childLInterface);
+ rules.addEdge(g, serviceInstance, configurationThree);
+ rules.addEdge(g, configurationThree, configVpnBinding);
+ rules.addTreeEdge(g, configVpnBinding, configRouteTarget);
+ rules.addEdge(g, configurationThree, pnf);
+ rules.addEdge(g, configurationThree, badPnf);
+
+ expectedResult.add(customer);
+ expectedResult.add(serviceInstance);
+ expectedResult.add(configurationOne);
+ expectedResult.add(configurationTwo);
+ expectedResult.add(genericVnfOne);
+ expectedResult.add(genericVnfTwo);
+ expectedResult.add(rightInstanceGroup);
+ expectedResult.add(l3Network);
+ expectedResult.add(subnet);
+ expectedResult.add(l3InterfaceIpv6AddressList);
+ expectedResult.add(l3InterfaceIpv4AddressList);
+ expectedResult.add(l3VpnBinding);
+ expectedResult.add(l3RouteTarget);
+ expectedResult.add(parentLInterface);
+ expectedResult.add(vlan);
+ expectedResult.add(childLInterface);
+ expectedResult.add(configurationThree);
+ expectedResult.add(configVpnBinding);
+ expectedResult.add(configRouteTarget);
+ expectedResult.add(pnf);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getCustomerVPNBondingServiceDetails";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-subscription").has("service-type", "start-test");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetNetworksByServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetNetworksByServiceInstanceTest.java
new file mode 100644
index 0000000..1b1395c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetNetworksByServiceInstanceTest.java
@@ -0,0 +1,120 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 GetNetworksByServiceInstanceTest extends QueryTest {
+
+ public GetNetworksByServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance",T.id, "0", "aai-node-type", "service-instance", "service-instance-id", "serviceinstanceid");
+ Vertex l3Network = graph.addVertex(T.label, "l3-network",T.id, "1", "aai-node-type", "l3-network","network-id", "networkId");
+ Vertex vlanTag = graph.addVertex(T.label, "vlan-tag",T.id, "2", "aai-node-type", "vlan-tag","vlan-tag-id", "vlanTagId");
+ Vertex l3Network1 = graph.addVertex(T.label, "l3-network",T.id, "3", "aai-node-type", "l3-network","network-id", "networkId1");
+ Vertex vlanTag1 = graph.addVertex(T.label, "vlan-tag",T.id, "4", "aai-node-type", "vlan-tag","vlan-tag-id", "vlanTagId");
+
+ Vertex serviceInstance2 = graph.addVertex(T.label, "service-instance",T.id, "5", "aai-node-type", "service-instance", "service-instance-id", "serviceinstanceid1");
+ Vertex l3Network2 = graph.addVertex(T.label, "l3-network",T.id, "6", "aai-node-type", "l3-network","network-id", "networkId2");
+ Vertex vlanTag2 = graph.addVertex(T.label, "vlan-tag",T.id, "7", "aai-node-type", "vlan-tag","vlan-tag-id", "vlanTagId");
+ Vertex l3Network3 = graph.addVertex(T.label, "l3-network",T.id, "8", "aai-node-type", "l3-network","network-id", "networkId3");
+ Vertex vlanTag3 = graph.addVertex(T.label, "vlan-tag",T.id, "9", "aai-node-type", "vlan-tag","vlan-tag-id", "vlanTagId");
+ Vertex vlanTag4 = graph.addVertex(T.label, "vlan-tag",T.id, "10", "aai-node-type", "vlan-tag","vlan-tag-id", "vlanTagId");
+
+
+ Vertex l3Network4 = graph.addVertex(T.label, "l3-network",T.id, "11", "aai-node-type", "l3-network","network-id", "networkId4");
+ Vertex l3Network5 = graph.addVertex(T.label, "l3-network",T.id, "12", "aai-node-type", "l3-network","network-id", "networkId5");
+
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, serviceInstance,l3Network);
+ rules.addEdge(g, serviceInstance,l3Network2);
+
+ rules.addEdge(g, l3Network,vlanTag);
+ rules.addEdge(g, l3Network,vlanTag2);
+
+ rules.addEdge(g, l3Network,l3Network1);
+ rules.addEdge(g, l3Network1,vlanTag1);
+
+ rules.addEdge(g, l3Network2,vlanTag4);
+
+ rules.addEdge(g, l3Network2,l3Network3);
+ rules.addEdge(g, l3Network3,vlanTag3);
+
+ rules.addEdge(g, l3Network4,l3Network5);
+ rules.addEdge(g, serviceInstance,l3Network5);
+
+ expectedResult.add(l3Network);
+ expectedResult.add(l3Network2);
+
+ expectedResult.add(vlanTag);
+ expectedResult.add(vlanTag2);
+
+ expectedResult.add(l3Network1);
+ expectedResult.add(vlanTag1);
+
+ expectedResult.add(vlanTag4);
+
+ expectedResult.add(l3Network3);
+ expectedResult.add(vlanTag3);
+
+ expectedResult.add(l3Network4);
+ expectedResult.add(l3Network5);
+
+ //expectedResult.add(vlanTag1);//false
+ //expectedResult.add(l3Network1);//false
+ //expectedResult.add(linterface1);//false
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getNetworksByServiceInstance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "serviceinstanceid");
+ }
+
+ @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/GetRouterRoadmTailSummaryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java
index dc6d148..ee1a08a 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java
@@ -76,7 +76,7 @@ public class GetRouterRoadmTailSummaryTest extends QueryTest{
expectedResult.add(pnf1);
expectedResult.add(pInterface1);
- expectedResult.add(logicalLink1);
+ //expectedResult.add(logicalLink1);
expectedResult.add(pInterface2);
expectedResult.add(pInterface3);
expectedResult.add(pnf2);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedHashMapQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedHashMapQueryTest.java
new file mode 100644
index 0000000..6488cae
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedHashMapQueryTest.java
@@ -0,0 +1,39 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 org.onap.aai.exceptions.AAIException;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+
+public abstract class LinkedHashMapQueryTest extends QueryTest {
+
+ protected List<LinkedHashMap> hashMapList;
+
+ public LinkedHashMapQueryTest() throws AAIException {
+ super();
+ }
+
+ @Override
+ public void run() {
+ hashMapList = (List<LinkedHashMap>) shell.executeTraversal(query, params).toList();
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinterfacesCPFromVnfcTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinterfacesCPFromVnfcTest.java
new file mode 100644
index 0000000..e911634
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinterfacesCPFromVnfcTest.java
@@ -0,0 +1,101 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 LinterfacesCPFromVnfcTest extends QueryTest {
+
+ public LinterfacesCPFromVnfcTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex vnfc = graph.addVertex(T.label, "vnfc",T.id, "0", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function","model-invariant-id","modelinvariantid","model-customization-id","modelcustomizationid");
+ Vertex cp = graph.addVertex(T.label, "cp",T.id, "1", "aai-node-type", "cp","cp-id", "cpId");
+ Vertex vlanTag = graph.addVertex(T.label, "vlan-tag",T.id, "2", "aai-node-type", "vlan-tag","vlan-tag-id", "vlanTagId");
+ Vertex l3Network = graph.addVertex(T.label, "l3-network",T.id, "3", "aai-node-type", "l3-network","network-id", "networkId","is-provider-network",true);
+ Vertex vserv = graph.addVertex(T.label, "vserver",T.id, "4", "aai-node-type", "vserver",
+ "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0","network-name","networkName0");
+
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc",T.id, "6", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function","model-invariant-id","modelinvariantid1","model-customization-id","modelcustomizationid1");
+ Vertex cp1 = graph.addVertex(T.label, "cp",T.id, "7", "aai-node-type", "cp","cp-id", "cpId");
+ Vertex vlanTag1 = graph.addVertex(T.label, "vlan-tag",T.id, "8", "aai-node-type", "vlan-tag","vlan-tag-id", "vlanTagId");
+ Vertex l3Network1 = graph.addVertex(T.label, "l3-network",T.id, "9", "aai-node-type", "l3-network","network-id", "networkId","is-provider-network",false);
+ Vertex vserv1 = graph.addVertex(T.label, "vserver",T.id, "10", "aai-node-type", "vserver",
+ "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0","network-name","networkName0");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, vnfc,cp);
+ rules.addEdge(g, cp,vlanTag);
+ rules.addEdge(g, cp,l3Network);
+ rules.addEdge(g, vnfc,vserv);
+ rules.addTreeEdge(g, vserv, linterface);
+
+ rules.addTreeEdge(g, vnfc1,cp1);
+ rules.addEdge(g, cp1,vlanTag1);
+ rules.addEdge(g, cp1,l3Network1);
+ rules.addEdge(g, vnfc1,vserv1);
+ rules.addTreeEdge(g, vserv1, linterface1);
+
+ expectedResult.add(vlanTag);
+ expectedResult.add(l3Network);
+ expectedResult.add(linterface);
+ //expectedResult.add(vlanTag1);//false
+ //expectedResult.add(l3Network1);//false
+ //expectedResult.add(linterface1);//false
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "l-interface-to-CP";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vnfc").has("model-invariant-id", "modelinvariantid").has("model-customization-id", "modelcustomizationid");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("isProviderNetwork", true);
+ }
+
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java
new file mode 100644
index 0000000..838489f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java
@@ -0,0 +1,212 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 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.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.aai.config.IntrospectionConfig;
+import org.onap.aai.config.SearchConfiguration;
+import org.onap.aai.config.SpringContextAware;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.nodes.NodeIngestor;
+import org.onap.aai.setup.AAIConfigTranslator;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import org.onap.aai.query.builder.GremlinTraversal;
+import org.onap.aai.restcore.search.GremlinGroovyShell;
+import org.onap.aai.restcore.search.GroovyQueryBuilder;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+@RunWith(Parameterized.class)
+@ContextConfiguration(classes = {
+ SchemaLocationsBean.class,
+ SchemaVersions.class,
+ AAIConfigTranslator.class,
+ EdgeIngestor.class,
+ EdgeSerializer.class,
+ NodeIngestor.class,
+ SpringContextAware.class,
+ SearchConfiguration.class,
+ IntrospectionConfig.class
+})
+@TestPropertySource(properties = {
+ "schema.uri.base.path = /aai",
+ "schema.ingest.file = src/test/resources/application-onap-test.properties"
+})
+public abstract class OnapQueryTest {
+
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule springMethodRule = new SpringMethodRule();
+
+ protected EELFLogger logger;
+ protected Graph graph;
+ protected GremlinGroovyShell shell;
+ @Mock protected TransactionalGraphEngine dbEngine;
+ protected final List<Vertex> expectedResult = new ArrayList<>();
+
+ @Autowired
+ protected EdgeIngestor edgeRules;
+
+ @Autowired
+ protected EdgeSerializer rules;
+
+ @Autowired
+ protected LoaderFactory loaderFactory;
+
+ @Autowired
+ protected SchemaVersions schemaVersions;
+
+ @Autowired
+ protected GremlinServerSingleton gremlinServerSingleton;
+
+ protected Loader loader;
+ protected GraphTraversalSource gts;
+
+ @Parameterized.Parameter(value = 0)
+ public SchemaVersion version;
+
+ @Parameterized.Parameters(name = "Version.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {new SchemaVersion("v11")},
+ {new SchemaVersion("v12")},
+ {new SchemaVersion("v13")},
+ {new SchemaVersion("v14")}
+ });
+ }
+
+ protected String query;
+
+ LinkedHashMap <String, Object> params;
+
+ @BeforeClass
+ public static void setupBundleconfig() {
+ System.setProperty("AJSC_HOME", "./");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
+ }
+
+ @Before
+ public void setUp() throws AAIException, NoEdgeRuleFoundException, EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
+ logger = EELFManager.getInstance().getLogger(getClass());
+ MockitoAnnotations.initMocks(this);
+ graph = TinkerGraph.open();
+ gts = graph.traversal();
+ createGraph();
+ shell = new GremlinGroovyShell();
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, version);
+ setUpQuery();
+ }
+
+
+ protected void setUpQuery() {
+ query = gremlinServerSingleton.getStoredQueryFromConfig(getQueryName());
+ params = new LinkedHashMap <>();
+ addParam(params);
+ when(dbEngine.getQueryBuilder(any(QueryStyle.class))).thenReturn(new GremlinTraversal<>(loader, graph.traversal()));
+ logger.info("Stored query in abstraction form {}", query);
+ query = new GroovyQueryBuilder().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);
+ }
+
+ public void run() {
+
+ 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);
+
+ }
+
+ protected 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, EdgeRuleNotFoundException, AmbiguousRuleChoiceException;
+
+ protected abstract String getQueryName();
+
+ protected abstract void addStartNode(GraphTraversal<Vertex, Vertex> g);
+
+ protected abstract void addParam(Map<String, Object> params);
+
+}
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 29cd505..0bc4dbe 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
@@ -35,6 +35,7 @@ import org.junit.runners.Parameterized;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.onap.aai.config.IntrospectionConfig;
+import org.onap.aai.config.SearchConfiguration;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
@@ -54,8 +55,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
import org.onap.aai.query.builder.GremlinTraversal;
-import org.onap.aai.restcore.search.GremlinGroovyShellSingleton;
-import org.onap.aai.restcore.search.GroovyQueryBuilderSingleton;
+import org.onap.aai.restcore.search.GremlinGroovyShell;
+import org.onap.aai.restcore.search.GroovyQueryBuilder;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
import org.onap.aai.serialization.engines.QueryStyle;
@@ -77,7 +78,7 @@ import static org.mockito.Mockito.when;
EdgeSerializer.class,
NodeIngestor.class,
SpringContextAware.class,
- GremlinServerSingleton.class,
+ SearchConfiguration.class,
IntrospectionConfig.class
})
@TestPropertySource(properties = {
@@ -94,7 +95,7 @@ public abstract class QueryTest {
protected EELFLogger logger;
protected Graph graph;
- protected GremlinGroovyShellSingleton shell;
+ protected GremlinGroovyShell shell;
@Mock protected TransactionalGraphEngine dbEngine;
protected final List<Vertex> expectedResult = new ArrayList<>();
@@ -148,7 +149,7 @@ public abstract class QueryTest {
graph = TinkerGraph.open();
gts = graph.traversal();
createGraph();
- shell = GremlinGroovyShellSingleton.getInstance();
+ shell = new GremlinGroovyShell();
loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, version);
setUpQuery();
}
@@ -160,7 +161,7 @@ public abstract class QueryTest {
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);
+ query = new GroovyQueryBuilder().executeTraversal(dbEngine, query, params);
logger.info("After converting to gremlin query {}", query);
query = "g" + query;
GraphTraversal<Vertex, Vertex> g = graph.traversal().V();
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java
index 85f4e3b..f2c6369 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java
@@ -24,6 +24,7 @@ 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.query.builder.MissingOptionalParameter;
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
import java.util.Map;
@@ -81,7 +82,7 @@ public class RelatedToBothCousinAndTreeCustomQueryTest extends QueryTest{
protected void addParam(Map<String, Object> params) {
params.put("startingNodeType", "lag-interface");
params.put("relatedToNodeType", "l-interface");
-
+ params.put("edgeType", MissingOptionalParameter.getInstance());
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java
index b8a8156..5147268 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java
@@ -71,7 +71,7 @@ public class RelatedToCustomQueryTest extends QueryTest{
protected void addParam(Map<String, Object> params) {
params.put("startingNodeType", "generic-vnf");
params.put("relatedToNodeType", "vserver");
-
+ params.put("edgeType", "COUSIN");
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java
index 8998b90..2f31206 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java
@@ -72,6 +72,7 @@ public class RelatedToTreeCustomQueryTest extends QueryTest {
protected void addParam(Map<String, Object> params) {
params.put("startingNodeType", "generic-vnf");
params.put("relatedToNodeType", "entitlement");
+ params.put("edgeType", "TREE");
}
}
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
index 731642c..88af274 100644
--- 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
@@ -55,6 +55,11 @@ public class TopologySummaryQueryTest extends QueryTest {
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");
+ Vertex lineofbusiness = graph.addVertex(T.label, "line-of-business", T.id, "12", "aai-node-type", "line-of-business");
+ Vertex platform = graph.addVertex(T.label, "platform", T.id, "13", "aai-node-type", "platform");
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "14", "aai-node-type", "service-instance");
+ Vertex owningentity = graph.addVertex(T.label, "owning-entity", T.id, "15", "aai-node-type", "owning-entity");
+ Vertex project = graph.addVertex(T.label, "project", T.id, "16", "aai-node-type", "project");
GraphTraversalSource g = graph.traversal();
rules.addEdge(g, vnf, vnfc);
@@ -70,6 +75,11 @@ public class TopologySummaryQueryTest extends QueryTest {
rules.addTreeEdge(g, pserver, pserverint);
rules.addTreeEdge(g, vnf, vnfint);
rules.addTreeEdge(g, vserver, vserverint);
+ rules.addEdge(g, vnf, lineofbusiness);
+ rules.addEdge(g, vnf, platform);
+ rules.addEdge(g, vnf, serviceinstance);
+ rules.addEdge(g, serviceinstance, owningentity);
+ rules.addEdge(g, serviceinstance, project);
expectedResult.add(vnf);
expectedResult.add(vnfc);
@@ -80,6 +90,10 @@ public class TopologySummaryQueryTest extends QueryTest {
expectedResult.add(flavor);
expectedResult.add(pserver);
expectedResult.add(complex);
+ expectedResult.add(lineofbusiness);
+ expectedResult.add(platform);
+ expectedResult.add(owningentity);
+ expectedResult.add(project);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfSummaryFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfSummaryFromVnfTest.java
new file mode 100644
index 0000000..c5dcf57
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfSummaryFromVnfTest.java
@@ -0,0 +1,111 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 VnfSummaryFromVnfTest extends QueryTest {
+ public VnfSummaryFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfId1", "vnf-name", "vnf-name-1", "vnf-type", "vnfType1");
+ Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnfId2", "vnf-name", "vnf-name-2", "vnf-type", "vnfType2");
+ Vertex platform = graph.addVertex(T.label, "platform", T.id, "3", "aai-node-type", "platform", "platform-name", "platform-name-1");
+ Vertex platform2 = graph.addVertex(T.label, "platform", T.id, "4", "aai-node-type", "platform", "platform-name", "platform-name-2");
+ Vertex lineofbus = graph.addVertex(T.label, "line-of-business", T.id, "5", "aai-node-type", "line-of-business", "line-of-business-name", "line-of-business-name-1");
+ Vertex lineofbus2 = graph.addVertex(T.label, "line-of-business", T.id, "6", "aai-node-type", "line-of-business", "line-of-business-name", "line-of-business-name-2");
+ Vertex serviceinst = graph.addVertex(T.label, "service-instance", T.id, "7", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1");
+ Vertex serviceinst2 = graph.addVertex(T.label, "service-instance", T.id, "8", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2");
+ Vertex owningent = graph.addVertex(T.label, "owning-entity", T.id, "9", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-1");
+ Vertex owningent2 = graph.addVertex(T.label, "owning-entity", T.id, "10", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-2");
+ Vertex project = graph.addVertex(T.label, "project", T.id, "11", "aai-node-type", "project", "project-name", "project-name-1");
+ Vertex project2 = graph.addVertex(T.label, "project", T.id, "12", "aai-node-type", "project", "project-name", "project-name-2");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "13", "aai-node-type", "pserver", "hostname", "hostname-1");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "hostname-2");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "15", "aai-node-type", "pserver", "hostname", "hostname-2");
+ Vertex pserver4 = graph.addVertex(T.label, "pserver", T.id, "16", "aai-node-type", "pserver", "hostname", "hostname-2");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "17", "aai-node-type", "vserver", "vserver-id", "vserver-id-1");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "18", "aai-node-type", "vserver", "vserver-id", "vserver-id-2");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, genericvnf1, platform);
+ rules.addEdge(g, genericvnf1, lineofbus);
+ rules.addEdge(g, genericvnf1, serviceinst);
+ rules.addEdge(g, serviceinst, owningent);
+ rules.addEdge(g, serviceinst, project);
+ rules.addEdge(g, genericvnf1, pserver);
+ rules.addEdge(g, genericvnf1, vserver);
+ rules.addEdge(g, vserver, pserver2);
+
+ rules.addEdge(g, genericvnf2, platform2);//false
+ rules.addEdge(g, genericvnf2, lineofbus2);//false
+ rules.addEdge(g, genericvnf2, serviceinst2);//false
+ rules.addEdge(g, serviceinst2, owningent2);//false
+ rules.addEdge(g, serviceinst2, project2);//false
+ rules.addEdge(g, genericvnf2, pserver3);//false
+ rules.addEdge(g, genericvnf2, vserver2);//false
+ rules.addEdge(g, vserver2, pserver4);//false
+
+ expectedResult.add(genericvnf1);
+ expectedResult.add(platform);
+ expectedResult.add(lineofbus);
+ expectedResult.add(serviceinst);
+ expectedResult.add(owningent);
+ expectedResult.add(project);
+ expectedResult.add(pserver);
+ expectedResult.add(vserver);
+ expectedResult.add(pserver2);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vnf-summary-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;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfToEsrSystemInfoQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfToEsrSystemInfoQueryTest.java
new file mode 100644
index 0000000..0e82c0b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfToEsrSystemInfoQueryTest.java
@@ -0,0 +1,96 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 VnfToEsrSystemInfoQueryTest extends OnapQueryTest {
+ public VnfToEsrSystemInfoQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ Vertex gnvf = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserver-id-1","vserver-name","vserver-name-1");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "4", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1");
+ Vertex esr = graph.addVertex(T.label, "esr-system-info", T.id, "6", "aai-node-type", "esr-system-info", "esr-system-info-id", "esr-system-info-1");
+
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "8", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "9", "aai-node-type", "vserver", "vserver-id", "vserver-id-2","vserver-name","vserver-name-2");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "10", "aai-node-type", "tenant", "tenant-id", "tenantid02", "tenant-name", "tenantName02");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "11", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-2");
+ Vertex esr1 = graph.addVertex(T.label, "esr-system-info", T.id, "12", "aai-node-type", "esr-system-info", "esr-system-info-id", "esr-system-info-2");
+
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gnvf, vserver);
+ rules.addTreeEdge(g, vserver,tenant);
+ rules.addTreeEdge(g, tenant,cloudregion);
+ rules.addTreeEdge(g, cloudregion, esr);
+
+ //Not expected in result
+ rules.addEdge(g, gnvf1, vserver1);
+ rules.addTreeEdge(g, vserver1,tenant1);
+ rules.addTreeEdge(g, tenant1,cloudregion1);
+ rules.addTreeEdge(g, cloudregion1, esr1);
+ //Not expected in result
+
+ expectedResult.add(gnvf);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(cloudregion);
+ expectedResult.add(esr);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vnf-to-esr-system-info";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "vnf-id-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java
new file mode 100644
index 0000000..04a7d21
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java
@@ -0,0 +1,141 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 VnfTopologyFromServiceInstanceTest extends QueryTest {
+ public VnfTopologyFromServiceInstanceTest() 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 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-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
+ Vertex allottedresource = graph.addVertex(T.label, "allotted-resource", T.id, "4", "aai-node-type", "allotted-resource", "allotted-resource-id", "allotted-resource-id-1", "allotted-resource-name", "allotted-resource-name1");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "5", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+ Vertex volumegroup = graph.addVertex(T.label, "volume-group", T.id, "6", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-1", "volume-group-name", "volume-group-name1");
+ Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "7", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list-id", "l3-interface-ipv4-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-1", "l3-network-name", "l3-network-name1");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name1", "vservername1");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "12", "aai-node-type", "tenant", "tenant-name1", "tenant-name-1","tenant-id", "tenant-id-1");
+ Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "13", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
+ Vertex l3inter2ipv4addresslist = graph.addVertex(T.label, "interface-ipv6-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "17", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-2", "l3-network-name", "l3-network-name2");
+ Vertex l3inter2ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "18", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "19", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-3", "l3-network-name", "l3-network-name3");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "20", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-4", "l3-network-name", "l3-network-name4");
+ Vertex l3network5 = graph.addVertex(T.label, "l3-network", T.id, "23", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-5", "l3-network-name", "l3-network-name5");
+ Vertex l3network6 = graph.addVertex(T.label, "l3-network", T.id, "24", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-6", "l3-network-name", "l3-network-name6");
+ Vertex configuration = graph.addVertex(T.label, "configuration", T.id, "21", "aai-node-type", "configuration", "configuration-id", "configuration-id-1", "configuration-type", "configuration-type-1");
+ Vertex vlantag = graph.addVertex(T.label, "vlan-tag", T.id, "22", "aai-node-type", "vlan-tag", "vlan-tag-id", "vlan-tag-id-1");
+ Vertex vlantag2 = graph.addVertex(T.label, "vlan-tag", T.id, "25", "aai-node-type", "vlan-tag", "vlan-tag-id", "vlan-tag-id-2");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gnvf1, serviceinstance);//false
+ rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
+ rules.addTreeEdge(g, servicesubscription, customer);//true
+ rules.addTreeEdge(g, serviceinstance, allottedresource);//true
+ rules.addEdge(g, serviceinstance, configuration);//true
+ rules.addTreeEdge(g, gnvf1, vfmodule);//true
+ rules.addEdge(g, gnvf1, volumegroup);//false
+ rules.addEdge(g, gnvf1, l3network5);//true
+ rules.addEdge(g, l3network5, vlantag);//true
+ rules.addEdge(g, l3network5, l3network6);//true
+ rules.addEdge(g, l3network6, vlantag2);//true
+ rules.addTreeEdge(g, gnvf1, linter1);//true
+ rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);//true
+ rules.addEdge(g, l3inter1ipv4addresslist, l3network1);//false
+ rules.addTreeEdge(g, linter1, l3inter1ipv6addresslist);//true
+ rules.addEdge(g, l3inter1ipv6addresslist, l3network2);//false
+ rules.addEdge(g, gnvf1, vserver);//false
+ rules.addTreeEdge(g, vserver, tenant);//true
+ rules.addTreeEdge(g, tenant, region1);//true
+ rules.addEdge(g, vserver, pserver);//false
+ rules.addTreeEdge(g, vserver, linter2);//false
+ rules.addTreeEdge(g, linter2, l3inter2ipv4addresslist);//false
+ rules.addEdge(g, l3inter2ipv4addresslist, l3network3);//false
+ rules.addTreeEdge(g, linter2, l3inter2ipv6addresslist);//true
+ rules.addEdge(g, l3inter2ipv6addresslist, l3network4);//true
+
+
+ expectedResult.add(gnvf1);
+ expectedResult.add(serviceinstance);
+ expectedResult.add(customer);
+ expectedResult.add(allottedresource);
+ expectedResult.add(configuration);
+ expectedResult.add(vfmodule);
+ expectedResult.add(volumegroup);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3network1);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(l3network2);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(region1);
+ expectedResult.add(pserver);
+ expectedResult.add(l3inter2ipv4addresslist);
+ expectedResult.add(l3network3);
+ expectedResult.add(l3inter2ipv6addresslist);
+ expectedResult.add(l3network4);
+ expectedResult.add(l3network5);
+ expectedResult.add(vlantag);
+ expectedResult.add(l3network6);
+ expectedResult.add(vlantag2);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vnf-topology-fromServiceInstance";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("service-instance-name", "service-instance-name-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfVserverFromCustomerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfVserverFromCustomerTest.java
new file mode 100644
index 0000000..5d70867
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfVserverFromCustomerTest.java
@@ -0,0 +1,85 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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 VnfVserverFromCustomerTest extends QueryTest {
+ public VnfVserverFromCustomerTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "0", "aai-node-type", "customer", "global-customer-id", "customer1","subscriber-type","INFRA");
+ Vertex service1 = graph.addVertex(T.label, "service-subscription", T.id, "1", "aai-node-type", "service-subscription", "service-type", "service1");
+ Vertex instance = graph.addVertex(T.label, "service-instance", T.id, "2", "aai-node-type", "service-instance");
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "4", "aai-node-type", "vserver");
+
+ Vertex customer2 = graph.addVertex(T.label, "customer", T.id, "5", "aai-node-type", "customer", "global-customer-id", "customer2","subscriber-type","INFRA2");
+ Vertex service2 = graph.addVertex(T.label, "service-subscription", T.id, "6", "aai-node-type", "service-subscription", "service-type", "service2");
+ Vertex instance2 = graph.addVertex(T.label, "service-instance", T.id, "7", "aai-node-type", "service-instance");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "8", "aai-node-type", "generic-vnf");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "9", "aai-node-type", "vserver");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, customer1, service1);
+ rules.addTreeEdge(g, service1, instance);
+ rules.addEdge(g, vnf, instance);
+ rules.addEdge(g, vnf, vserver);
+
+ rules.addTreeEdge(g, customer2, service2); //false
+ rules.addTreeEdge(g, service2, instance2); //false
+ rules.addEdge(g, vnf2, instance2); //false
+ rules.addEdge(g, vnf2, vserver2);//false
+
+ expectedResult.add(vnf);
+ expectedResult.add(vserver);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "vnf-vserver-fromCustomer";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "customer").has("subscriber-type", "INFRA");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}