aboutsummaryrefslogtreecommitdiffstats
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
parentc0365f15a25aed95f7e812dc1d7e7ac588ebbed5 (diff)
Update traversal to support v15
Issue-ID: AAI-2073 Change-Id: I1c3df218d1333bdebc984947edc100607958ab60 Signed-off-by: LaMont, William (wl2432) <wl2432@us.att.com>
-rw-r--r--aai-traversal/.classpath37
-rw-r--r--aai-traversal/pom.xml17
-rw-r--r--aai-traversal/src/main/docker/docker-entrypoint.sh8
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/TraversalApp.java66
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/config/DslConfiguration.java6
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java26
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java3
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java42
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java82
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java17
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java38
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java46
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java72
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java21
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/CQConfig.java28
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java9
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java47
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyShellImpl.java4
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/LocalCQConfig.java85
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java6
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/SchemaServiceCQConfig.java64
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/util/TraversalConstants.java2
-rw-r--r--aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g46
-rw-r--r--aai-traversal/src/main/resources/application.properties21
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties18
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/error.properties7
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties2
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties4
-rw-r--r--aai-traversal/src/main/resources/etc/scriptdata/widget-model-json/collection-1.0.json11
-rw-r--r--aai-traversal/src/main/resources/schema/onap/query/stored-queries.json190
-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
-rw-r--r--aai-traversal/src/test/resources/application-onap-test.properties74
-rw-r--r--aai-traversal/src/test/resources/application-test.properties9
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/complex.json19
-rw-r--r--aai-traversal/src/test/resources/schema-ingest.properties10
61 files changed, 2742 insertions, 313 deletions
diff --git a/aai-traversal/.classpath b/aai-traversal/.classpath
deleted file mode 100644
index ff97a07..0000000
--- a/aai-traversal/.classpath
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/aai-traversal/pom.xml b/aai-traversal/pom.xml
index a9555fe..773fd38 100644
--- a/aai-traversal/pom.xml
+++ b/aai-traversal/pom.xml
@@ -41,8 +41,8 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
- <aai.schema.version>1.4.0</aai.schema.version>
- <aai.core.version>1.4.0</aai.core.version>
+ <aai.schema.version>1.0.0-SNAPSHOT</aai.schema.version>
+ <aai.core.version>1.4.1-SNAPSHOT</aai.core.version>
<spring.boot.version>1.5.18.RELEASE</spring.boot.version>
@@ -158,7 +158,7 @@
<schema.version.namespace.change.start>v12</schema.version.namespace.change.start>
<schema.version.edge.label.start>v12</schema.version.edge.label.start>
<schema.version.api.default>v14</schema.version.api.default>
- <schema.version.list>v8,v9,v10,v11,v12,v13,v14</schema.version.list>
+ <schema.version.list>v8,v9,v10,v11,v12,v13,v14,v15</schema.version.list>
<schema.uri.base.path>/aai</schema.uri.base.path>
<!-- End of Default ONAP Schema Properties -->
</properties>
@@ -237,7 +237,7 @@
<properties>
<schema.source.name>onap</schema.source.name>
<schema.version.namespace.change.start>v12</schema.version.namespace.change.start>
- <schema.version.list>v8,v9,v10,v11,v12,v13,v14</schema.version.list>
+ <schema.version.list>v8,v9,v10,v11,v12,v13,v14,v15</schema.version.list>
</properties>
</profile>
<!-- End of ONAP Profile -->
@@ -670,6 +670,11 @@
<version>${httpclient.version}</version>
</dependency>
<dependency>
+ <groupId>org.onap.aai.aai-common</groupId>
+ <artifactId>aai-rest</artifactId>
+ <version>1.4.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>${jsonassert.version}</version>
@@ -1113,7 +1118,7 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>org.onap.aai.aai-common</groupId>
+ <groupId>org.onap.aai.schema-service</groupId>
<artifactId>aai-schema</artifactId>
<version>${aai.schema.version}</version>
<outputDirectory>${project.basedir}/src/main/resources/schema/</outputDirectory>
@@ -1132,7 +1137,7 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>org.onap.aai.aai-common</groupId>
+ <groupId>org.onap.aai.schema-service</groupId>
<artifactId>aai-schema</artifactId>
<version>${aai.schema.version}</version>
<outputDirectory>${project.basedir}/src/main/resources/schema/</outputDirectory>
diff --git a/aai-traversal/src/main/docker/docker-entrypoint.sh b/aai-traversal/src/main/docker/docker-entrypoint.sh
index c9e76ec..c4c4a03 100644
--- a/aai-traversal/src/main/docker/docker-entrypoint.sh
+++ b/aai-traversal/src/main/docker/docker-entrypoint.sh
@@ -65,7 +65,6 @@ if [ -f ${APP_HOME}/aai.sh ]; then
exit 0;
fi;
-
fi;
if [ -z ${DISABLE_UPDATE_QUERY} ]; then
@@ -83,8 +82,7 @@ fi;
MIN_HEAP_SIZE=${MIN_HEAP_SIZE:-512m};
MAX_HEAP_SIZE=${MAX_HEAP_SIZE:-1024m};
-MAX_PERM_SIZE=${MAX_PERM_SIZE:-512m};
-PERM_SIZE=${PERM_SIZE:-512m}
+MAX_METASPACE_SIZE=${MAX_METASPACE_SIZE:-512m};
JAVA_CMD="exec gosu aaiadmin java";
@@ -95,8 +93,7 @@ JVM_OPTS="${JVM_OPTS} -Xmx${MAX_HEAP_SIZE}";
JVM_OPTS="${JVM_OPTS} -XX:+PrintGCDetails";
JVM_OPTS="${JVM_OPTS} -XX:+PrintGCTimeStamps";
-JVM_OPTS="${JVM_OPTS} -XX:MaxPermSize=${MAX_PERM_SIZE}";
-JVM_OPTS="${JVM_OPTS} -XX:PermSize=${PERM_SIZE}";
+JVM_OPTS="${JVM_OPTS} -XX:MaxMetaspaceSize=${MAX_METASPACE_SIZE}";
JVM_OPTS="${JVM_OPTS} -server";
JVM_OPTS="${JVM_OPTS} -XX:NewSize=512m";
@@ -128,6 +125,7 @@ JAVA_OPTS="${JAVA_OPTS} -DAAI_BUILD_VERSION=${AAI_BUILD_VERSION}";
JAVA_OPTS="${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom";
JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=./resources/logback.xml";
JAVA_OPTS="${JAVA_OPTS} -Dloader.path=$APP_HOME/resources";
+JAVA_OPTS="${JAVA_OPTS} -Dgroovy.use.classvalue=true";
JAVA_OPTS="${JAVA_OPTS} ${POST_JAVA_OPTS}";
JAVA_MAIN_JAR=$(ls lib/aai-traversal*.jar);
diff --git a/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java b/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java
index 2797545..64a3b44 100644
--- a/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java
+++ b/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java
@@ -21,10 +21,12 @@ package org.onap.aai;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.onap.aai.config.PropertyPasswordConfiguration;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.logging.LoggingContext.StatusCode;
import org.onap.aai.nodes.NodeIngestor;
@@ -56,7 +58,8 @@ import java.util.Map;
"org.onap.aai.setup",
"org.onap.aai.tasks",
"org.onap.aai.service",
- "org.onap.aai.rest"
+ "org.onap.aai.rest",
+ "org.onap.aai.rest-client"
})
@EnableAutoConfiguration(exclude = {
@@ -122,14 +125,40 @@ public class TraversalApp {
AAIGraph.getInstance().graphShutdown();
}
- public static void main(String[] args) {
+ public static void main(String[] args) throws AAIException{
+
+ setDefaultProps();
+
+ LoggingContext.save();
+ LoggingContext.component("init");
+ LoggingContext.partnerName("NA");
+ LoggingContext.targetEntity(APP_NAME);
+ LoggingContext.requestId(UUID.randomUUID().toString());
+ LoggingContext.serviceName(APP_NAME);
+ LoggingContext.targetServiceName("contextInitialized");
+ LoggingContext.statusCode(StatusCode.COMPLETE);
+ Environment env =null;
+ AAIConfig.init();
+
+ try{
+ SpringApplication app = new SpringApplication(TraversalApp.class);
+ app.setLogStartupInfo(false);
+ app.setRegisterShutdownHook(true);
+ app.addInitializers(new PropertyPasswordConfiguration());
+ env = app.run(args).getEnvironment();
+ }
+ catch(Exception ex){
+ AAIException aai = schemaServiceExceptionTranslator(ex);
+ LoggingContext.statusCode(LoggingContext.StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
+ logger.error("Problems starting Traversal "+aai.getMessage());
+ ErrorLogHelper.logException(aai);
+ ErrorLogHelper.logError(aai.getCode(), ex.getMessage() + ", resolve and restart Traversal");
+ //ErrorLogHelper.logError(aai.getCode(), aai.getMessage() + aai.getCause().toString());
+ throw aai;
+ }
+
- setDefaultProps();
- SpringApplication app = new SpringApplication(TraversalApp.class);
- app.setLogStartupInfo(false);
- app.setRegisterShutdownHook(true);
- app.addInitializers(new PropertyPasswordConfiguration());
- Environment env = app.run(args).getEnvironment();
MDC.setContextMap (contextMap);
logger.info(
"Application '{}' is running on {}!" ,
@@ -166,4 +195,25 @@ public class TraversalApp {
}
}
+ private static AAIException schemaServiceExceptionTranslator(Exception ex) {
+ AAIException aai = null;
+ logger.info("Error Message is "+ ExceptionUtils.getRootCause(ex).toString() + " details - "+ExceptionUtils.getRootCause(ex).getMessage());
+ if(ExceptionUtils.getRootCause(ex).getMessage().contains("NodeIngestor")){
+ aai = new AAIException("AAI_3026","Error reading OXM from SchemaService - Investigate");
+ }
+ else if(ExceptionUtils.getRootCause(ex).getMessage().contains("EdgeIngestor")){
+ aai = new AAIException("AAI_3027","Error reading EdgeRules from SchemaService - Investigate");
+ }
+ else if(ExceptionUtils.getRootCause(ex).getMessage().contains("stored-queries")){
+ aai = new AAIException("AAI_3027","Error reading EdgeRules from SchemaService - Investigate");
+ }
+ else if(ExceptionUtils.getRootCause(ex).getMessage().contains("Connection refused")){
+ aai = new AAIException("AAI_3025","Error connecting to SchemaService - Investigate");
+ }
+ else {
+ aai = new AAIException("AAI_3025","Error connecting to SchemaService - Please Investigate");
+ }
+
+ return aai;
+ }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/config/DslConfiguration.java b/aai-traversal/src/main/java/org/onap/aai/config/DslConfiguration.java
index 74bc046..311dd99 100644
--- a/aai-traversal/src/main/java/org/onap/aai/config/DslConfiguration.java
+++ b/aai-traversal/src/main/java/org/onap/aai/config/DslConfiguration.java
@@ -20,8 +20,10 @@
package org.onap.aai.config;
import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.rest.dsl.DslListener;
import org.onap.aai.rest.dsl.DslQueryProcessor;
+import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -32,8 +34,8 @@ public class DslConfiguration {
@Bean
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public DslListener dslListener(EdgeIngestor edgeIngestor){
- return new DslListener(edgeIngestor);
+ public DslListener dslListener(EdgeIngestor edgeIngestor, SchemaVersions schemaVersions, LoaderFactory loaderFactory){
+ return new DslListener(edgeIngestor, schemaVersions, loaderFactory);
}
@Bean
diff --git a/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java b/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java
index bef10d0..0b8238b 100644
--- a/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java
+++ b/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java
@@ -25,17 +25,30 @@ import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.rest.dsl.DslListener;
import org.onap.aai.rest.dsl.DslQueryProcessor;
+import org.onap.aai.rest.search.CQConfig;
import org.onap.aai.rest.search.GremlinServerSingleton;
+import org.onap.aai.rest.search.LocalCQConfig;
+import org.onap.aai.rest.search.SchemaServiceCQConfig;
import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Scope;
@Configuration
+@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
+
public class SearchConfiguration {
+ private static final String CONFIG_TRANSLATOR = "config";
+ private static final String SCHEMA_SERVICE_TRANSLATOR = "schema-service";
+
+ @Value("${schema.translator.list}")
+ private String translator;
+
@Bean
public SearchGraph searchGraph(LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, SchemaVersions schemaVersions) {
SearchGraph searchGraph = new SearchGraph(loaderFactory, edgeIngestor, schemaVersions);
@@ -44,7 +57,18 @@ public class SearchConfiguration {
@Bean
public GremlinServerSingleton gremlinServerSingleton(){
- return new GremlinServerSingleton();
+ return new GremlinServerSingleton(getCustomQueryConfig());
}
+
+ @Bean
+ public CQConfig getCustomQueryConfig(){
+ if(translator.equals(SCHEMA_SERVICE_TRANSLATOR)) {
+ return new SchemaServiceCQConfig();
+ }
+ return new LocalCQConfig();
+ }
+
+
+
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java b/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
index 0725802..0221d8a 100644
--- a/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
+++ b/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.ws.rs.core.HttpHeaders;
@@ -520,7 +521,7 @@ public class SearchGraph {
edgeRules = edgeIngestor.getRules(query);
//Map<String, EdgeRule> rules = EdgeRules.getInstance().getEdgeRules(targetNodeType, nodeType);
- String[] results = edgeRules.keySet().toArray(new String[0]);
+ String[] results = edgeRules.values().stream().map(rule -> rule.getLabel()).collect(Collectors.toList()).toArray(new String[0]);
return results;
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java
index bdca63b..ad5fffb 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java
@@ -59,6 +59,7 @@ import org.onap.aai.serialization.queryformats.Formatter;
import org.onap.aai.serialization.queryformats.SubGraphStyle;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.TraversalConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -104,14 +105,14 @@ public class DslConsumer extends RESTAPI {
public Response executeQuery(String content, @PathParam("version") String versionParam,
@PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,
@DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers,
- @Context UriInfo info, @Context HttpServletRequest req) {
+ @Context UriInfo info, @Context HttpServletRequest req, @DefaultValue("-1") @QueryParam("resultIndex") String resultIndex, @DefaultValue("-1") @QueryParam("resultSize") String resultSize) {
return runner(TraversalConstants.AAI_TRAVERSAL_DSL_TIMEOUT_ENABLED,
TraversalConstants.AAI_TRAVERSAL_DSL_TIMEOUT_APP, TraversalConstants.AAI_TRAVERSAL_DSL_TIMEOUT_LIMIT,
headers, info, HttpMethod.PUT, new AaiCallable<Response>() {
@Override
public Response process() {
return processExecuteQuery(content, versionParam, uri, queryFormat, subgraph, headers, info,
- req);
+ req, resultIndex, resultSize);
}
});
}
@@ -119,10 +120,11 @@ public class DslConsumer extends RESTAPI {
public Response processExecuteQuery(String content, @PathParam("version") String versionParam,
@PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,
@DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers,
- @Context UriInfo info, @Context HttpServletRequest req) {
+ @Context UriInfo info, @Context HttpServletRequest req, @DefaultValue("-1") @QueryParam("resultIndex") String resultIndex, @DefaultValue("-1") @QueryParam("resultSize") String resultSize) {
String methodName = "executeDslQuery";
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
+ String dslOverride = headers.getRequestHeaders().getFirst("X-DslOverride");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
Response response;
SchemaVersion version = new SchemaVersion(versionParam);
@@ -132,6 +134,7 @@ public class DslConsumer extends RESTAPI {
LoggingContext.save();
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ traversalUriHttpEntry.setPaginationParameters(resultIndex, resultSize);
dbEngine = traversalUriHttpEntry.getDbEngine();
JsonObject input = new JsonParser().parse(content).getAsJsonObject();
JsonElement dslElement = input.get("dsl");
@@ -145,29 +148,46 @@ public class DslConsumer extends RESTAPI {
LoggingContext.startTime();
StopWatch.conditionalStart();
+ boolean isDslOverride = dslOverride != null && !AAIConfig.get(TraversalConstants.DSL_OVERRIDE).equals("false")
+ && dslOverride.equals(AAIConfig.get(TraversalConstants.DSL_OVERRIDE));
+
+ if(isDslOverride)
+ dslQueryProcessor.setValidationFlag(false);
+
GenericQueryProcessor processor = new GenericQueryProcessor.Builder(dbEngine, gremlinServerSingleton)
.queryFrom(dsl, "dsl").queryProcessor(dslQueryProcessor).processWith(processorType).create();
-
+
String result = "";
SubGraphStyle subGraphStyle = SubGraphStyle.valueOf(subgraph);
- List<Object> vertices = processor.execute(subGraphStyle);
-
+ List<Object> vertTemp = processor.execute(subGraphStyle);
+ List<Object> vertices = traversalUriHttpEntry.getPaginatedVertexList(vertTemp);
DBSerializer serializer = new DBSerializer(version, dbEngine, ModelType.MOXY, sourceOfTruth);
Format format = Format.getFormat(queryFormat);
FormatFactory ff = new FormatFactory(traversalUriHttpEntry.getLoader(), serializer, schemaVersions,
this.basePath);
-
+
Formatter formater = ff.get(format, info.getQueryParameters());
result = formater.output(vertices).toString();
-
+
double msecs = StopWatch.stopIfStarted();
LoggingContext.elapsedTime((long) msecs, TimeUnit.MILLISECONDS);
LoggingContext.successStatusFields();
LOGGER.info("Completed");
-
- response = Response.status(Status.OK).type(MediaType.APPLICATION_JSON).entity(result).build();
-
+
+ if(traversalUriHttpEntry.isPaginated()){
+ response = Response.status(Status.OK)
+ .type(MediaType.APPLICATION_JSON)
+ .header("total-results", traversalUriHttpEntry.getTotalVertices())
+ .header("total-pages", traversalUriHttpEntry.getTotalPaginationBuckets())
+ .entity(result)
+ .build();
+ }else {
+ response = Response.status(Status.OK)
+ .type(MediaType.APPLICATION_JSON)
+ .entity(result).build();
+ }
+
} catch (AAIException e) {
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.PUT, e);
} catch (Exception e) {
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
index 7ce61e3..633bc9c 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
@@ -23,8 +23,10 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
@@ -118,7 +120,7 @@ public class QueryConsumer extends RESTAPI {
@PUT
@Consumes({ MediaType.APPLICATION_JSON})
@Produces({ MediaType.APPLICATION_JSON})
- public Response executeQuery(String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,@DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req){
+ public Response executeQuery(String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,@DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req, @DefaultValue("-1") @QueryParam("resultIndex") String resultIndex, @DefaultValue("-1") @QueryParam("resultSize") String resultSize){
return runner(TraversalConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
TraversalConstants.AAI_TRAVERSAL_TIMEOUT_APP,
TraversalConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
@@ -128,14 +130,13 @@ public class QueryConsumer extends RESTAPI {
new AaiCallable<Response>() {
@Override
public Response process() {
- return processExecuteQuery(content, versionParam, uri, queryFormat, subgraph, headers, info, req);
+ return processExecuteQuery(content, versionParam, uri, queryFormat, subgraph, headers, info, req, resultIndex, resultSize);
}
}
);
}
- public Response processExecuteQuery(String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,@DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
-
+ public Response processExecuteQuery(String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,@DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req, @DefaultValue("-1") @QueryParam("resultIndex") String resultIndex, @DefaultValue("-1") @QueryParam("resultSize") String resultSize) {
String methodName = "executeQuery";
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
@@ -165,6 +166,11 @@ public class QueryConsumer extends RESTAPI {
SchemaVersion version = new SchemaVersion(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ /*
+ * Changes for Pagination
+ */
+
+ traversalUriHttpEntry.setPaginationParameters(resultIndex, resultSize);
dbEngine = traversalUriHttpEntry.getDbEngine();
if (startElement != null) {
@@ -188,9 +194,17 @@ public class QueryConsumer extends RESTAPI {
CustomQueryConfig customQueryConfig = getCustomQueryConfig(queryURIObj);
if ( customQueryConfig != null ) {
List<String> missingRequiredQueryParameters = checkForMissingQueryParameters( customQueryConfig.getQueryRequiredProperties(), URITools.getQueryMap(queryURIObj));
+
if ( !missingRequiredQueryParameters.isEmpty() ) {
return( createMessageMissingQueryRequiredParameters( missingRequiredQueryParameters, headers, info, req));
}
+
+ List<String> invalidQueryParameters = checkForInvalidQueryParameters( customQueryConfig, URITools.getQueryMap(queryURIObj));
+
+ if ( !invalidQueryParameters.isEmpty() ) {
+ return( createMessageInvalidQueryParameters( invalidQueryParameters, headers, info, req));
+ }
+
} else if ( queryElement != null ) {
return( createMessageInvalidQuerySection( queryURI, headers, info, req));
}
@@ -227,8 +241,9 @@ public class QueryConsumer extends RESTAPI {
.processWith(processorType).create();
}
String result = "";
- List<Object> vertices = processor.execute(subGraphStyle);
-
+ List<Object> vertTemp = processor.execute(subGraphStyle);
+ List<Object> vertices = traversalUriHttpEntry.getPaginatedVertexList(vertTemp);
+
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
FormatFactory ff = new FormatFactory(traversalUriHttpEntry.getLoader(), serializer, schemaVersions, this.basePath);
@@ -240,12 +255,19 @@ public class QueryConsumer extends RESTAPI {
LoggingContext.elapsedTime((long)msecs,TimeUnit.MILLISECONDS);
LoggingContext.successStatusFields();
LOGGER.info ("Completed");
-
-
- response = Response.status(Status.OK)
- .type(MediaType.APPLICATION_JSON)
- .entity(result).build();
+ if(traversalUriHttpEntry.isPaginated()){
+ response = Response.status(Status.OK)
+ .type(MediaType.APPLICATION_JSON)
+ .header("total-results", traversalUriHttpEntry.getTotalVertices())
+ .header("total-pages", traversalUriHttpEntry.getTotalPaginationBuckets())
+ .entity(result)
+ .build();
+ }else {
+ response = Response.status(Status.OK)
+ .type(MediaType.APPLICATION_JSON)
+ .entity(result).build();
+ }
} catch (AAIException e) {
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e);
} catch (Exception e ) {
@@ -340,6 +362,44 @@ public class QueryConsumer extends RESTAPI {
return response;
}
+
+
+ public List<String> checkForInvalidQueryParameters( CustomQueryConfig customQueryConfig, MultivaluedMap<String, String> queryParams) {
+
+ List<String> allParameters = new ArrayList<String>();
+ /*
+ * Add potential Required and Optional to allParameters
+ */
+ Optional.ofNullable(customQueryConfig.getQueryOptionalProperties()).ifPresent(allParameters::addAll);
+ Optional.ofNullable(customQueryConfig.getQueryRequiredProperties()).ifPresent(allParameters::addAll);
+
+ if(queryParams.isEmpty())
+ return new ArrayList<>();
+ List<String> invalidParameters = queryParams.keySet().stream()
+ .filter(param -> !allParameters.contains(param))
+ .collect(Collectors.toList());
+
+ return invalidParameters;
+
+ }
+
+ private Response createMessageInvalidQueryParameters(List<String> invalidQueryParams, HttpHeaders headers, UriInfo info, HttpServletRequest req) {
+ AAIException e = new AAIException("AAI_3022");
+
+ ArrayList<String> templateVars = new ArrayList<>();
+
+ if (templateVars.isEmpty()) {
+ templateVars.add(invalidQueryParams.toString());
+ }
+
+ Response response = Response
+ .status(e.getErrorObject().getHTTPResponseCode())
+ .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
+ templateVars)).build();
+
+ return response;
+ }
+
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java
index 46bccdf..3154087 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java
@@ -224,8 +224,13 @@ public class RecentAPIConsumer extends RESTAPI {
if (params != null && params.containsKey("hours") && params.getFirst("hours").matches("-?\\d+")) {
isHoursParameter = true;
-
- Long hours = Long.parseLong(params.getFirst("hours"));
+ Long hours = 0L;
+ try{
+ hours = Long.parseLong(params.getFirst("hours"));
+ }
+ catch(NumberFormatException ex){
+ throw new AAIException("AAI_3021", " Invalid Hours. Valid values for hours are 1 to " + AAIConstants.HISTORY_MAX_HOURS);
+ }
if (hours < 1 || hours > AAIConstants.HISTORY_MAX_HOURS) {
throw new AAIException("AAI_3021", " Valid values for hours are 1 to " + AAIConstants.HISTORY_MAX_HOURS);
}
@@ -233,7 +238,13 @@ public class RecentAPIConsumer extends RESTAPI {
if (params != null && params.containsKey("date-time") && params.getFirst("date-time").matches("-?\\d+")) {
isDateTimeParameter = true;
Long minStartTime = System.currentTimeMillis() - TimeUnit.HOURS.toMillis(AAIConstants.HISTORY_MAX_HOURS);
- Long startTime = Long.parseLong(params.getFirst("date-time"));
+ Long startTime = 0L;
+ try{
+ startTime = Long.parseLong(params.getFirst("date-time"));
+ }
+ catch(NumberFormatException ex){
+ throw new AAIException("AAI_3021", " Invalid Data-time. Valid values for date-time are "+minStartTime+" to " + System.currentTimeMillis() );
+ }
if (startTime < minStartTime) {
throw new AAIException("AAI_3021", " Valid values for date-time are "+minStartTime+" to " + System.currentTimeMillis() );
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java
index 3a3cc96..9ffa69b 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java
@@ -19,8 +19,10 @@
*/
package org.onap.aai.rest.dsl;
+import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;
+import java.util.List;
import org.antlr.v4.runtime.ParserRuleContext;
@@ -28,8 +30,12 @@ public class DslContext {
private ParserRuleContext ctx;
+ private boolean validationFlag = true;
+ private boolean isStartNode = false;
+ private String startNode = "";
+ private List<String> startNodeKeys = new ArrayList<String>();
+
private String currentNode;
-
private String previousNode;
private boolean isTraversal = false;
@@ -38,7 +44,7 @@ public class DslContext {
private boolean isUnionStart = false;
private String whereStartNode = "";
-
+
private Deque<String> unionStartNodes = new LinkedList<String>();
/*
@@ -55,6 +61,26 @@ public class DslContext {
this.ctx = ctx;
}
+ public boolean isStartNode() {
+ return isStartNode;
+ }
+
+ public void setStartNodeFlag(boolean isStartNode) {
+ this.isStartNode = isStartNode;
+ }
+
+ public String getStartNode() {
+ return startNode;
+ }
+
+ public void setStartNode(String startNode) {
+ this.startNode = startNode;
+ }
+
+ public List<String> getStartNodeKeys() {
+ return startNodeKeys;
+ }
+
public String getCurrentNode() {
return currentNode;
}
@@ -126,5 +152,13 @@ public class DslContext {
public void setLimitQuery(StringBuilder limitQuery) {
this.limitQuery = limitQuery;
}
+
+ public boolean isValidationFlag() {
+ return validationFlag;
+ }
+
+ public void setValidationFlag(boolean validationFlag) {
+ this.validationFlag = validationFlag;
+ }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java
index ecd04ac..a6be24c 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java
@@ -29,9 +29,17 @@ import java.util.List;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.onap.aai.AAIDslParser;
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.edges.EdgeRuleQuery;
import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.logging.LogFormatTools;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Autowired;
import org.onap.aai.AAIDslBaseListener;
import org.onap.aai.edges.EdgeIngestor;
@@ -54,18 +62,32 @@ public class DslListener extends AAIDslBaseListener {
* Instantiates a new DslListener.
*/
@Autowired
- public DslListener(EdgeIngestor edgeIngestor) {
+ public DslListener(EdgeIngestor edgeIngestor, SchemaVersions schemaVersions, LoaderFactory loaderFactory) {
this.edgeRules = edgeIngestor;
context = new DslContext();
- dslBuilder = new DslQueryBuilder(edgeIngestor);
+
+ Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ dslBuilder = new DslQueryBuilder(edgeIngestor, loader);
}
- public String getQuery() {
+ public String getQuery() throws AAIException {
+ if (!getException().isEmpty()) {
+ LOGGER.error("Exception in the DSL Query" + getException());
+ throw new AAIException("AAI_6149", getException());
+ }
return dslBuilder.getQuery().toString();
}
+ public String getException() {
+ return dslBuilder.getQueryException().toString();
+ }
+
@Override
public void enterAaiquery(AAIDslParser.AaiqueryContext ctx) {
+ /*
+ * This is my start-node, have some validations here
+ */
+ context.setStartNodeFlag(true);
dslBuilder.start();
}
@@ -131,6 +153,14 @@ public class DslListener extends AAIDslBaseListener {
@Override
public void exitSingleNodeStep(AAIDslParser.SingleNodeStepContext ctx) {
+ if (context.isStartNode() && isValidationFlag()) {
+ try {
+ dslBuilder.validateFilter(context);
+ } catch (AAIException e) {
+ LOGGER.error("AAIException in DslListener" + LogFormatTools.getStackTop(e));
+ }
+ }
+ context.setStartNodeFlag(false);
context.setCtx(ctx);
dslBuilder.store(context);
}
@@ -186,6 +216,7 @@ public class DslListener extends AAIDslBaseListener {
@Override
public void enterFilterStep(AAIDslParser.FilterStepContext ctx) {
+
context.setCtx(ctx);
dslBuilder.filter(context);
}
@@ -210,4 +241,13 @@ public class DslListener extends AAIDslBaseListener {
context.setCtx(ctx);
dslBuilder.limit(context);
}
+
+ public void setValidationFlag(boolean validationFlag) {
+ this.context.setValidationFlag(validationFlag);
+ }
+
+ public boolean isValidationFlag() {
+ return this.context.isValidationFlag();
+ }
+
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java
index 59f4443..fce8a98 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java
@@ -21,6 +21,7 @@ package org.onap.aai.rest.dsl;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import java.util.stream.Collectors;
import org.antlr.v4.runtime.tree.TerminalNode;
@@ -32,15 +33,24 @@ import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRuleQuery;
import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+
+import com.jcabi.log.Logger;
public class DslQueryBuilder {
private StringBuilder query;
+ private StringBuilder queryException;
private final EdgeIngestor edgeRules;
+ private final Loader loader;
- public DslQueryBuilder(EdgeIngestor edgeIngestor) {
+ public DslQueryBuilder(EdgeIngestor edgeIngestor, Loader loader) {
this.edgeRules = edgeIngestor;
+ this.loader = loader;
query = new StringBuilder();
+ queryException = new StringBuilder();
}
public StringBuilder getQuery() {
@@ -51,6 +61,14 @@ public class DslQueryBuilder {
this.query = query;
}
+ public StringBuilder getQueryException() {
+ return queryException;
+ }
+
+ public void setQueryException(StringBuilder queryException) {
+ this.queryException = queryException;
+ }
+
public DslQueryBuilder start() {
query.append("builder");
return this;
@@ -68,6 +86,8 @@ public class DslQueryBuilder {
public DslQueryBuilder nodeQuery(DslContext context) {
query.append(".getVerticesByProperty('aai-node-type', '").append(context.getCurrentNode()).append("')");
+ if(context.isStartNode() && context.getStartNode().isEmpty())
+ context.setStartNode(context.getCurrentNode());
return this;
}
@@ -76,7 +96,7 @@ public class DslQueryBuilder {
String edgeType = "";
if (!edgeRules.hasRule(baseQ.build())) {
throw new AAIException("AAI_6120", "No EdgeRule found for passed nodeTypes: " + context.getPreviousNode()
- + ", " + context.getCurrentNode());
+ + ", " + context.getCurrentNode());
} else if (edgeRules.hasRule(baseQ.edgeType(EdgeType.TREE).build())) {
edgeType = "EdgeType.TREE";
} else if (edgeRules.hasRule(baseQ.edgeType(EdgeType.COUSIN).build())) {
@@ -85,7 +105,7 @@ public class DslQueryBuilder {
edgeType = "EdgeType.COUSIN";
query.append(".createEdgeTraversal(").append(edgeType).append(", '").append(context.getPreviousNode())
- .append("','").append(context.getCurrentNode()).append("')");
+ .append("','").append(context.getCurrentNode()).append("')");
return this;
}
@@ -142,21 +162,53 @@ public class DslQueryBuilder {
}
+ public DslQueryBuilder validateFilter(DslContext context) throws AAIException {
+ Introspector obj = loader.introspectorFromName(context.getStartNode());
+ if(context.getStartNodeKeys().isEmpty()){
+ queryException.append("No keys sent. Valid keys for " + context.getStartNode() + " are "
+ + String.join(",", obj.getIndexedProperties()));
+ return this;
+ }
+ boolean notIndexed = context.getStartNodeKeys().stream()
+ .filter((prop) -> obj.getIndexedProperties().contains(prop)).collect(Collectors.toList()).isEmpty();
+ if (notIndexed)
+ queryException.append("Non indexed keys sent. Valid keys for " + context.getStartNode() + " "
+ + String.join(",", obj.getIndexedProperties()));
+
+ return this;
+ }
+
public DslQueryBuilder filterPropertyKeys(DslContext context) {
AAIDslParser.FilterStepContext ctx = (AAIDslParser.FilterStepContext) context.getCtx();
final String key = ctx.KEY(0).getText();
-
- query.append(key);
+ /*
+ * This key should be indexed if it is start node
+ */
+ if (context.isStartNode() && context.getStartNodeKeys().isEmpty()) {
+ // check if key is not indexed, then throw exception
+ context.getStartNodeKeys().add(key.replaceAll("'", ""));
+ }
+ query.append(key);
List<TerminalNode> nodes = ctx.KEY();
+ List<TerminalNode> numberValues = ctx.NODE();
+ /*
+ * Add all String values
+ */
List<String> valuesArray = nodes.stream().filter((node) -> !key.equals(node.getText()))
- .map((node) -> "'" + node.getText().replace("'", "").trim() + "'")
- .collect(Collectors.toList());
+ .map((node) -> "'" + node.getText().replace("'", "").trim() + "'").collect(Collectors.toList());
+
+ /*
+ * Add all numeric values
+ */
+ valuesArray.addAll(numberValues.stream().filter((node) -> !key.equals(node.getText()) )
+ .map((node) -> node.getText()).collect(Collectors.toList()));
+
/*
- * The whole point of doing this to separate P.within from key-value search
- * For a list of values QB uses P.within
- * For just a single value QB uses key,value check
+ * The whole point of doing this to separate P.within from key-value
+ * search For a list of values QB uses P.within For just a single value
+ * QB uses key,value check
*/
if (nodes.size() > 2) {
String values = String.join(",", valuesArray);
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java
index b2be402..d9ce63e 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java
@@ -30,7 +30,7 @@ import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.onap.aai.AAIDslLexer;
import org.onap.aai.AAIDslParser;
-
+import org.onap.aai.exceptions.AAIException;
import org.onap.aai.rest.dsl.DslListener;
import org.antlr.v4.runtime.Token;
@@ -46,13 +46,14 @@ public class DslQueryProcessor {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DslQueryProcessor.class);
private DslListener dslListener;
+ private boolean validationFlag = true;
@Autowired
- public DslQueryProcessor(DslListener dslListener){
+ public DslQueryProcessor(DslListener dslListener) {
this.dslListener = dslListener;
}
- public String parseAaiQuery(String aaiQuery) {
+ public String parseAaiQuery(String aaiQuery) throws AAIException {
try {
// Create a input stream that reads our string
InputStream stream = new ByteArrayInputStream(aaiQuery.getBytes(StandardCharsets.UTF_8));
@@ -63,10 +64,10 @@ public class DslQueryProcessor {
// Get a list of tokens pulled from the lexer
CommonTokenStream tokens = new CommonTokenStream(lexer);
-
// Parser that feeds off of the tokens buffer
AAIDslParser parser = new AAIDslParser(tokens);
+ dslListener.setValidationFlag(isValidationFlag());
// Specify our entry point
ParseTree ptree = parser.aaiquery();
LOGGER.info("QUERY-interim" + ptree.toStringTree(parser));
@@ -82,9 +83,17 @@ public class DslQueryProcessor {
*
*/
return dslListener.getQuery();
+ } catch (AAIException e) {
+ throw new AAIException("AAI_6149", "Error while processing the query :" + e.getMessage());
} catch (Exception e) {
- LOGGER.error("Error while processing the query"+e.getMessage());
+ throw new AAIException("AAI_6149","Error while processing the query :" + e.getMessage());
}
- return "";
+ }
+ public boolean isValidationFlag() {
+ return validationFlag;
+ }
+
+ public void setValidationFlag(boolean validationFlag) {
+ this.validationFlag = validationFlag;
}
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/CQConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/CQConfig.java
new file mode 100644
index 0000000..d17fb2b
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/CQConfig.java
@@ -0,0 +1,28 @@
+/**
+ * ============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;
+
+public abstract class CQConfig {
+ protected GetCustomQueryConfig queryConfig;
+
+ public GetCustomQueryConfig getCustomQueryConfig(){
+ return queryConfig;
+ }
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
index fd9d53b..56b748c 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
@@ -27,11 +27,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
-import org.onap.aai.config.SpringContextAware;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.query.builder.MissingOptionalParameter;
import org.onap.aai.rest.dsl.DslQueryProcessor;
-import org.onap.aai.restcore.search.GroovyQueryBuilderSingleton;
+import org.onap.aai.restcore.search.GroovyQueryBuilder;
import org.onap.aai.restcore.util.URITools;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.SubGraphStyle;
@@ -55,7 +54,7 @@ public abstract class GenericQueryProcessor {
protected Optional<String> gremlin;
protected final TransactionalGraphEngine dbEngine;
protected GremlinServerSingleton gremlinServerSingleton;
- protected static GroovyQueryBuilderSingleton queryBuilderSingleton = GroovyQueryBuilderSingleton.getInstance();
+ protected GroovyQueryBuilder groovyQueryBuilder = new GroovyQueryBuilder();
protected final boolean isGremlin;
protected Optional<DslQueryProcessor> dslQueryProcessorOptional;
/* dsl parameters to store dsl query and to check
@@ -130,7 +129,7 @@ public abstract class GenericQueryProcessor {
String dslUserQuery = dsl.get();
if(dslQueryProcessorOptional.isPresent()){
String dslQuery = dslQueryProcessorOptional.get().parseAaiQuery(dslUserQuery);
- query = queryBuilderSingleton.executeTraversal(dbEngine, dslQuery, params);
+ query = groovyQueryBuilder.executeTraversal(dbEngine, dslQuery, params);
String startPrefix = "g.V()";
query = startPrefix + query;
}
@@ -179,7 +178,7 @@ public abstract class GenericQueryProcessor {
if (query == null) {
query = "";
} else {
- query = queryBuilderSingleton.executeTraversal(dbEngine, query, params);
+ query = groovyQueryBuilder.executeTraversal(dbEngine, query, params);
}
String startPrefix = "g.V(startVertexes)";
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java
index 20a18d9..9ae3dec 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java
@@ -25,6 +25,7 @@ import org.onap.aai.util.FileWatcher;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.PostConstruct;
@@ -47,11 +48,8 @@ public class GremlinServerSingleton {
private boolean timerSet;
private Timer timer;
- private GetCustomQueryConfig queryConfig;
-
- @Value("${schema.queries.location}")
- private String storedQueriesLocation;
+ CQConfig customQueryInfo;
/**
* Initializes the gremlin server singleton
* Loads the configuration of the gremlin server and creates a cluster
@@ -61,41 +59,9 @@ public class GremlinServerSingleton {
* the properties object
*
*/
- @PostConstruct
- public void init() {
-
- try {
- String filepath = storedQueriesLocation + AAIConstants.AAI_FILESEP + "stored-queries.json";
- Path path = Paths.get(filepath);
- String customQueryConfigJson = new String(Files.readAllBytes(path));
-
-
- queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
- } catch (IOException e) {
- logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
- }
-
-
- TimerTask task = new FileWatcher(new File(storedQueriesLocation)) {
- @Override
- protected void onChange(File file) {
- try {
- String filepath = storedQueriesLocation;
- Path path = Paths.get(filepath);
- String customQueryConfigJson = new String(Files.readAllBytes(path));
- queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
- } catch (IOException e) {
- logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
- }
- }
- };
-
- if (!timerSet) {
- timerSet = true;
- timer = new Timer();
- timer.schedule( task , new Date(), 10000 );
- }
-
+ @Autowired
+ public GremlinServerSingleton(CQConfig customQueryInfo){
+ this.customQueryInfo = customQueryInfo;
}
/**
@@ -104,6 +70,8 @@ public class GremlinServerSingleton {
* @return
*/
public String getStoredQueryFromConfig(String key){
+ GetCustomQueryConfig queryConfig = customQueryInfo.getCustomQueryConfig();
+
CustomQueryConfig customQueryConfig = queryConfig.getStoredQuery(key);
if ( customQueryConfig == null ) {
return null;
@@ -112,6 +80,7 @@ public class GremlinServerSingleton {
}
public CustomQueryConfig getCustomQueryConfig(String key) {
+ GetCustomQueryConfig queryConfig = customQueryInfo.getCustomQueryConfig();
return queryConfig.getStoredQuery(key);
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyShellImpl.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyShellImpl.java
index de59262..712d7f0 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyShellImpl.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyShellImpl.java
@@ -23,7 +23,7 @@ import java.util.Map;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.onap.aai.restcore.search.GremlinGroovyShellSingleton;
+import org.onap.aai.restcore.search.GremlinGroovyShell;
public class GroovyShellImpl extends GenericQueryProcessor {
@@ -36,7 +36,7 @@ public class GroovyShellImpl extends GenericQueryProcessor {
params.put("g", this.dbEngine.asAdmin().getTraversalSource());
- GremlinGroovyShellSingleton shell = GremlinGroovyShellSingleton.getInstance();
+ GremlinGroovyShell shell = new GremlinGroovyShell();
return shell.executeTraversal(query, params);
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/LocalCQConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/LocalCQConfig.java
new file mode 100644
index 0000000..bcd4c4e
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/LocalCQConfig.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 com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.aai.logging.LogFormatTools;
+import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.FileWatcher;
+import org.springframework.beans.factory.annotation.Value;
+
+import javax.annotation.PostConstruct;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class LocalCQConfig extends CQConfig {
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(LocalCQConfig.class);
+
+ @Value("${schema.queries.location}")
+ private String storedQueriesLocation;
+
+ private boolean timerSet;
+ private Timer timer;
+
+ @PostConstruct
+ public void init() {
+
+ try {
+ String filepath = storedQueriesLocation + AAIConstants.AAI_FILESEP + "stored-queries.json";
+ logger.info("Using the Local stored queries");
+ Path path = Paths.get(filepath);
+ String customQueryConfigJson = new String(Files.readAllBytes(path));
+ queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
+
+ } catch (IOException e) {
+ logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
+ }
+
+ TimerTask task = new FileWatcher(new File(storedQueriesLocation)) {
+ @Override
+ protected void onChange(File file) {
+ try {
+ String filepath = storedQueriesLocation;
+ Path path = Paths.get(filepath);
+ String customQueryConfigJson = new String(Files.readAllBytes(path));
+ queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
+
+ } catch (IOException e) {
+ logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
+ }
+ }
+ };
+
+ if (!timerSet) {
+ timerSet = true;
+ timer = new Timer();
+ timer.schedule(task, new Date(), 10000);
+ }
+
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java
index 0126162..6421f67 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java
@@ -28,7 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.restcore.search.GroovyQueryBuilderSingleton;
+import org.onap.aai.restcore.search.GroovyQueryBuilder;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.SubGraphStyle;
@@ -49,7 +49,7 @@ public class NodeQueryProcessor extends GroovyShellImpl {
protected static Pattern p = Pattern.compile("query/(.*+)");
protected Optional<String> gremlin;
protected final TransactionalGraphEngine dbEngine;
- protected static GroovyQueryBuilderSingleton queryBuilderSingleton = GroovyQueryBuilderSingleton.getInstance();;
+ protected GroovyQueryBuilder queryBuilder = new GroovyQueryBuilder();;
protected NodeQueryProcessor(Builder builder) {
super(builder);
@@ -82,7 +82,7 @@ public class NodeQueryProcessor extends GroovyShellImpl {
params.put("startTime", startTime);
params.put("nodeType", nodeType);
- query = queryBuilderSingleton.executeTraversal(dbEngine, query, params);
+ query = queryBuilder.executeTraversal(dbEngine, query, params);
String startPrefix = "g.V()";
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/SchemaServiceCQConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/SchemaServiceCQConfig.java
new file mode 100644
index 0000000..6e55246
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/SchemaServiceCQConfig.java
@@ -0,0 +1,64 @@
+/**
+ * ============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.onap.aai.restclient.RestClient;
+import org.onap.aai.restclient.RestClientFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.ResponseEntity;
+
+import javax.annotation.PostConstruct;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SchemaServiceCQConfig extends CQConfig {
+
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceCQConfig.class);
+ private static final String SCHEMA_SERVICE = "schema-service";
+
+ @Value("${schema.service.custom.queries.endpoint}")
+ private String customQueriesUri;
+
+ @Autowired
+ private RestClientFactory restClientFactory;
+
+ @PostConstruct
+ public void initialize() {
+ //Call SchemaService to get custom queries
+ retrieveCustomQueries();
+ }
+
+ public void retrieveCustomQueries() {
+ /*
+ Call Schema MS to get custom queries using RestTemplate
+ */
+ logger.info("Calling the SchemaService to retrieve stored queries");
+ String content = "";
+ Map<String, String> headersMap = new HashMap<>();
+ RestClient restClient = restClientFactory
+ .getRestClient(SCHEMA_SERVICE);
+
+ ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, customQueriesUri, headersMap);
+ queryConfig = new GetCustomQueryConfig(schemaResponse.getBody());
+ }
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/util/TraversalConstants.java b/aai-traversal/src/main/java/org/onap/aai/util/TraversalConstants.java
index 69e1e9f..4b5ebfe 100644
--- a/aai-traversal/src/main/java/org/onap/aai/util/TraversalConstants.java
+++ b/aai-traversal/src/main/java/org/onap/aai/util/TraversalConstants.java
@@ -29,6 +29,8 @@ public final class TraversalConstants {
public static final String AAI_TRAVERSAL_DSL_TIMEOUT_LIMIT = "aai.traversal.dsl.timeoutlimit";
public static final String AAI_TRAVERSAL_DSL_TIMEOUT_ENABLED = "aai.traversal.dsl.timeoutenabled";
public static final String AAI_TRAVERSAL_DSL_TIMEOUT_APP = "aai.traversal.dsl.timeout.appspecific";
+ public static final String DSL_NOVALIDATION_CLIENTS = "aai.traversal.dsl.novalidation.clients";
+ public static final String DSL_OVERRIDE = "aai.dsl.override";
public static final long HISTORY_MAX_HOURS = 192;
diff --git a/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4 b/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
index f0c866a..cf34571 100644
--- a/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
+++ b/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
@@ -14,7 +14,7 @@ traverseStep: (TRAVERSE ( singleNodeStep | unionQueryStep));
singleNodeStep: NODE STORE? (filterStep | filterTraverseStep)*;
-filterStep: NOT? (LPAREN KEY (COMMA KEY)* RPAREN);
+filterStep: NOT? (LPAREN KEY (COMMA (KEY | NODE))* RPAREN);
filterTraverseStep: (LPAREN traverseStep* RPAREN);
limitStep: LIMIT NODE;
@@ -47,13 +47,13 @@ RBRACKET: [\]];
NOT: [!];
-VALUE: DIGIT;
+VALUE: [DIGIT]+;
fragment LOWERCASE : [a-z] ;
fragment UPPERCASE : [A-Z] ;
fragment DIGIT : [0-9] ;
ID
- : ( LOWERCASE | UPPERCASE | DIGIT) ( LOWERCASE | UPPERCASE | DIGIT | '-' |'.' |'_')*
+ : ( LOWERCASE | UPPERCASE | DIGIT) ( LOWERCASE | UPPERCASE | DIGIT | '-' | '.' | '_' | '/')*
;
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
diff --git a/aai-traversal/src/main/resources/application.properties b/aai-traversal/src/main/resources/application.properties
index 1769c9f..54fcc55 100644
--- a/aai-traversal/src/main/resources/application.properties
+++ b/aai-traversal/src/main/resources/application.properties
@@ -26,6 +26,10 @@ server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties
server.port=8446
server.ssl.enabled-protocols=TLSv1.1,TLSv1.2
+
+# By default spring boot jetty will exclude the following ciphers
+# We need to specifically add this to support tls v1.1
+server.ssl.ciphers=^.*_(MD5|SHA|SHA1)$
server.ssl.client-auth=want
server.ssl.key-store-type=JKS
@@ -36,7 +40,7 @@ server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
server.ssl.trust-store=${server.local.startpath}etc/auth/aai_keystore
server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-schema.version.list=v8,v9,v10,v11,v12,v13,v14
+schema.version.list=v8,v9,v10,v11,v12,v13,v14,v15
# Specifies which component should the oxm be looking at
schema.source.name=onap
# End of Internal Specific Properties
@@ -46,7 +50,6 @@ jms.bind.address=tcp://localhost:61646
dmaap.ribbon.listOfServers=localhost:3904
-# Lists all of the versions in the schema
# Schema related attributes for the oxm and edges
# Any additional schema related attributes should start with prefix schema
@@ -74,4 +77,16 @@ schema.version.namespace.change.start=v12
# Specifies from which version should the client start seeing the edge label in payload
schema.version.edge.label.start=v12
# Specifies the version that the application should default to
-schema.version.api.default=v14
+schema.version.api.default=v15
+
+schema.translator.list=config
+schema.service.base.url=https://localhost:8452/aai/schema-service/v1/
+schema.service.nodes.endpoint=nodes?version=
+schema.service.edges.endpoint=edgerules?version=
+schema.service.versions.endpoint=versions
+schema.service.custom.queries.endpoint=stored-queries
+
+schema.service.ssl.key-store=${server.local.startpath}etc/auth/aai_keystore
+schema.service.ssl.trust-store=${server.local.startpath}etc/auth/aai_keystore
+schema.service.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
+schema.service.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
diff --git a/aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties b/aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties
index d384727..a07e985 100644
--- a/aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties
@@ -31,23 +31,23 @@ aai.transaction.logging.get=true
aai.transaction.logging.post=true
aai.server.url.base=https://localhost:8443/aai/
-aai.server.url=https://localhost:8443/aai/v14/
+aai.server.url=https://localhost:8443/aai/v15/
aai.global.callback.url=https://localhost:8443/aai/
-aai.notification.current.version=v14
+aai.notification.current.version=v15
aai.notificationEvent.default.status=UNPROCESSED
aai.notificationEvent.default.eventType=AAI-EVENT
aai.notificationEvent.default.domain=devINT1
aai.notificationEvent.default.sourceName=aai
aai.notificationEvent.default.sequenceNumber=0
aai.notificationEvent.default.severity=NORMAL
-aai.notificationEvent.default.version=v14
+aai.notificationEvent.default.version=v15
# This one lets us enable/disable resource-version checking on updates/deletes
aai.resourceversion.enableflag=true
# This will specify how deep the stack trace should be logged
aai.logging.maxStackTraceEntries=10
-aai.default.api.version=v14
+aai.default.api.version=v15
# Used by Model-processing code
aai.model.query.resultset.maxcount=50
@@ -59,7 +59,7 @@ aai.jms.enable=false
aai.traversal.timeoutenabled=true
aai.traversal.dsl.timeoutenabled=true
#timeout app specific -1 to bypass for that app id, a whole number to override the timeout with that value (in ms)
-aai.traversal.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1|FitNesse-Test-PS2418,-1|FitNesse-Test-jenkins,-1|FitNesse-Test-ps2418,-1|FitNesse-Relationship-Test-PS2418,-1|FitNesse-Relationship-Test-ps2418,-1|FitNesse-Relationship-Test-jenkins,-1|VPESAT,-1|AAIRctFeed,-1|NewvceCreator,-1|IANewvceCreator,-1|AAI-CSIOVALS,-1
+aai.traversal.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1|FitNesse-Test-PS2418,-1|FitNesse-Test-jenkins,-1|FitNesse-Test-ps2418,-1|FitNesse-Relationship-Test-PS2418,-1|FitNesse-Relationship-Test-ps2418,-1|FitNesse-Relationship-Test-jenkins,-1|VPESAT,-1|AAIRctFeed,-1|NewvceCreator,-1|IANewvceCreator,-1|AAI-CSIOVALS,-1|AaiVnfGet,-1
aai.traversal.dsl.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1|FitNesse-Test-PS2418,-1|FitNesse-Test-jenkins,-1|FitNesse-Test-ps2418,-1|FitNesse-Relationship-Test-PS2418,-1|FitNesse-Relationship-Test-ps2418,-1|FitNesse-Relationship-Test-jenkins,-1|VPESAT,-1|AAIRctFeed,-1|NewvceCreator,-1|IANewvceCreator,-1|AAI-CSIOVALS,-1
#default timeout limit added for traversal if not overridden (in ms)
@@ -67,3 +67,11 @@ aai.traversal.timeoutlimit=180000
aai.traversal.dsl.timeoutlimit=180000
aai.realtime.clients=SDNC,SO,MSO
+
+#DSL Override property - when running on dev uncomment and use the value
+#aai.dsl.override=D5D0158NMWN14NYBA0H5F2S2L5JYD07RXJ4P1FB
+aai.dsl.override=false
+
+# Threshold for margin of error (in ms) for resources_with_sot format to derive the most recent http method performed
+aai.resource.formatter.threshold=10
+
diff --git a/aai-traversal/src/main/resources/etc/appprops/error.properties b/aai-traversal/src/main/resources/etc/appprops/error.properties
index d1e39cc..1ef789e 100644
--- a/aai-traversal/src/main/resources/etc/appprops/error.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/error.properties
@@ -36,6 +36,11 @@ AAI_3018=5:6:WARN:3018:400:3018:Query URI missing required parameters
AAI_3019=5:6:WARN:3019:400:3019:Query URI sending conflicting parameters
AAI_3020=5:6:WARN:3020:400:3020:Query URI parameters outside bounds
AAI_3021=5:6:WARN:3021:400:3021:Invalid parameters to Recents API
+AAI_3022=5:6:WARN:3022:400:3022:Query payload includes extra/unrecognized parameters %1
+AAI_3025=5:4:FATAL:3025:500:3025:Error connecting to Schema Service
+AAI_3026=5:4:FATAL:3026:500:3026:Error reading OXM from Schema Service
+AAI_3027=5:4:FATAL:3026:500:3026:Error reading EdgeRules from Schema Service
+AAI_3028=5:4:FATAL:3026:500:3026:Error reading stored-queries from Schema Service
# pol errors
AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1
@@ -118,6 +123,8 @@ AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via rel
AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead
AAI_6147=5:4:ERROR:6147:400:3000:Payload Limit Reached, reduce payload
AAI_6148=5:4:INFO:6148:404:3001:Node Not Found. Start URI returned no vertexes, please check the start URI
+AAI_6149=5:4:INFO:6149:404:6149:DSL Query Error
+AAI_6150=5:4:INFO:6150:404:6150:Pagination Error
#--- aaicsvp: 7101-7199
AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing
diff --git a/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties b/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties
index 2fb4940..d032dd0 100644
--- a/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties
@@ -45,7 +45,7 @@ load.snapshot.file=false
#storage.cql.keyspace=aaigraph_single_dc
#storage.cql.only-use-local-consistency-for-system-operations=true
#storage.cql.cluster-name=clusterName
-#storage.cql.local-datacenter=dataCenter
+#storage.cql.local-datacenter=dataCenterName
#storage.cql.read-consistency-level=QUORUM
#storage.cql.write-consistency-level=QUORUM
#storage.connection-timeout=100000
diff --git a/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties b/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties
index fbb2090..b55897c 100644
--- a/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties
@@ -36,13 +36,13 @@ load.snapshot.file=false
#storage.hostname=host1,host2,host3
#storage.cql.replication-strategy-class=NetworkTopologyStrategy
#storage.cql.replication-strategy-options=options
-# for single datacenter cluster
+#for single datacenter cluster
#storage.cql.replication-factor=3
#storage.cql.keyspace=aaigraph_single_dc
#storage.cql.only-use-local-consistency-for-system-operations=true
#storage.cql.cluster-name=clusterName
-#storage.cql.local-datacenter=dataCenter
+#storage.cql.local-datacenter=localDataCenter
#storage.cql.read-consistency-level=QUORUM
#storage.cql.write-consistency-level=QUORUM
#storage.connection-timeout=100000
diff --git a/aai-traversal/src/main/resources/etc/scriptdata/widget-model-json/collection-1.0.json b/aai-traversal/src/main/resources/etc/scriptdata/widget-model-json/collection-1.0.json
new file mode 100644
index 0000000..269f860
--- /dev/null
+++ b/aai-traversal/src/main/resources/etc/scriptdata/widget-model-json/collection-1.0.json
@@ -0,0 +1,11 @@
+{
+ "model-invariant-id" : "8bac3599-9a1c-4b7f-80e5-c1838f744c23",
+ "model-type" : "widget",
+ "model-vers" : {
+ "model-ver" : [ {
+ "model-version-id" : "3f908abc-3a15-40d0-b674-2a639e52884d",
+ "model-name" : "collection",
+ "model-version" : "1.0"
+ } ]
+ }
+}
diff --git a/aai-traversal/src/main/resources/schema/onap/query/stored-queries.json b/aai-traversal/src/main/resources/schema/onap/query/stored-queries.json
index a3f6a62..edbeff8 100644
--- a/aai-traversal/src/main/resources/schema/onap/query/stored-queries.json
+++ b/aai-traversal/src/main/resources/schema/onap/query/stored-queries.json
@@ -59,7 +59,7 @@
},
"stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'pnf').getVerticesByProperty('equip-vendor', equipVendor).getVerticesByProperty('equip-model', equipModel).store('x').cap('x').unfold().dedup()"
}
- },{
+ },{
"pnf-fromModel-byRegion":{
"query":{
"required-properties":["equipVendor","equipModel","cloudRegionId"]
@@ -95,6 +95,13 @@
"stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').getVerticesByProperty('interface-id', interfaceId).store('x')).union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
}
},{
+ "pserver-fromConfigurationFilterInterfaceId":{
+ "query":{
+ "required-properties":["interfaceId"]
+ },
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').getVerticesByProperty('interface-id', interfaceId).store('x')).union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
+ }
+ },{
"cloudRegion-fromCountry":{
"stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'complex', 'cloud-region').store('x').cap('x').unfold().dedup()"
}
@@ -196,7 +203,7 @@
}
},{
"topology-summary":{
- "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'image').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'flavor').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex').store('x'))).cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'line-of-business').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'platform').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'owning-entity').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'project').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'image').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'flavor').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex').store('x'))).cap('x').unfold().dedup()"
}
},{
"topology-detail":{
@@ -250,34 +257,34 @@
"stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').store('x').union( builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x').union( builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vip-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vip-ipv4-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vip-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vip-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', 'l3-interface-ipv4-address-list').store('x').union( builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x') ), builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', 'l3-interface-ipv6-address-list').store('x').union( builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x') ) ), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union( builder.newInstance().createEdgeTraversal(EdgeType.TREE,'vserver','tenant').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x').union( builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').union( builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x') ), builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').union( builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'subnet').store( 'x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x') ) ), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x') ), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pserver').store('x').createEdgeTraversal(EdgeType.TREE, 'pserver', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN, 'p-interface', 'physical-link').store('x') ).cap('x').unfold().dedup()"
}
},{
- "access-service-fromServiceInstance":{
- "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'forwarding-path').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarding-path', 'configuration').store('x').createEdgeTraversal(EdgeType.TREE, 'configuration', 'evc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'forwarding-path', 'forwarder').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'configuration').store('x').createEdgeTraversal(EdgeType.TREE, 'configuration', 'forwarder-evc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'p-interface', 'pnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'lag-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'lag-interface', 'pnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'lag-interface', 'logical-link').getVerticesByProperty('link-type', 'LAG').store('x'))))).cap('x').unfold().dedup()"
+ "access-service-fromServiceInstance":{
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'forwarding-path').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarding-path', 'configuration').store('x').createEdgeTraversal(EdgeType.TREE, 'configuration', 'evc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'forwarding-path', 'forwarder').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'configuration').store('x').createEdgeTraversal(EdgeType.TREE, 'configuration', 'forwarder-evc').store('x').createEdgeTraversal(EdgeType.TREE, 'forwarder-evc', 'vlan-mapping').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'p-interface', 'pnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'lag-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'lag-interface', 'pnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'lag-interface', 'logical-link').getVerticesByProperty('link-type', 'LAG').store('x'))))).cap('x').unfold().dedup()"
}
},{
- "count-vnf-byVnfType":{
+ "count-vnf-byVnfType":{
"stored-query":"builder.getVerticesByProperty('aai-node-type', 'generic-vnf').groupCount().by('vnf-type').store('x').unfold()"
- }
+ }
},{
- "pservers-withNoComplex":{
+ "pservers-withNoComplex":{
"stored-query":"builder.getVerticesByProperty('aai-node-type', 'pserver').where(builder.newInstance().not(builder.newInstance().both().getVerticesByProperty('aai-node-type', 'complex'))).store('x').unfold()"
- }
+ }
},{
"gfp-vserver-data":{
"stored-query":"builder.createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x')).cap('x').unfold().dedup()"
}
},{
- "gfp-vnf-data":{
+ "gfp-vnf-data":{
"stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list').store('x'))),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'lag-interface').createEdgeTraversal(EdgeType.TREE, 'lag-interface', 'l-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnf-image').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'network-profile').store('x')).cap('x').unfold().dedup()"
}
},{
-
"related-to":{
"query":{
- "required-properties":["startingNodeType","relatedToNodeType"]
+ "required-properties":["startingNodeType","relatedToNodeType"],
+ "optional-properties":["edgeType"]
},
- "stored-query":"builder.createEdgeTraversal(startingNodeType, relatedToNodeType).store('x').cap('x').unfold().dedup()"
+ "stored-query":"builder.createEdgeTraversal(edgeType, startingNodeType, relatedToNodeType).store('x').cap('x').unfold().dedup()"
}
- },{
+ },{
"gfp-vserver":{
"stored-query":"builder.where(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant'))"
}
@@ -292,35 +299,52 @@
},
"stored-query":"builder.where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').getVerticesByProperty('network-name',networkName)).createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').getVerticesByProperty('network-name',networkName).store('x').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x').cap('x').unfold().dedup()"
}
- },{
- "vnfs-vlans-fromServiceInstance":{
- "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'configuration').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'generic-vnf').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x')).cap('x').unfold().dedup()"
- }
- },{
- "getClfiRoadmTailSummary":{
- "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE,'p-interface', 'pnf').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'logical-link').store('x').createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'service-instance').store('x').createEdgeTraversal(EdgeType.TREE,'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE,'service-subscription', 'customer').store('x')).cap('x').unfold().dedup()"
+ },{
+ "containment-path":{
+ "stored-query":"builder.until(builder.newInstance().not(builder.newInstance().getParentEdge())).repeat(builder.newInstance().getParentVertex()).path()"
}
- },{
- "getRouterRoadmTailSummary":{
- "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.TREE,'pnf', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN,'p-interface', 'logical-link').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE,'p-interface', 'pnf').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'logical-link').store('x').createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'service-instance').store('x').createEdgeTraversal(EdgeType.TREE,'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE,'service-subscription', 'customer').store('x')).cap('x').unfold().dedup()"
+ },
+ {
+ "getSvcSubscriberModelInfo":{
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').store('x'),builder.newInstance().createPrivateEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'model-ver').store('x')).cap('x').unfold().dedup()"
}
- },{
- "topology-summary-fromCloudRegion":{
- "stored-query": "builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'cloud-region', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region', 'pserver').store('x')).cap('x').unfold().dedup()"
+ },
+ {
+ "vnf-vserver-fromCustomer":{
+ "stored-query":"builder.createEdgeTraversal(EdgeType.TREE, 'customer', 'service-subscription').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'service-instance').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').cap('x').unfold().dedup()"
}
- }, {
- "vservers-fromPserver-tree": {
- "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'vserver').tree()"
- }
+ },
+ {
+ "getCustomerVPNBondingServiceDetails":{
+ "stored-query":"builder.union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'service-instance').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'configuration').getVerticesByProperty('configuration-type', 'VLAN-NETWORK-RECEPTOR').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'generic-vnf').store('x').createEdgeTraversalWithLabels(EdgeType.COUSIN, 'generic-vnf', 'instance-group', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.MemberOf'))).store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'l3-network').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l3-network', 'subnet').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'subnet', 'l3-interface-ipv6-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'subnet', 'l3-interface-ipv4-address-list').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vpn-binding').store('x').createEdgeTraversal(EdgeType.TREE, 'vpn-binding', 'route-target').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l-interface').store('x'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'configuration').getVerticesByProperty('configuration-type', 'VRF ENTRY').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'vpn-binding').store('x').createEdgeTraversal(EdgeType.TREE, 'vpn-binding', 'route-target').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'pnf').getVerticesByProperty('nf-role','D2IPE').store('x')))).cap('x').unfold().dedup()"
+ }
+ },
+ {
+ "vnf-summary-fromVnf": {
+ "stored-query": "builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'platform').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'line-of-business').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'owning-entity').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'project').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x')).cap('x').unfold().dedup()"
+ }
+ },
+ {
+ "getComplexAndPservers":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'complex','pserver').store('x').cap('x').unfold().dedup()"
+ }
},{
"cloud-region-and-source-FromConfiguration":{
"stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'configuration','logical-link').createEdgeTraversalWithLabels(EdgeType.COUSIN, 'logical-link', 'l-interface',new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.Source'))).createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vf-module').createEdgeTraversal(EdgeType.TREE, 'vf-module', 'generic-vnf').store('x')).cap('x').unfold().dedup()"
}
},{
- "destination-FromConfiguration":{
- "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'configuration','logical-link').union(builder.newInstance().createEdgeTraversalWithLabels(EdgeType.COUSIN, 'logical-link', 'l-interface', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.Destination'))).createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vf-module').createEdgeTraversal(EdgeType.TREE, 'vf-module', 'generic-vnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
+ "getClfiRoadmTailSummary":{
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE,'p-interface', 'pnf').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'logical-link').createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'service-instance').store('x').createEdgeTraversal(EdgeType.TREE,'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE,'service-subscription', 'customer').store('x')).cap('x').unfold().dedup()"
+ }
+ },{
+ "getRouterRoadmTailSummary":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.TREE,'pnf', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN,'p-interface', 'logical-link').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE,'p-interface', 'pnf').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'logical-link').createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'service-instance').store('x').createEdgeTraversal(EdgeType.TREE,'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE,'service-subscription', 'customer').store('x')).cap('x').unfold().dedup()"
}
},{
+ "vservers-fromPserver-tree": {
+ "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'vserver').tree()"
+ }
+ },{
"topology-summary-fromTenant":{
"stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'tenant', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'))).cap('x').unfold().dedup()"
}
@@ -328,7 +352,11 @@
"vfModule-fromServiceInstance":{
"stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance','generic-vnf').createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').store('x').cap('x').unfold().dedup()"
}
- },{
+ },{
+ "topology-summary-fromCloudRegion":{
+ "stored-query": "builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'cloud-region', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region', 'pserver').store('x')).cap('x').unfold().dedup()"
+ }
+ }, {
"getComplexByPnfName":{
"stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN,'pnf', 'complex').store('x').cap('x').unfold().dedup()"
}
@@ -347,43 +375,41 @@
"network-collection-ByServiceInstance":{
"stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'collection').store('x').createEdgeTraversal(EdgeType.COUSIN, 'collection', 'instance-group').store('x').createEdgeTraversal(EdgeType.COUSIN, 'instance-group', 'l3-network').store('x').cap('x').unfold().dedup()"
}
+ },{
+ "getServiceTopology":{
+ "stored-query":"builder.union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'allotted-resource').createEdgeTraversal(EdgeType.TREE, 'allotted-resource', 'service-instance').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list')))))).tree()"}
+ },
+ {
+ "getL3networkCloudRegionByNetworkRole": {
+ "stored-query": "builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x').cap('x').unfold().dedup()"
+ }
},{
- "containment-path":{
- "stored-query":"builder.until(builder.newInstance().not(builder.newInstance().getParentEdge())).repeat(builder.newInstance().getParentVertex()).path()"
- }
- },{
- "getSvcSubscriberModelInfo":{
- "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').store('x'),builder.newInstance().createPrivateEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'model-ver').store('x')).cap('x').unfold().dedup()"
- }
- },
- {
+ "getNetworks": {
+ "query":{
+ "required-properties":["networkRole","cloudRegionId"]
+ },
+ "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'owning-entity','service-instance').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'l3-network').getVerticesByProperty('network-role', networkRole).where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'cloud-region').getVerticesByProperty('cloud-region-id', cloudRegionId)).store('x').cap('x').unfold().dedup()"
+ }
+ },{
"getLogicalLinkByCloudRegionId": {
"stored-query": "builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region', 'logical-link').store('x').cap('x').unfold().dedup()"
}
- },{
+ },{
"getPinterfacePhysicalLinkBySvcInstId":{
"stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN,'service-instance', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN,'generic-vnf', 'vserver').store('x').createEdgeTraversal(EdgeType.COUSIN,'vserver', 'pserver').store('x').createEdgeTraversal(EdgeType.TREE,'pserver', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN,'p-interface', 'physical-link').store('x').cap('x').unfold().dedup()"
}
- },{
+ },{
+ "getNetworksByServiceInstance": {
+ "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'l3-network').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vlan-tag').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'l3-network').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vlan-tag').store('x')).cap('x').unfold().dedup()"
+ }
+ },
+ {
"topology-detail-fromVnf":{
"stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x').createEdgeTraversal(EdgeType.TREE, 'cloud-region', 'availability-zone').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'image').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'flavor').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface','l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').createEdgeTraversal(EdgeType.COUSIN, 'vf-module', 'volume-group').store('x')).cap('x').unfold().dedup()"}
},{
"vnf-to-service-instance":{
"stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').store('x').cap('x').unfold().dedup()"}
- },{
- "getServiceTopology":{
- "stored-query":"builder.union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'allotted-resource').createEdgeTraversal(EdgeType.TREE, 'allotted-resource', 'service-instance').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list')))))).tree()"}
- },
- {
- "getL3networkCloudRegionByNetworkRole": {
- "stored-query": "builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x').cap('x').unfold().dedup()"
- }
- },{
- "getDHVLogicalLink": {
- "stored-query": "builder.createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').createEdgeTraversal(EdgeType.COUSIN, 'vlan', 'logical-link').tree()"
- }
- },
- {
+ },{
"pserver-fromHostnameFirstToken": {
"query":{
"required-properties":["hostnameFirstToken","sourcesOfTruth"]
@@ -391,7 +417,7 @@
"stored-query": "builder.getVerticesStartsWithProperty('hostname', hostnameFirstToken).getVerticesByProperty('source-of-truth', new ArrayList<>(Arrays.asList(sourcesOfTruth)))"
}
},
- {
+ {
"pserver-fromFqdnFirstToken": {
"query":{
"required-properties":["fqdnFirstToken","sourcesOfTruth"]
@@ -399,6 +425,25 @@
"stored-query": "builder.getVerticesStartsWithProperty('fqdn', fqdnFirstToken).getVerticesByProperty('source-of-truth', new ArrayList<>(Arrays.asList(sourcesOfTruth)))"
}
},
+ {
+ "cloud-regions-by-generic-vnf-HG-pairs": {
+ "stored-query": "builder.createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'service-instance').as('a').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'allotted-resource').createEdgeTraversal(EdgeType.TREE, 'allotted-resource', 'service-instance').createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').getVerticesByProperty('service-type', 'HNGATEWAY').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'service-instance').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').getVerticesByProperty('vnf-type', 'HG').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').as('b').select('a','b').by('aai-uri')"
+ }
+ },
+ {
+ "getDHVLogicalLink": {
+ "stored-query": "builder.createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').createEdgeTraversal(EdgeType.COUSIN, 'vlan', 'logical-link').tree()"
+ }
+ },
+ {
+ "destination-FromConfiguration":{
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'configuration','logical-link').union(builder.newInstance().createEdgeTraversalWithLabels(EdgeType.COUSIN, 'logical-link', 'l-interface', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.Destination'))).createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vf-module').createEdgeTraversal(EdgeType.TREE, 'vf-module', 'generic-vnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
+ }
+ },{
+ "fabric-information-fromVnf":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'sriov-vf').createEdgeTraversal(EdgeType.COUSIN, 'sriov-vf', 'sriov-pf').createEdgeTraversal(EdgeType.TREE, 'sriov-pf', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'p-interface', 'pserver').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').store('x').createEdgeTraversal(EdgeType.TREE, 'vnfc', 'cp').createEdgeTraversal(EdgeType.COUSIN, 'cp', 'vlan-tag').store('x')).cap('x').unfold().dedup()"
+ }
+ },
{
"getLinterface-fromNewvce": {
"query":{
@@ -415,23 +460,18 @@
"stored-query": "builder.union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', 'cp').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cp', 'vlan-tag').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cp', 'l3-network').getVerticesByBooleanProperty('is-provider-network', isProviderNetwork).store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x'))).cap('x').unfold().dedup()"
}
},
- {
- "getNetworks": {
- "query":{
- "required-properties":["networkRole","cloudRegionId"]
- },
- "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'owning-entity','service-instance').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'l3-network').getVerticesByProperty('network-role', networkRole).where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'cloud-region').getVerticesByProperty('cloud-region-id', cloudRegionId)).store('x').cap('x').unfold().dedup()"
- }
- },
- {
- "fabric-information-fromVnf":{
- "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'sriov-vf').createEdgeTraversal(EdgeType.COUSIN, 'sriov-vf', 'sriov-pf').createEdgeTraversal(EdgeType.TREE, 'sriov-pf', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'p-interface', 'pserver').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').createEdgeTraversal(EdgeType.TREE, 'vnfc', 'cp').createEdgeTraversal(EdgeType.COUSIN, 'cp', 'vlan-tag').store('x')).cap('x').unfold().dedup()"
+ {
+ "vnf-to-esr-system-info":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x').createEdgeTraversal(EdgeType.TREE, 'cloud-region', 'esr-system-info').store('x').cap('x').unfold().dedup()"
}
- },
- {
- "getNetworksByServiceInstance": {
- "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'l3-network').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vlan-tag').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'l3-network').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vlan-tag').store('x')).cap('x').unfold().dedup()"
+ },
+ {
+ "genericVnfs-fromPserver":{
+ "query":{
+ "optional-properties":["vnfType","nfFunction","nfRole","nfNamingCode"]
+ },
+ "stored-query":"builder.union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'generic-vnf'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'vserver').createEdgeTraversal('vserver','generic-vnf')).getVerticesByProperty('vnf-type',vnfType).getVerticesByProperty('nf-function',nfFunction).getVerticesByProperty('nf-role',nfRole).getVerticesByProperty('nf-naming-code',nfNamingCode).store('x').cap('x').unfold().dedup()"
}
}
- ]
+ ]
}
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;
+ }
+}
diff --git a/aai-traversal/src/test/resources/application-onap-test.properties b/aai-traversal/src/test/resources/application-onap-test.properties
new file mode 100644
index 0000000..fc53f7a
--- /dev/null
+++ b/aai-traversal/src/test/resources/application-onap-test.properties
@@ -0,0 +1,74 @@
+# The following info parameters are being referenced by ajsc6
+info.build.artifact=aai-traversal
+info.build.name=traversal
+info.build.description=Traversal Microservice
+info.build.version=1.1.0
+
+spring.application.name=aai-traversal
+spring.jersey.type=filter
+
+server.contextPath=/
+spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
+
+spring.jersey.application-path=${schema.uri.base.path}
+
+spring.profiles.active=production,two-way-ssl
+#The max number of active threads in this pool
+server.tomcat.max-threads=200
+#The minimum number of threads always kept alive
+server.tomcat.min-Spare-Threads=25
+#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
+server.tomcat.max-idle-time=60000
+
+#Servlet context parameters
+server.context_parameters.p-name=value #context parameter with p-name as key and value as value.
+
+# If you get an application startup failure that the port is already taken
+# If thats not it, please check if the key-store file path makes sense
+server.local.startpath=src/main/resources/
+server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties
+
+server.port=8446
+server.ssl.enabled-protocols=TLSv1.1,TLSv1.2
+server.ssl.key-store=${server.local.startpath}etc/auth/aai-client-cert.p12
+server.ssl.key-store-password=password(1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o)
+server.ssl.trust-store=${server.local.startpath}etc/auth/tomcat_keystore
+server.ssl.trust-store-password=password(1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o)
+server.ssl.client-auth=want
+server.ssl.key-store-type=JKS
+
+# JMS bind address host port
+jms.bind.address=tcp://localhost:61646
+
+# Schema related attributes for the oxm and edges
+# Any additional schema related attributes should start with prefix schema
+schema.configuration.location=N/A
+# Choose if the oxm schema is onap or other system
+schema.source.name=onap
+# Location of where the oxm files are
+schema.nodes.location=${server.local.startpath}/schema/${schema.source.name}/oxm/
+# Location of where the dbedgerules files are
+schema.edges.location=${server.local.startpath}/schema/${schema.source.name}/dbedgerules/
+# Location of where the stored queries are
+schema.queries.location=${server.local.startpath}/schema/${schema.source.name}/query/
+
+schema.ingest.file=${server.local.startpath}/application-test.properties
+
+# Schema Version Related Attributes
+schema.uri.base.path=/aai
+# Lists all of the versions in the schema
+schema.version.list=v10,v11,v12,v13,v14,v15
+# Specifies from which version should the depth parameter to default to zero
+schema.version.depth.start=v10
+# Specifies from which version should the related link be displayed in response payload
+schema.version.related.link.start=v10
+# Specifies from which version should the client see only the uri excluding host info
+# Before this version server base will also be included
+schema.version.app.root.start=v11
+# Specifies from which version should the namespace be changed
+schema.version.namespace.change.start=v12
+# Specifies from which version should the client start seeing the edge label in payload
+schema.version.edge.label.start=v12
+# Specifies the version that the application should default to
+schema.version.api.default=v15
+schema.translator.list=config \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/application-test.properties b/aai-traversal/src/test/resources/application-test.properties
index e9ecb99..57b51d5 100644
--- a/aai-traversal/src/test/resources/application-test.properties
+++ b/aai-traversal/src/test/resources/application-test.properties
@@ -47,6 +47,7 @@ dmaap.ribbon.listOfServers=localhost:3904
schema.configuration.location=N/A
# Choose if the oxm schema is onap or other system
schema.source.name=onap
+>>>>>>> release/1902
# Location of where the oxm files are
schema.nodes.location=${server.local.startpath}/schema/${schema.source.name}/oxm/
# Location of where the dbedgerules files are
@@ -59,9 +60,9 @@ schema.ingest.file=${server.local.startpath}/application-test.properties
# Schema Version Related Attributes
schema.uri.base.path=/aai
# Lists all of the versions in the schema
-schema.version.list=v8,v9,v10,v11,v12,v13,v14
+schema.version.list=v10,v11,v12,v13,v14,v15
# Specifies from which version should the depth parameter to default to zero
-schema.version.depth.start=v9
+schema.version.depth.start=v10
# Specifies from which version should the related link be displayed in response payload
schema.version.related.link.start=v10
# Specifies from which version should the client see only the uri excluding host info
@@ -72,4 +73,6 @@ schema.version.namespace.change.start=v12
# Specifies from which version should the client start seeing the edge label in payload
schema.version.edge.label.start=v12
# Specifies the version that the application should default to
-schema.version.api.default=v14
+schema.version.api.default=v15
+
+schema.translator.list=config
diff --git a/aai-traversal/src/test/resources/payloads/templates/complex.json b/aai-traversal/src/test/resources/payloads/templates/complex.json
new file mode 100644
index 0000000..ccdcf64
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/complex.json
@@ -0,0 +1,19 @@
+{
+ "physical-location-id": "location-1111",
+ "physical-location-type": "type-111",
+ "street1": "street-11",
+ "city": "city-11",
+ "postal-code": "postal-11",
+ "country": "US",
+ "region": "region-11",
+ "dataCenterCode": "test-code-111",
+ "complex-name": "example-complex-name-val-55430",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "cloud-region",
+ "related-link": "${cloud-region-uri}"
+ }
+ ]
+ }
+}
diff --git a/aai-traversal/src/test/resources/schema-ingest.properties b/aai-traversal/src/test/resources/schema-ingest.properties
new file mode 100644
index 0000000..f461aea
--- /dev/null
+++ b/aai-traversal/src/test/resources/schema-ingest.properties
@@ -0,0 +1,10 @@
+schema.configuration.location=N/A
+schema.nodes.location=src/main/resources/etc/oxm/
+schema.edges.location=src/main/resources/etc/dbedgerules/
+
+schema.version.list=v10,v11,v12,v13,v14,v15
+schema.version.depth.start=v10
+schema.version.related.link.start=v10
+schema.version.app.root.start=v11
+schema.version.edge.label.start=v12
+schema.version.api.default=v15