aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test/java
diff options
context:
space:
mode:
authorJames Forsyth <jf2512@att.com>2019-04-11 16:22:48 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-11 16:22:48 +0000
commitdeffc993786bdbafe9e6d5fe63cdce5b58cafe1a (patch)
tree568c41a72696693d815064be8e301824c6c83585 /aai-traversal/src/test/java
parent4d7847bbd41b88c65279b25cbec284d8f0a6ef3e (diff)
parent5b3ccace8082f9ae76a69d8fc96def195c2c3da7 (diff)
Merge "add v16 to traversal repo"
Diffstat (limited to 'aai-traversal/src/test/java')
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java41
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java225
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java95
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetVNFVpnBondingServiceDetailsTest.java112
11 files changed, 434 insertions, 53 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
index 0a9ec97..7f5b1d8 100644
--- a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
@@ -138,7 +138,7 @@ public class AAIGremlinQueryTest {
String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
headers.add("Authorization", "Basic " + authorization);
- baseUrl = "https://localhost:" + randomPort;
+ baseUrl = "http://localhost:" + randomPort;
}
@Test
diff --git a/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java b/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java
index 3956b70..76a1277 100644
--- a/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java
@@ -163,7 +163,7 @@ public class QueryParameterTest {
String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
headers.add("Authorization", "Basic " + authorization);
- baseUrl = "https://localhost:" + randomPort;
+ baseUrl = "http://localhost:" + randomPort;
}
@Test
diff --git a/aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java b/aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java
index efb9e89..bc43979 100644
--- a/aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java
@@ -106,7 +106,7 @@ public class SubgraphPruneTest {
String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
headers.add("Authorization", "Basic " + authorization);
- baseUrl = "https://localhost:" + randomPort;
+ baseUrl = "http://localhost:" + randomPort;
}
@Test
diff --git a/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java b/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java
index 46e6be7..552feb6 100644
--- a/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java
+++ b/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java
@@ -58,30 +58,35 @@ public class TraversalTestConfiguration {
@Bean
RestTemplate restTemplate(RestTemplateBuilder builder) throws Exception {
- char[] trustStorePassword = env.getProperty("server.ssl.trust-store-password").toCharArray();
- char[] keyStorePassword = env.getProperty("server.ssl.key-store-password").toCharArray();
+ RestTemplate restTemplate = null;
- String keyStore = env.getProperty("server.ssl.key-store");
- String trustStore = env.getProperty("server.ssl.trust-store");
+ if(env.acceptsProfiles("one-way-ssl", "two-way-ssl")) {
+ char[] trustStorePassword = env.getProperty("server.ssl.trust-store-password").toCharArray();
+ char[] keyStorePassword = env.getProperty("server.ssl.key-store-password").toCharArray();
- SSLContextBuilder sslContextBuilder = SSLContextBuilder.create();
+ String keyStore = env.getProperty("server.ssl.key-store");
+ String trustStore = env.getProperty("server.ssl.trust-store");
+ SSLContextBuilder sslContextBuilder = SSLContextBuilder.create();
- if(env.acceptsProfiles("two-way-ssl")){
- sslContextBuilder = sslContextBuilder.loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword);
- }
+ if (env.acceptsProfiles("two-way-ssl")) {
+ sslContextBuilder = sslContextBuilder.loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword);
+ }
- SSLContext sslContext = sslContextBuilder
- .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword)
- .build();
+ SSLContext sslContext = sslContextBuilder
+ .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword)
+ .build();
- HttpClient client = HttpClients.custom()
- .setSSLContext(sslContext)
- .setSSLHostnameVerifier((s, sslSession) -> true)
- .build();
+ HttpClient client = HttpClients.custom()
+ .setSSLContext(sslContext)
+ .setSSLHostnameVerifier((s, sslSession) -> true)
+ .build();
- RestTemplate restTemplate = builder
- .requestFactory(new HttpComponentsClientHttpRequestFactory(client))
- .build();
+ restTemplate = builder
+ .requestFactory(new HttpComponentsClientHttpRequestFactory(client))
+ .build();
+ }else {
+ restTemplate = builder.build();
+ }
restTemplate.setErrorHandler(new ResponseErrorHandler() {
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
index 7235fa3..b767dbb 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
@@ -99,7 +99,7 @@ public abstract class AbstractSpringRestTest {
String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
headers.add("Authorization", "Basic " + authorization);
httpEntity = new HttpEntity(headers);
- baseUrl = "https://localhost:" + randomPort;
+ baseUrl = "http://localhost:" + randomPort;
}
/*
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java
index a566499..5edf12d 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java
@@ -84,7 +84,7 @@ public class BadQueryFormatTest {
String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
headers.add("Authorization", "Basic " + authorization);
- baseUrl = "https://localhost:" + randomPort;
+ baseUrl = "http://localhost:" + randomPort;
}
@Test
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 347e21b..e4576ae 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
@@ -107,7 +107,7 @@ public class DslConsumerTest extends AbstractSpringRestTest {
httpEntity = new HttpEntity(payload, headers);
responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- assertEquals("Expected the response to be 400", HttpStatus.INTERNAL_SERVER_ERROR,
+ assertEquals("Expected the response to be 404", HttpStatus.NOT_FOUND,
responseEntity.getStatusCode());
}
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
index 80efe37..b894985 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java
@@ -96,7 +96,7 @@ public class QueryConsumerTest {
headers.add("X-TransactionId", "JUNIT");
String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
headers.add("Authorization", "Basic " + authorization);
- baseUrl = "https://localhost:" + randomPort;
+ baseUrl = "http://localhost:" + randomPort;
httpTestUtil = new HttpTestUtil();
addPserver();
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 e6665fd..340f8f8 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
@@ -19,20 +19,77 @@
*/
package org.onap.aai.rest.dsl;
-import static org.junit.Assert.assertEquals;
-
-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.exceptions.AAIException;
+import static org.junit.Assert.assertEquals;
+
/**
* The Class DslMain.
*/
public class DslQueryProcessorTest extends AAISetup {
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
+ @Test
+ public void singleNode1() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void singleNodeLimit() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid') LIMIT 10";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".store('x').cap('x').unfold().dedup().limit(10)";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void specialCharacterTest() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coidhello:?_-)(!@#$%^&*+={}[]|/.<,') LIMIT 10";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coidhello:?_-)(!@#$%^&*+={}[]|/.<,')"
+ + ".store('x').cap('x').unfold().dedup().limit(10)";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void singleNodeLimitBlah() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid') LIMIT blah";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".getVerticesByProperty('cloud-region-id','cr id').store('x').cap('x').unfold().dedup().limit(10)";
+
+ expectedEx.expect(org.onap.aai.exceptions.AAIException.class);
+ expectedEx.expectMessage("DSL Syntax Error while processing the query");
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ }
+
+ @Test
+ public void singleNodeLimitNull() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid') LIMIT ";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".getVerticesByProperty('cloud-region-id','cr id').store('x').cap('x').unfold().dedup().limit(10)";
+
+ expectedEx.expect(org.onap.aai.exceptions.AAIException.class);
+ expectedEx.expectMessage("DSL Syntax Error while processing the query");
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ }
@Test
public void cloudRegion1Test() throws AAIException {
@@ -48,10 +105,14 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void cloudRegion_entitlementTest() throws AAIException {
- String aaiQuery = "generic-vnf('vnf-id','vnfId') (> vserver > tenant > cloud-region*('cloud-region-id','One')) > entitlement*";
+ /*
+ A store within a where makes no sense
+ */
+ 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'))"
+ + ".getVerticesByProperty('cloud-region-id','One'))"
+ ".createEdgeTraversal(EdgeType.TREE, 'generic-vnf','entitlement').store('x').cap('x').unfold().dedup()";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
@@ -59,9 +120,23 @@ public class DslQueryProcessorTest extends AAISetup {
}
@Test
+ public void cloudRegion_entitlementTestWithLabels() throws AAIException {
+
+ String aaiQuery = "generic-vnf('vnf-id','vnfId') (> ('tosca.relationships.HostedOn') vserver > ('org.onap.relationships.inventory.BelongsTo') tenant > ('org.onap.relationships.inventory.BelongsTo') cloud-region('cloud-region-id','One')) > ('org.onap.relationships.inventory.ComposedOf')service-instance*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where("
+ + "builder.newInstance().createEdgeTraversalWithLabels( 'generic-vnf','vserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).createEdgeTraversalWithLabels( 'vserver','tenant', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo'))).createEdgeTraversalWithLabels( 'tenant','cloud-region', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo')))"
+ + ".getVerticesByProperty('cloud-region-id','One'))"
+ + ".createEdgeTraversalWithLabels( 'generic-vnf','service-instance', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.ComposedOf'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
public void complex_az_fromComplexTest() throws AAIException {
- String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') > [ availability-zone* , complex*]";
+ String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') > [ availability-zone* , complex*]";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
@@ -72,6 +147,19 @@ public class DslQueryProcessorTest extends AAISetup {
}
@Test
+ public void complex_az_fromComplexTestWithLabels() throws AAIException {
+
+ String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') > [ ('org.onap.relationships.inventory.BelongsTo')availability-zone* , ('org.onap.relationships.inventory.LocatedIn')complex*]";
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ + ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
+ + ".union(builder.newInstance().createEdgeTraversalWithLabels( 'cloud-region','availability-zone', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo'))).store('x')"
+ + ",builder.newInstance().createEdgeTraversalWithLabels( 'cloud-region','complex', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.LocatedIn'))).store('x')).cap('x').unfold().dedup()";
+
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
public void cloudRegion_fromComplex1Test() throws AAIException {
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('data-center-code','data-center-code-name')"
@@ -102,8 +190,8 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver','generic-vnf').getVerticesByProperty('vnf-name','ZALL1MMSC03'))"
+ ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ ".store('x').cap('x').unfold().dedup()";
- String aaiQuery = "image('application-vendor','F5') > vserver (>generic-vnf('vnf-name','ZALL1MMSC03')) > tenant > cloud-region*";
+ String aaiQuery = "image('application-vendor','F5') > vserver (> generic-vnf('vnf-name','ZALL1MMSC03')) > tenant > cloud-region*";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
@@ -117,8 +205,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ ").createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ ".store('x').cap('x').unfold().dedup()";
- String aaiQuery = "image('application-vendor','vendor') > vserver( >generic-vnf('nf-type', 'nfType') ) > tenant > cloud-region*";
-
+ String aaiQuery = "image('application-vendor','vendor') > vserver(> generic-vnf('nf-type', 'nfType') ) > tenant > cloud-region*";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
@@ -166,8 +253,8 @@ 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*, "
- + " vserver > pserver* > complex* " + "]";
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') > [ pserver* > complex*, "
+ + " vserver > pserver* > complex* " + "]";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
@@ -175,19 +262,17 @@ public class DslQueryProcessorTest extends AAISetup {
}
@Test
- public void complex_fromVnfTest() throws AAIException {
+ public void complex_fromVnfTest2() throws AAIException {
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','pserver').store('x'),"
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
- + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x'))"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
- + ").cap('x').unfold().dedup()";
-
- String aaiQuery = "generic-vnf*('vnf-id','vnfId') > " + "[ pserver* > complex*, "
- + " vserver > pserver* > complex* " + "]";
+ + ".cap('x').unfold().dedup()";
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') > [ pserver* , "
+ + " vserver > pserver* ] > complex*";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
@@ -208,8 +293,7 @@ public class DslQueryProcessorTest extends AAISetup {
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* ]";
-
+ + " > [ vnfc* , vserver*, pserver* , pnf* ]";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
@@ -222,8 +306,8 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".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*('vnf-id','vnfId') (> [pserver('hostname','hostname1'), "
- + "vserver > pserver('hostname','hostname1')])";
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') (> [ pserver('hostname','hostname1'), "
+ + " vserver > pserver('hostname','hostname1')])";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
@@ -259,7 +343,7 @@ public class DslQueryProcessorTest extends AAISetup {
@Test
public void hasNotPropertyNullValuesTest() throws AAIException {
String aaiQuery = "cloud-region* !('cloud-owner',' ',' null ')";
- String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner', new ArrayList<>(Arrays.asList('','null'))).store('x').cap('x').unfold().dedup()";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner', new ArrayList<>(Arrays.asList(' ',' null '))).store('x').cap('x').unfold().dedup()";
String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(dslQuery, query);
@@ -267,12 +351,38 @@ 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 aaiQuery = "cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'MTN61a') > 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').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag').getVerticesByProperty('vlan-id-inner',20).store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void noEdgeRuleTest() throws AAIException {
+ String aaiQuery = "vserver('vserver-id','abc') > logical-link* > l-interface*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'vserver').getVerticesByProperty('vserver-id','abc').createEdgeTraversal(EdgeType.TREE, 'vserver','logical-link').store('x').createEdgeTraversal('logical-link','l-interface').store('x')cap('x').unfold().dedup()";
+ expectedEx.expect(org.onap.aai.exceptions.AAIException.class);
+ expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: vserver, logical-link");
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void multipleEdgeRuleTest() throws AAIException {
+ String aaiQuery = "vserver('vserver-id','abc') > l-interface* > lag-interface*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'vserver').getVerticesByProperty('vserver-id','abc').createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').store('x').createEdgeTraversal( 'l-interface','lag-interface').store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void multipleEdgeRuleTestWithLabels() throws AAIException {
+ String aaiQuery = "vserver('vserver-id','abc') > l-interface* > ('org.onap.relationships.inventory.BelongsTo') lag-interface*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'vserver').getVerticesByProperty('vserver-id','abc').createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').store('x').createEdgeTraversalWithLabels( 'l-interface','lag-interface', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo'))).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')";
@@ -282,4 +392,63 @@ public class DslQueryProcessorTest extends AAISetup {
assertEquals(dslQuery, query);
}
+ @Test
+ public void overlyNestedQueryTest() throws AAIException {
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') (> [ pserver('hostname','hostname1'), vserver (> [ pserver('hostname','hostname1'), pserver('hostname','hostname1')])]) > vserver";
+
+ String dslQuery = "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').where(builder.newInstance().union(builder.newInstance()" +
+ ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'),builder.newInstance()." +
+ "createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'))))).store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void overlyNestedQueryTestWithLabels() throws AAIException {
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') (> [ ('tosca.relationships.HostedOn')pserver('hostname','hostname1'), ('tosca.relationships.HostedOn')vserver (> [ ('tosca.relationships.HostedOn')pserver('hostname','hostname1'), ('tosca.relationships.HostedOn')pserver('hostname','hostname1')])]) > ('org.onap.relationships.inventory.PartOf')allotted-resource";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where(builder.newInstance().union" +
+ "(builder.newInstance().createEdgeTraversalWithLabels( 'generic-vnf','pserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).getVerticesByProperty('hostname','hostname1')," +
+ "builder.newInstance().createEdgeTraversalWithLabels( 'generic-vnf','vserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).where(builder.newInstance().union(builder.newInstance()" +
+ ".createEdgeTraversalWithLabels( 'vserver','pserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).getVerticesByProperty('hostname','hostname1'),builder.newInstance()." +
+ "createEdgeTraversalWithLabels( 'vserver','pserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).getVerticesByProperty('hostname','hostname1'))))).store('x').createEdgeTraversalWithLabels( 'generic-vnf','allotted-resource', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.PartOf'))).cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void nestedUnionQueryTest() throws AAIException {
+
+ 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'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x'))"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ + ".union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'complex','availability-zone')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'availability-zone','cloud-region').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'complex','ctag-pool').store('x').union("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'ctag-pool','availability-zone').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'availability-zone','complex').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'ctag-pool','generic-vnf').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','availability-zone').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'availability-zone','complex').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'ctag-pool','vpls-pe').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vpls-pe','complex').store('x'))"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x'))"
+ + ".createEdgeTraversal(EdgeType.TREE, 'cloud-region','tenant').store('x')"
+ + ".cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') > [ pserver* , "
+ + " vserver > pserver* ] > complex* > [ availability-zone > cloud-region*, cloud-region*, " +
+ " ctag-pool* > [ availability-zone* > complex* , generic-vnf* > availability-zone* > complex*, vpls-pe* > complex*] > cloud-region*] > tenant* " ;
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java
new file mode 100644
index 0000000..822643e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java
@@ -0,0 +1,95 @@
+/**
+ * ============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.dsl;
+
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.exceptions.AAIException;
+
+import static org.junit.Assert.assertEquals;
+
+//TODO: Change this to read queries and their builder equivalent from a file
+//TODO: Add queries run by SEs
+
+public class ProdDslTest extends AAISetup {
+ @Test
+ public void msoQueryTest1() throws AAIException {
+ String aaiQuery = "cloud-region('cloud-owner', 'value')('cloud-region-id', 'value') > vlan-tag*('vlan-id-outer', 'value')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','value')"
+ + ".getVerticesByProperty('cloud-region-id','value').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag')"
+ + ".getVerticesByProperty('vlan-id-outer','value').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void msoQueryTest2() throws AAIException {
+ String aaiQuery = "pserver('hostname', 'pserver-1') > p-interface > sriov-pf*('pf-pci-id', '0000:ee:00.0')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('hostname','pserver-1')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'pserver','p-interface')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'p-interface','sriov-pf').getVerticesByProperty('pf-pci-id','0000:ee:00.0').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void msoQueryTest3() throws AAIException {
+ String aaiQuery = "l-interface ('interface-id', 'value') > sriov-vf > sriov-pf*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'l-interface').getVerticesByProperty('interface-id','value')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'l-interface','sriov-vf')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'sriov-vf','sriov-pf').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ //TODO : Get this from schema
+ @Test
+ public void msoQueryTest4() throws AAIException {
+ //String aaiQuery = "l-interface ('interface-id', 'value') > lag-interface('interface-name', 'bond1') > sriov-pf*";
+ String aaiQuery = "l-interface ('interface-id', 'value') > lag-interface('interface-name', 'bond1') > p-interface > sriov-pf*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'l-interface').getVerticesByProperty('interface-id','value')"
+ + ".createEdgeTraversal( 'l-interface','lag-interface').getVerticesByProperty('interface-name','bond1')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'lag-interface','p-interface').createEdgeTraversal(EdgeType.TREE, 'p-interface','sriov-pf').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ //TODO : Get this from schema
+ @Test
+ public void msoQueryTest5() throws AAIException {
+ //String aaiQuery = "pserver ('hostname', 'value') > vserver ('vserver-name', 'value') > l-interface > vlan-tag*";
+ String aaiQuery = "pserver ('hostname', 'value') > vserver ('vserver-name', 'value') > l-interface > cp > vlan-tag*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('hostname','value')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','vserver').getVerticesByProperty('vserver-name','value')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').createEdgeTraversal(EdgeType.COUSIN, 'l-interface','cp').createEdgeTraversal(EdgeType.COUSIN, 'cp','vlan-tag').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVNFVpnBondingServiceDetailsTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVNFVpnBondingServiceDetailsTest.java
new file mode 100644
index 0000000..b859b84
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVNFVpnBondingServiceDetailsTest.java
@@ -0,0 +1,112 @@
+/**
+ * ============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.Ignore;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetVNFVpnBondingServiceDetailsTest extends QueryTest {
+
+ public GetVNFVpnBondingServiceDetailsTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ // Test ignored for time being as query files pulled from aai-queries in schema-service differ
+ // from the stored-queries.json file that used to reside in traversal.
+ @Ignore
+ @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 vserver = graph.addVertex(T.label, "vserver", T.id, "1", "aai-node-type", "vserver", "vserver-name1", "vservername1");
+ Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
+ Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "3", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
+ Vertex vlan1 = graph.addVertex(T.label, "vlan", T.id, "4", "aai-node-type", "vlan","vlan-interface", "vlan11");
+ Vertex config1 = graph.addVertex(T.label, "configuration", T.id, "5", "aai-node-type", "configuration", "configuration-id", "configuration1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-1", "l3-network-name", "l3-network-name1");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "7", "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 l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex configVpnBinding = graph.addVertex(T.label, "vpn-binding", T.id, "9", "aai-node-type", "vpn-binding",
+ "vpn-id", "test-binding-config", "vpn-name", "test");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "10", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
+ Vertex subnet1 = graph.addVertex(T.label, "subnet", T.id, "11", "aai-node-type", "subnet", "subnet-id", "subnet-id-11");
+ Vertex routeTarget1 = graph.addVertex(T.label, "route-target", T.id, "12", "aai-node-type", "route-target", "global-route-target", "111");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gnvf1, vserver);//false
+ rules.addEdge(g, gnvf1, config1);//false
+ rules.addTreeEdge(g, vserver, linter1);//true
+ rules.addTreeEdge(g, linter1, linter2);//true
+ rules.addTreeEdge(g, linter2, vlan1);//true
+ rules.addEdge(g, config1, l3network1 );//false
+ rules.addTreeEdge(g, l3network1, subnet1);//true
+ rules.addEdge(g, subnet1, l3inter1ipv4addresslist );//false
+ rules.addEdge(g, subnet1, l3inter1ipv6addresslist );//false
+ rules.addEdge(g, l3network1, configVpnBinding );//false
+ rules.addEdge(g, configVpnBinding, customer );//false
+ rules.addTreeEdge(g, configVpnBinding, routeTarget1);//true
+
+
+ expectedResult.add(vserver);
+ expectedResult.add(config1);
+ expectedResult.add(linter1);
+ expectedResult.add(linter2);
+ expectedResult.add(vlan1);
+ expectedResult.add(l3network1);
+ expectedResult.add(subnet1);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(configVpnBinding);
+ expectedResult.add(customer);
+ expectedResult.add(routeTarget1);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getVNFVpnBondingServiceDetails";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-name", "vnf-name-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("vnf-name", "vnf-name-1");
+ }
+}