aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--aai-traversal/.classpath32
-rw-r--r--aai-traversal/.gitignore9
-rw-r--r--aai-traversal/ajsc-shared-config/etc/aft.properties13
-rw-r--r--aai-traversal/ajsc-shared-config/etc/logback.xml30
-rw-r--r--aai-traversal/bundleconfig-local/etc/appprops/aaiconfig.properties12
-rw-r--r--aai-traversal/bundleconfig-local/etc/appprops/caet.properties0
-rw-r--r--aai-traversal/bundleconfig-local/etc/appprops/error.properties22
-rw-r--r--aai-traversal/bundleconfig-local/etc/query/stored-queries.json45
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json263
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getComponentList-1.1.json12
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json20
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/widget-model-json/configuration-1.0.json11
-rw-r--r--aai-traversal/pom.xml36
-rw-r--r--aai-traversal/src/main/config/caet.properties0
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java376
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java27
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java14
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java14
-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/dsl/DslListener.java306
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java99
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java80
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java18
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java10
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java127
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java118
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java84
-rw-r--r--aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g466
-rw-r--r--aai-traversal/src/main/scripts/deleteNamedQuery.sh12
-rw-r--r--aai-traversal/src/main/scripts/putTool.sh61
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java984
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java1279
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java61
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java13
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java315
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java234
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java124
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java77
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java85
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java115
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java82
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java80
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java138
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java8
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java52
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java105
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java8
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java81
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java111
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java67
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java3
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java156
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java1
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java24
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java94
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java149
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java85
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java80
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java86
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java87
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java11
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java9
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java122
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java2
-rw-r--r--aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties10
-rw-r--r--aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties60
-rw-r--r--aai-traversal/src/test/resources/logback.xml239
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/cloud-region-with-linterface.json57
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/custom-query.json4
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/gremlin-query.json4
-rw-r--r--pom.xml2
80 files changed, 5874 insertions, 1719 deletions
diff --git a/.gitignore b/.gitignore
index 7cb9fb4..0aac718 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,7 +3,11 @@
target/
**/logs/
bundleconfig-local/etc/auth/aai-client-cert.p12
+bundleconfig-local/etc/auth/tomcat_keystore
bundleconfig-local/etc/logback.xml
/.pydevproject
/bin/
/.classpath
+**/.idea/
+*/.idea
+*.iml \ No newline at end of file
diff --git a/aai-traversal/.classpath b/aai-traversal/.classpath
index eecfd16..ff97a07 100644
--- a/aai-traversal/.classpath
+++ b/aai-traversal/.classpath
@@ -1,17 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/test/resources"/>
- <classpathentry kind="src" path="src/test/java"/>
- <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
- <attribute name="owner.project.facets" value="java"/>
+ <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 exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <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/.gitignore b/aai-traversal/.gitignore
index cd21128..ae3c172 100644
--- a/aai-traversal/.gitignore
+++ b/aai-traversal/.gitignore
@@ -1,10 +1 @@
-.settings
-target/
-**/logs/
-bundleconfig-local/etc/auth/aai-client-cert.p12
-bundleconfig-local/etc/oxm
-src/main/aai_schema
-bundleconfig-local/etc/logback.xml
-/.pydevproject
-/test_csvWriter.csv
/bin/
diff --git a/aai-traversal/ajsc-shared-config/etc/aft.properties b/aai-traversal/ajsc-shared-config/etc/aft.properties
deleted file mode 100644
index 43e896d..0000000
--- a/aai-traversal/ajsc-shared-config/etc/aft.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-
-# Flow test 319
-com.att.aft.discovery.client.environment=AFTUAT
-com.att.aft.discovery.client.latitude=35.318900
-com.att.aft.discovery.client.longitude=-80.762200
-com.att.aft.alias=ecomp-aai
-#com.att.aft.keyStore=ajsc-shared-config/etc/spm2.jks
-com.att.aft.keyStore=/opt/app/aai/bundleconfig/etc/m04353t.jks
-com.att.aft.keyStorePassword=its4test
-#com.att.aft.trustStore=ajsc-shared-config/etc/spm2.jks
-com.att.aft.trustStore=/opt/app/aai/bundleconfig/etc/m04353t.jks
-com.att.aft.trustStorePassword=its4test
-
diff --git a/aai-traversal/ajsc-shared-config/etc/logback.xml b/aai-traversal/ajsc-shared-config/etc/logback.xml
index 3b8a257..71b6585 100644
--- a/aai-traversal/ajsc-shared-config/etc/logback.xml
+++ b/aai-traversal/ajsc-shared-config/etc/logback.xml
@@ -28,7 +28,7 @@
<property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
<property name="eelfAuditLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n|\r\n', '^'}%n"/>
<property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
-
+ <property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%ecompResponseCode|%ecompResponseDescription|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
@@ -114,7 +114,7 @@
</fileNamePattern>
</rollingPolicy>
<encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <pattern>${eelfErrorLogPattern}</pattern>
</encoder>
</appender>
@@ -212,7 +212,26 @@
<pattern>${eelfLogPattern}</pattern>
</encoder>
</appender>
-
+ <appender name="external"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>WARN</level>
+ </filter>
+ <file>${logDirectory}/external/external.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/external/external.log.%d{yyyy-MM-dd}
+ </fileNamePattern>
+ </rollingPolicy>
+ <encoder class="org.onap.aai.logging.EcompEncoder">
+ <pattern>${eelfLogPattern}</pattern>
+ </encoder>
+ </appender>
+ <logger name="org.onap.aai" level="DEBUG" additivity="false">
+ <appender-ref ref="asyncDEBUG" />
+ <appender-ref ref="asyncERROR" />
+ <appender-ref ref="asyncMETRIC" />
+ <appender-ref ref="asyncSANE" />
+ </logger>
<!-- Spring related loggers -->
<logger name="org.springframework" level="WARN" />
<logger name="org.springframework.beans" level="WARN" />
@@ -221,6 +240,8 @@
<logger name="com.jayway.jsonpath" level="WARN" />
<!-- AJSC Services (bootstrap services) -->
+ <logger name="org.codehaus.groovy" level="WARN" />
+ <logger name="com.att.scamper" level="WARN" />
<logger name="ajsc" level="WARN" />
<logger name="ajsc.RouteMgmtService" level="WARN" />
<logger name="ajsc.ComputeService" level="WARN" />
@@ -230,6 +251,7 @@
<logger name="ajsc.UserDefinedBeansDefService" level="WARN" />
<logger name="ajsc.LoggingConfigurationService" level="WARN" />
+
<!-- AJSC related loggers (DME2 Registration, csi logging, restlet, servlet
logging) -->
<logger name="ajsc.utils" level="WARN" />
@@ -241,6 +263,7 @@
<logger name="com.att.ajsc" level="WARN" />
<logger name="com.att.ajsc.csi.logging" level="WARN" />
<logger name="com.att.ajsc.filemonitor" level="WARN" />
+ <logger name="com.att.ajsc.runner" level="WARN" />
<!-- Other Loggers that may help troubleshoot -->
<logger name="net.sf" level="WARN" />
@@ -365,5 +388,6 @@
<appender-ref ref="asyncERROR" />
<appender-ref ref="asyncMETRIC" />
<appender-ref ref="asyncSANE" />
+ <appender-ref ref="external" />
</root>
</configuration>
diff --git a/aai-traversal/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-traversal/bundleconfig-local/etc/appprops/aaiconfig.properties
index 9524a16..0c263be 100644
--- a/aai-traversal/bundleconfig-local/etc/appprops/aaiconfig.properties
+++ b/aai-traversal/bundleconfig-local/etc/appprops/aaiconfig.properties
@@ -73,7 +73,6 @@ aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo
aai.primary.filetransfer.pingtimeout=5000
aai.primary.filetransfer.pingcount=5
-
#rsync properties
aai.rsync.command=rsync
aai.rsync.options.list=-v|-t
@@ -108,3 +107,14 @@ aai.realtime.clients=RO,SDNC,MSO
aai.server.rebind=g
aai.jms.enable=false
+
+#timeout for traversal enabled flag
+aai.traversal.timeoutenabled=true
+
+#timeout app specific
+aai.traversal.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1
+
+#default timeout limit added for traversal if not overridden (in ms)
+aai.traversal.timeoutlimit=180000
+
+
diff --git a/aai-traversal/bundleconfig-local/etc/appprops/caet.properties b/aai-traversal/bundleconfig-local/etc/appprops/caet.properties
deleted file mode 100644
index e69de29..0000000
--- a/aai-traversal/bundleconfig-local/etc/appprops/caet.properties
+++ /dev/null
diff --git a/aai-traversal/bundleconfig-local/etc/appprops/error.properties b/aai-traversal/bundleconfig-local/etc/appprops/error.properties
index 34ef2de..ba71275 100644
--- a/aai-traversal/bundleconfig-local/etc/appprops/error.properties
+++ b/aai-traversal/bundleconfig-local/etc/appprops/error.properties
@@ -111,6 +111,7 @@ AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found
AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph
AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship
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
#--- aaicsvp: 7101-7199
AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing
@@ -138,7 +139,7 @@ AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl
AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API
AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API
AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate
-AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
+#AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
#--- NotificationEvent, using UEB space
AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed
@@ -148,17 +149,24 @@ AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API
AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error
AAI_7403=5:4:WARN:7403:400:3001:Request error
AAI_7404=5:4:INFO:7404:404:3001:Node not found
+AAI_7405=5:4:WARN:7405:200:0:UUID not formatted correctly, generating UUID
+AAI_7406=5:4:ERROR:7406:400:7406:Request Timed Out
+
+#--- aaicsiovals: 7501-7599
+#AAI_7501=5:4:WARN:7501:500:3002:Error getting connection to CSI-OVALS
+AAI_7502=5:4:WARN:7502:500:3002:Bad parameter when trying to build request for CSI-OVALS
+AAI_7503=5:4:WARN:7503:500:3002:Error returned by CSI-OVALS
#--- aaiauth: 9101-9199
AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function
-AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
-AAI_9103=5:0:WARN:9103:403:3300:User not found
-AAI_9104=5:0:WARN:9104:401:3302:Authentication error
-AAI_9105=5:0:WARN:9105:403:3300:Authorization error
-AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
+#AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
+#AAI_9103=5:0:WARN:9103:403:3300:User not found
+#AAI_9104=5:0:WARN:9104:401:3302:Authentication error
+#AAI_9105=5:0:WARN:9105:403:3300:Authorization error
+#AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request
AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin
#--- aaiinstar: 9201-9299
-AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
+#AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread
diff --git a/aai-traversal/bundleconfig-local/etc/query/stored-queries.json b/aai-traversal/bundleconfig-local/etc/query/stored-queries.json
index 8b883ce..8d18fd7 100644
--- a/aai-traversal/bundleconfig-local/etc/query/stored-queries.json
+++ b/aai-traversal/bundleconfig-local/etc/query/stored-queries.json
@@ -16,7 +16,7 @@
}
},{
"pserver-fromConfiguration":{
- "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x')).cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', '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()"
}
},{
"spaas-topology-fromServiceInstance":{
@@ -53,6 +53,13 @@
"stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'complex', 'l3-network').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'cloud-region').store('x').cap('x').unfold()"
}
},{
+ "pnf-fromModel-byRegion":{
+ "query":{
+ "required-properties":["equipVendor","equipModel","cloudRegionId"]
+ },
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'pnf').getVerticesByProperty('equip-vendor', equipVendor).getVerticesByProperty('equip-model', equipModel).where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pnf', 'complex').createEdgeTraversal(EdgeType.COUSIN, 'complex', 'cloud-region').getVerticesByProperty('cloud-region-id', cloudRegionId)).store('x').cap('x').unfold().dedup()"
+ }
+ },{
"topology-fromCloudRegionIdandServiceId":{
"query":{
"required-properties":["serviceId"]
@@ -78,7 +85,7 @@
"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', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x')).cap('x').unfold().dedup()"
+ "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', '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":{
@@ -100,7 +107,7 @@
"query":{
"required-properties":["distributionStatus"]
},
- "stored-query":"builder.where(builder.newInstance().createEdgeTraversal(EdgeType.TREE,'model', 'model-ver').getVerticesByProperty('distribution-status', distributionStatus)).store('x').createEdgeTraversal(EdgeType.TREE,'model', 'model-ver').getVerticesByProperty('distribution-status', distributionStatus).store('x').cap('x').unfold().dedup()"
+ "stored-query":"builder.getVerticesByProperty('model-type', 'service').where(builder.newInstance().createEdgeTraversal(EdgeType.TREE,'model', 'model-ver').getVerticesByProperty('distribution-status', distributionStatus)).store('x').createEdgeTraversal(EdgeType.TREE,'model', 'model-ver').getVerticesByProperty('distribution-status', distributionStatus).store('x').cap('x').unfold().dedup()"
}
},{
"vserver-fromVnf":{
@@ -151,10 +158,6 @@
"stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').getVerticesByProperty('cloud-region-id', cloudRegionId)).store('x').cap('x').unfold().dedup()"
}
},{
- "v2-legacy-subgraph":{
- "stored-query":"builder.newInstance().store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'flavor'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'image'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex')).store('x').cap('x').unfold()"
- }
- },{
"colocated-devices":{
"stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'pserver', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN, 'p-interface', 'physical-link').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'complex', 'pserver').store('x').createEdgeTraversal(EdgeType.TREE, 'pserver', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN, 'p-interface', 'physical-link').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'complex', 'pnf').store('x').createEdgeTraversal(EdgeType.TREE, 'pnf', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN, 'p-interface', 'physical-link').store('x'))).cap('x').unfold().dedup()"
}
@@ -190,7 +193,7 @@
}
},{
"topology-detail":{
- "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').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', 'vnfc').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x').union(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').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').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex').store('x'))).cap('x').unfold().dedup()"
+ "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').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', 'vnfc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(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').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').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex').store('x'))).cap('x').unfold().dedup()"
}
},{
"vnfs-fromPserver":{
@@ -235,5 +238,29 @@
"vnf-topology-fromVnf":{
"stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'allotted-resource').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'volume-group').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x'),),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x'),)).cap('x').unfold().dedup()"
}
+ },{
+ "service-topology":{
+ "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()"
+ }
+ },{
+ "count-vnf-byVnfType":{
+ "stored-query":"builder.getVerticesByProperty('aai-node-type', 'generic-vnf').groupCount().by('vnf-type').store('x').unfold()"
+ }
+ },{
+ "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":{
+ "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()"
+ }
}]
-}
+} \ No newline at end of file
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json
index e7a4314..2ff66f8 100644
--- a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json
@@ -1,187 +1,78 @@
{
- "description": "Named Query - For closed loop flow",
- "named-query-elements": {
- "named-query-element": [
- {
- "named-query-elements": {
- "named-query-element": [
- {
- "named-query-elements": {
- "named-query-element": [
- {
- "relationship-list": {
- "relationship": [
- {
- "related-to": "model",
- "relationship-data": [
- {
- "relationship-key": "model.model-invariant-id",
- "relationship-value": "425b2158-e51d-4509-9945-dad4556474a3"
- }
- ]
- }
- ]
- }
- }
- ]
- },
- "relationship-list": {
- "relationship": [
- {
- "related-to": "model",
- "relationship-data": [
- {
- "relationship-key": "model.model-invariant-id",
- "relationship-value": "97c26c99-6870-44c1-8a07-1d900d3f4ce6"
- }
- ]
- }
- ]
- }
- },
- {
- "named-query-elements": {
- "named-query-element": [
- {
- "related-lookups": {
- "related-lookup": [
- {
- "property-collect-list": [
- "model-invariant-id",
- "model-type"
- ],
- "source-node-property": "model-invariant-id-local",
- "source-node-type": "vf-module",
- "target-node-property": "model-invariant-id",
- "target-node-type": "model"
- },
- {
- "property-collect-list": [
- "model-name",
- "model-version-id",
- "model-version"
- ],
- "source-node-property": "model-version-id-local",
- "source-node-type": "vf-module",
- "target-node-property": "model-version-id",
- "target-node-type": "model-ver"
- }
- ]
- },
- "relationship-list": {
- "relationship": [
- {
- "related-to": "model",
- "relationship-data": [
- {
- "relationship-key": "model.model-invariant-id",
- "relationship-value": "ef86f9c5-2165-44f3-8fc3-96018b609ea5"
- }
- ]
- }
- ]
- }
- },
- {
- "related-lookups": {
- "related-lookup": [
- {
- "property-collect-list": [
- "model-invariant-id",
- "model-type"
- ],
- "source-node-property": "model-invariant-id-local",
- "source-node-type": "service-instance",
- "target-node-property": "model-invariant-id",
- "target-node-type": "model"
- },
- {
- "property-collect-list": [
- "model-name",
- "model-version-id",
- "model-version"
- ],
- "source-node-property": "model-version-id-local",
- "source-node-type": "service-instance",
- "target-node-property": "model-version-id",
- "target-node-type": "model-ver"
- }
- ]
- },
- "relationship-list": {
- "relationship": [
- {
- "related-to": "model",
- "relationship-data": [
- {
- "relationship-key": "model.model-invariant-id",
- "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
- }
- ]
- }
- ]
- }
- }
- ]
- },
- "related-lookups": {
- "related-lookup": [
- {
- "property-collect-list": [
- "model-invariant-id",
- "model-type"
- ],
- "source-node-property": "model-invariant-id-local",
- "source-node-type": "generic-vnf",
- "target-node-property": "model-invariant-id",
- "target-node-type": "model"
- },
- {
- "property-collect-list": [
- "model-name",
- "model-version-id",
- "model-version"
- ],
- "source-node-property": "model-version-id-local",
- "source-node-type": "generic-vnf",
- "target-node-property": "model-version-id",
- "target-node-type": "model-ver"
- }
- ]
- },
- "relationship-list": {
- "relationship": [
- {
- "related-to": "model",
- "relationship-data": [
- {
- "relationship-key": "model.model-invariant-id",
- "relationship-value": "acc6edd8-a8d4-4b93-afaa-0994068be14c"
- }
- ]
- }
- ]
- }
- }
- ]
- },
- "relationship-list": {
- "relationship": [
- {
- "related-to": "model",
- "relationship-data": [
- {
- "relationship-key": "model.model-invariant-id",
- "relationship-value": "ff69d4e0-a8e8-4108-bdb0-dd63217e63c7"
- }
- ]
- }
- ]
- }
- }
- ]
- },
- "named-query-name": "closed-loop-named-query",
- "named-query-uuid": "4ff56a54-9e3f-46b7-a337-07a1d3c6b469",
- "named-query-version": "1.0"
-}
+ "named-query-uuid" : "4ff56a54-9e3f-46b7-a337-07a1d3c6b469",
+ "named-query-name" : "closed-loop-named-query",
+ "named-query-version" : "1.0",
+ "description" : "Named Query - For closed loop flow",
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "425b2158-e51d-4509-9945-dad4556474a3"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "97c26c99-6870-44c1-8a07-1d900d3f4ce6"
+ } ]
+ } ]
+ }
+ }, {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "ef86f9c5-2165-44f3-8fc3-96018b609ea5"
+ } ]
+ } ]
+ }
+ }, {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "acc6edd8-a8d4-4b93-afaa-0994068be14c"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "ff69d4e0-a8e8-4108-bdb0-dd63217e63c7"
+ } ]
+ } ]
+ }
+ } ]
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getComponentList-1.1.json b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getComponentList-1.1.json
index 639cd41..f275950 100644
--- a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getComponentList-1.1.json
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getComponentList-1.1.json
@@ -8,6 +8,16 @@
"property-collect-list" : [ "service-instance-id", "service-instance-name" ],
"named-query-elements" : {
"named-query-element" : [ {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "166c050d-f69d-4305-943e-0bc58c3a26cf"
+ } ]
+ } ]
+ }
+ }, {
"named-query-elements" : {
"named-query-element" : [ {
"relationship-list" : {
@@ -122,4 +132,4 @@
}
} ]
}
-}
+} \ No newline at end of file
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json
index 55b6a14..c371796 100644
--- a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json
@@ -42,20 +42,10 @@
"relationship-key" : "model.model-invariant-id",
"relationship-value" : "97c26c99-6870-44c1-8a07-1d900d3f4ce6"
} ]
- }
- ] }
- },
- {
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "96129eb9-f0de-4e05-8af2-73146473f766"
- } ]
- }
- ] }
- } ] },
+ } ]
+ }
+ } ]
+ },
"relationship-list" : {
"relationship" : [ {
"related-to" : "model",
@@ -78,4 +68,4 @@
}
} ]
}
-}
+} \ No newline at end of file
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/widget-model-json/configuration-1.0.json b/aai-traversal/bundleconfig-local/etc/scriptdata/widget-model-json/configuration-1.0.json
new file mode 100644
index 0000000..939f175
--- /dev/null
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/widget-model-json/configuration-1.0.json
@@ -0,0 +1,11 @@
+{
+ "model-invariant-id" : "166c050d-f69d-4305-943e-0bc58c3a26cf",
+ "model-type" : "widget",
+ "model-vers" : {
+ "model-ver" : [ {
+ "model-version-id" : "5a175add-57e4-4a5d-8b02-c36f1d69c52b",
+ "model-version" : "1.0",
+ "model-name" : "configuration"
+ } ]
+ }
+}
diff --git a/aai-traversal/pom.xml b/aai-traversal/pom.xml
index 9db65af..d75187c 100644
--- a/aai-traversal/pom.xml
+++ b/aai-traversal/pom.xml
@@ -15,6 +15,7 @@
<properties>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
+ <!-- old version <hbase.version>0.98.4-hadoop2</hbase.version> -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dockerLocation>${basedir}/target/swm/package/nix/dist_files/</dockerLocation>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
@@ -26,17 +27,20 @@
<sonar.jacoco.reportPath>${project.build.directory}/coverage-reports/jacoco.exec</sonar.jacoco.reportPath>
<sonar.jacoco.reportMissing.force.zero>false</sonar.jacoco.reportMissing.force.zero>
<sonar.projectVersion>${project.version}</sonar.projectVersion>
+ <!-- Antlr-related properties to auto-gen visitor and listener -->
+ <antlr4.visitor>true</antlr4.visitor>
+ <antlr4.listener>true</antlr4.listener>
</properties>
<dependencies>
<dependency>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-schema</artifactId>
- <version>${project.version}</version>
+ <version>${aai.schema.version}</version>
</dependency>
<dependency>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-core</artifactId>
- <version>${project.version}</version>
+ <version>${aai.core.version}</version>
</dependency>
<!-- Scamper related dependencies -->
<dependency>
@@ -406,6 +410,16 @@
<artifactId>jolt-complete</artifactId>
<version>0.0.24</version>
</dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>4.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <version>4.7</version>
+ </dependency>
</dependencies>
<build>
<finalName>traversal</finalName>
@@ -448,7 +462,7 @@
<artifactItem>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-schema</artifactId>
- <version>${project.version}</version>
+ <version>${aai.core.version}</version>
<outputDirectory>bundleconfig-local/etc</outputDirectory>
<includes>oxm/*.xml</includes>
</artifactItem>
@@ -648,6 +662,22 @@
<serverId>ecomp-staging</serverId>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <version>4.7</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ <configuration>
+ <sourceDirectory>src/main/resources/antlr4</sourceDirectory>
+ <!-- <outputDirectory>src/main/java/antlr4</outputDirectory> -->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<profiles>
diff --git a/aai-traversal/src/main/config/caet.properties b/aai-traversal/src/main/config/caet.properties
deleted file mode 100644
index e69de29..0000000
--- a/aai-traversal/src/main/config/caet.properties
+++ /dev/null
diff --git a/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java b/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
index 5e7f9d9..aeeac2e 100644
--- a/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
+++ b/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
@@ -21,19 +21,13 @@
*/
package org.onap.aai.dbgraphgen;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.util.concurrent.SimpleTimeLimiter;
+import com.google.common.util.concurrent.TimeLimiter;
+import com.google.common.util.concurrent.UncheckedTimeoutException;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
@@ -52,18 +46,14 @@ import org.onap.aai.serialization.db.EdgeType;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.util.AAIConfig;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-import com.google.common.util.concurrent.SimpleTimeLimiter;
-import com.google.common.util.concurrent.TimeLimiter;
-import com.google.common.util.concurrent.UncheckedTimeoutException;
+import java.util.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
/**
* Utility class that uses Model/Named-Query definitions to navigate the graph.
*/
-public class ModelBasedProcessing{
+public class ModelBasedProcessing {
private EELFLogger LOGGER = EELFManager.getInstance().getLogger(ModelBasedProcessing.class);
private final int MAX_LEVELS = 50; // max depth allowed for our model - to protect against infinite loop problems
@@ -103,7 +93,7 @@ public class ModelBasedProcessing{
String passedTopNodeType,
List<Map<String,Object>> startNodeFilterArrayOfHashes,
String apiVer )
- throws AAIException{
+ throws AAIException {
// ----------------------------------------------------------------------------------------------------
// Get a hash for all start-nodes (key = vtxId, val = modelVersionId that applies)
// If no start-node-key info is passed, then use either the passed modelVersion or
@@ -122,14 +112,14 @@ public class ModelBasedProcessing{
if( (passedModelVersionId == null || passedModelVersionId.equals(""))
&& (passedModelInvId == null || passedModelInvId.equals(""))
&& (passedModelName == null || passedModelName.equals(""))){
- throw new AAIException("AAI_6118", "ModelInvariantId or ModelName or ModelVersionId required if no startNodeFilter data passed.");
+ throw new AAIException("AAI_6118", "ModelInvariantId or ModelName or ModelVersionId required if no startNodeFilter data passed.");
}
else {
// Use whatever model info they pass to find start-node instances
// Get the first/top named-query-element used by this query
if( passedModelVersionId != null && !passedModelVersionId.equals("") ){
// Need to look up the model-invariant-id and model-version to check against persona data
- Vertex modVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
+ Vertex modVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
"model-version-id", passedModelVersionId);
Vertex modVtx = getModelGivenModelVer( modVerVtx, "" );
String calcModId = modVtx.<String>property("model-invariant-id").orElse(null);
@@ -218,7 +208,7 @@ public class ModelBasedProcessing{
// the passsed-in one (if there is one)
if( passedTopNodeType != null && !passedTopNodeType.equals("")
&& !passedTopNodeType.equals(modTopNodeType) ){
- throw new AAIException("AAI_6120", "topNodeType passed in [" + passedTopNodeType
+ throw new AAIException("AAI_6120", "topNodeType passed in [" + passedTopNodeType
+ "] does not match nodeType derived for model info passed in: ["
+ modTopNodeType + "]");
}
@@ -330,14 +320,14 @@ public class ModelBasedProcessing{
* @return resultSet
* @throws AAIException the AAI exception
*/
- public List<ResultSet> queryByModel( String transId, String fromAppId,
- String modelVersionId,
- String modelInvariantId,
- String modelName,
- String topNodeType,
- List<Map<String,Object>> startNodeFilterArrayOfHashes,
- String apiVer )
- throws AAIException{
+ public List<ResultSet> queryByModel(String transId, String fromAppId,
+ String modelVersionId,
+ String modelInvariantId,
+ String modelName,
+ String topNodeType,
+ List<Map<String,Object>> startNodeFilterArrayOfHashes,
+ String apiVer )
+ throws AAIException {
final String transId_f = transId;
final String fromAppId_f = fromAppId;
@@ -415,14 +405,14 @@ public class ModelBasedProcessing{
* @return the array list
* @throws AAIException the AAI exception
*/
- public List<ResultSet> queryByModel_Timed( String transId, String fromAppId,
- String modelVersionId,
- String modelInvariantId,
- String modelName,
- String topNodeType,
- List<Map<String,Object>> startNodeFilterArrayOfHashesVal,
- String apiVer )
- throws AAIException{
+ public List<ResultSet> queryByModel_Timed(String transId, String fromAppId,
+ String modelVersionId,
+ String modelInvariantId,
+ String modelName,
+ String topNodeType,
+ List<Map<String,Object>> startNodeFilterArrayOfHashesVal,
+ String apiVer )
+ throws AAIException {
List<ResultSet> resultArray = new ArrayList<>();
@@ -472,7 +462,7 @@ public class ModelBasedProcessing{
// Figure out what-all models (model-ver nodes) we will be dealing with
// Note - Instances must all use the same type of start-node, but do not have to all use the same model-ver.
// --------------------------------------------------------------------------------------------------------
- Map<String, Vertex> distinctModelVersHash = new HashMap<>();
+ Map<String, Vertex> distinctModelVersHash = new HashMap<>();
// For distinctModelVersHash: key = modelVersionId, val= modelVerVertex
String startNodeType = "";
if( topNodeType != null && !topNodeType.equals("") ){
@@ -488,7 +478,7 @@ public class ModelBasedProcessing{
String modVerId = startNode2ModelVerHash.get(modVerIdKey);
if( !distinctModelVersHash.containsKey(modVerId) ){
// First time seeing this model-version-id
- Vertex modVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
+ Vertex modVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
"model-version-id", modVerId);
String tmpNodeType = "";
try {
@@ -524,7 +514,7 @@ public class ModelBasedProcessing{
// While we're at it, get a mapping of model-invariant-id|model-version to model-version-id for
// the model-vers being used
// ------------------------------------------------------------------------------------------------------
- Map<String, Multimap<String, String>> validNextStepHash = new HashMap<>();
+ Map<String, Multimap<String, String>> validNextStepHash = new HashMap<>();
// validNextStepHash: key = modelVerId, value = nextStepMap
Set <String> keySet = distinctModelVersHash.keySet();
Iterator<String> modelVerIterator = keySet.iterator();
@@ -631,7 +621,7 @@ public class ModelBasedProcessing{
List<String> vidsTraversed = new ArrayList<>();
Map<String,String> emptyDelKeyHash = new HashMap<>();
Map<String,String> emptyNQElementHash = new HashMap<>(); // Only applies to Named Queries
- ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
+ ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
tmpStartVtx, elementLocationTrail,
validNextStepMap, vidsTraversed, 0, emptyDelKeyHash, emptyNQElementHash, apiVer );
@@ -659,7 +649,7 @@ public class ModelBasedProcessing{
*/
public Map<String,String> runDeleteByModel( String transId, String fromAppId,
String modelVersionId, String topNodeTypeVal, Map<String,Object> startNodeFilterHash, String apiVer, String resVersion )
- throws AAIException{
+ throws AAIException {
Map<String,String> retHash = new HashMap<>();
@@ -721,7 +711,7 @@ public class ModelBasedProcessing{
String chkFirstNodePersonaModInvId = "";
String chkFirstNodePersonaModVerId = "";
String personaData = "";
- Vertex firstModElementVertex = getTopElementForSvcOrResModelVer( modelVerVtx, "" );
+ Vertex firstModElementVertex = getTopElementForSvcOrResModelVer( modelVerVtx, "" );
topNType = getModElementWidgetType( firstModElementVertex, "" );
if( (topNType == null) || topNType.equals("") ){
String msg = "Could not determine the top-node nodeType for model-version-id: [" + modelVersionId + "]";
@@ -771,7 +761,7 @@ public class ModelBasedProcessing{
String topVid = startVtx.id().toString();
// Read the model-ver into a Map for processing
- Multimap <String, String> validNextStepMap = genTopoMap4ModelVer(transId, fromAppId,
+ Multimap<String, String> validNextStepMap = genTopoMap4ModelVer(transId, fromAppId,
modelVerVtx, modelVersionId);
// Collect the data
@@ -780,7 +770,7 @@ public class ModelBasedProcessing{
Map<String,String> emptyHash = new HashMap<>();
// Pass emptyHash for the NQElement hash since that parameter only applies to Named Queries
- ResultSet retResSet = collectInstanceData( transId, fromAppId,
+ ResultSet retResSet = collectInstanceData( transId, fromAppId,
startVtx, elementLocationTrail,
validNextStepMap, vidsTraversed, 0, delKeyHash, emptyHash, apiVer );
@@ -812,8 +802,8 @@ public class ModelBasedProcessing{
* @return String
* @throws AAIException the AAI exception
*/
- public Map<String,String> deleteAsNeededFromResultSet( String transId, String fromAppId,
- ResultSet resSet, String vidToResCheck, String apiVer, String resVersion, Map<String,String> hashSoFar )
+ public Map<String,String> deleteAsNeededFromResultSet(String transId, String fromAppId,
+ ResultSet resSet, String vidToResCheck, String apiVer, String resVersion, Map<String,String> hashSoFar )
throws AAIException
{
Map<String,String> retHash = new HashMap<>();
@@ -842,7 +832,7 @@ public class ModelBasedProcessing{
// "vtx.isRemoved()" but that was a Titan-only feature and is not available anymore since
// we no longer use Titan vertices.
// If we don't do this check, we get errors later when we try to delete the node.
- thisVtx.property(AAIProperties.NODE_TYPE, thisNT);
+ thisVtx.property(AAIProperties.NODE_TYPE, thisNT);
gotVtxOK = true;
}
}
@@ -905,7 +895,7 @@ public class ModelBasedProcessing{
}
// Now call this routine for the sub-resultSets
- List <ResultSet> subResultSetList = resSet.getSubResultSet();
+ List <ResultSet> subResultSetList = resSet.getSubResultSet();
Iterator <ResultSet> subResSetIter = subResultSetList.iterator();
while( subResSetIter.hasNext() ){
ResultSet tmpSubResSet = subResSetIter.next();
@@ -934,11 +924,11 @@ public class ModelBasedProcessing{
* @return resultSet
* @throws AAIException the AAI exception
*/
- public List<ResultSet> queryByNamedQuery( String transId, String fromAppId,
- String namedQueryUuid,
- ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes,
- String apiVer )
- throws AAIException{
+ public List<ResultSet> queryByNamedQuery(String transId, String fromAppId,
+ String namedQueryUuid,
+ ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes,
+ String apiVer )
+ throws AAIException {
String dummyCutPoint = null;
Map<String,Object> dummySecondaryFilterHash = null;
@@ -965,13 +955,13 @@ public class ModelBasedProcessing{
* @return resultSet
* @throws AAIException the AAI exception
*/
- public List<ResultSet> queryByNamedQuery( String transId, String fromAppId,
- String namedQueryUuid,
- List<Map<String,Object>> startNodeFilterArrayOfHashes,
- String apiVer,
- String secondaryFilterCutPoint,
- Map<String,Object> secondaryFilterHash )
- throws AAIException{
+ public List<ResultSet> queryByNamedQuery(String transId, String fromAppId,
+ String namedQueryUuid,
+ List<Map<String,Object>> startNodeFilterArrayOfHashes,
+ String apiVer,
+ String secondaryFilterCutPoint,
+ Map<String,Object> secondaryFilterHash )
+ throws AAIException {
final String transId_f = transId;
final String fromAppId_f = fromAppId;
@@ -1046,17 +1036,17 @@ public class ModelBasedProcessing{
* @return resultSet
* @throws AAIException the AAI exception
*/
- public List<ResultSet> queryByNamedQuery_Timed( String transId, String fromAppId,
- String namedQueryUuid,
- List<Map<String,Object>> startNodeFilterArrayOfHashes,
- String apiVer,
- String secondaryFilterCutPoint,
- Map<String,Object> secondaryFilterHash
+ public List<ResultSet> queryByNamedQuery_Timed(String transId, String fromAppId,
+ String namedQueryUuid,
+ List<Map<String,Object>> startNodeFilterArrayOfHashes,
+ String apiVer,
+ String secondaryFilterCutPoint,
+ Map<String,Object> secondaryFilterHash
)
- throws AAIException{
+ throws AAIException {
// Locate the Query to be used
- Vertex queryVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query",
+ Vertex queryVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query",
"named-query-uuid", namedQueryUuid);
// Get the first/top named-query-element used by this query
@@ -1084,7 +1074,7 @@ public class ModelBasedProcessing{
}
// Read the topology into a hash for processing
- Multimap <String, String> validNextStepMap = genTopoMap4NamedQ(transId, fromAppId, queryVtx, namedQueryUuid);
+ Multimap<String, String> validNextStepMap = genTopoMap4NamedQ(transId, fromAppId, queryVtx, namedQueryUuid);
List<Vertex> startVertList = new ArrayList<>();
if( startNodeFilterArrayOfHashes.size() == 1 ){
@@ -1174,7 +1164,7 @@ public class ModelBasedProcessing{
firstNqElementVert, incomingTrail, currentHash, vidsTraversed, 0 );
vidsTraversed = new ArrayList<>();
- ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
+ ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
startVtx, elementLocationTrail,
validNextStepMap, vidsTraversed, 0, emptyDelKeyHash, namedQueryElementHash, apiVer );
resSetList.add(tmpResSet);
@@ -1232,7 +1222,7 @@ public class ModelBasedProcessing{
* @return pruned result set
* @throws AAIException the AAI exception
*/
- public ResultSet pruneResultSet( ResultSet resSetVal, String cutPointType, Map<String,Object> secFilterHash )
+ public ResultSet pruneResultSet(ResultSet resSetVal, String cutPointType, Map<String,Object> secFilterHash )
throws AAIException {
// Given a ResultSet and some secondary filter info, do pruning as needed
@@ -1286,7 +1276,7 @@ public class ModelBasedProcessing{
* @return true, if successful
* @throws AAIException the AAI exception
*/
- public boolean satisfiesFilters( ResultSet resSet, Map<String,Object> filterHash )
+ public boolean satisfiesFilters(ResultSet resSet, Map<String,Object> filterHash )
throws AAIException {
if( filterHash.isEmpty() ){
@@ -1303,7 +1293,7 @@ public class ModelBasedProcessing{
int periodLoc = propNodeTypeDotName.indexOf(".");
if( periodLoc <= 0 ){
String emsg = "Bad filter param key passed in: [" + propNodeTypeDotName + "]. Expected format = [nodeName.paramName]\n";
- throw new AAIException("AAI_6120", emsg);
+ throw new AAIException("AAI_6120", emsg);
}
else {
String fnt = propNodeTypeDotName.substring(0,periodLoc);
@@ -1333,7 +1323,7 @@ public class ModelBasedProcessing{
* @param filtPropVal the filt prop val
* @return true, if successful
*/
- public boolean filterMetByThisSet( ResultSet resSet, String filtNodeType, String filtPropName, String filtPropVal ) {
+ public boolean filterMetByThisSet(ResultSet resSet, String filtNodeType, String filtPropName, String filtPropVal ) {
// Note - we are just looking for a positive match for one filter for this resultSet
// NOTE: we're expecting the filter to have a format like this: "nodeType.parameterName:parameterValue"
@@ -1386,7 +1376,7 @@ public class ModelBasedProcessing{
* @return the array list
* @throws AAIException the AAI exception
*/
- public List<ResultSet> collapseForDoNotOutput( ResultSet resSetVal )
+ public List<ResultSet> collapseForDoNotOutput(ResultSet resSetVal )
throws AAIException {
// Given a ResultSet -- if it is tagged to NOT be output, then replace it with
@@ -1441,15 +1431,15 @@ public class ModelBasedProcessing{
* @return resultSet
* @throws AAIException the AAI exception
*/
- public ResultSet collectInstanceData( String transId, String fromAppId,
- Vertex thisLevelElemVtx,
- String thisVertsTrail,
- Multimap <String,String> validNextStepMap,
- List<String> vidsTraversed,
- int levelCounter,
- Map<String,String> delKeyHash, // only applies when collecting data using the default model for delete
- Map<String,String> namedQueryElementHash, // only applies to named-query data collecting
- String apiVer
+ public ResultSet collectInstanceData(String transId, String fromAppId,
+ Vertex thisLevelElemVtx,
+ String thisVertsTrail,
+ Multimap<String,String> validNextStepMap,
+ List<String> vidsTraversed,
+ int levelCounter,
+ Map<String,String> delKeyHash, // only applies when collecting data using the default model for delete
+ Map<String,String> namedQueryElementHash, // only applies to named-query data collecting
+ String apiVer
) throws AAIException {
levelCounter++;
@@ -1457,14 +1447,14 @@ public class ModelBasedProcessing{
String thisElemVid = thisLevelElemVtx.id().toString();
if( levelCounter > MAX_LEVELS ) {
- throw new AAIException("AAI_6125", "collectInstanceData() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
+ throw new AAIException("AAI_6125", "collectInstanceData() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
ResultSet rs = new ResultSet();
if( namedQueryElementHash.containsKey(thisVertsTrail) ){
// We're collecting data for a named-query, so need to see if we need to do anything special
String nqElUuid = namedQueryElementHash.get(thisVertsTrail);
- Vertex nqElementVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query-element",
+ Vertex nqElementVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query-element",
"named-query-element-uuid", nqElUuid);
String tmpDoNotShow = nqElementVtx.<String>property("do-not-output").orElse(null);
@@ -1542,7 +1532,7 @@ public class ModelBasedProcessing{
stepIsJustNT = false;
String[] pieces = targetStep.split(",");
if( pieces.length != 3 ){
- throw new AAIException("AAI_6128", "Unexpected format for nextStep in model processing = ["
+ throw new AAIException("AAI_6128", "Unexpected format for nextStep in model processing = ["
+ targetStep + "]. ");
}
else {
@@ -1574,7 +1564,7 @@ public class ModelBasedProcessing{
String tmpTrail = thisVertsTrail + "|" + targetStep;
if( !vidsTraversed.contains(tmpVid) ){
// This is one we would like to use - so we'll include the result set we get for it
- ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
+ ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
tmpVert, tmpTrail,
validNextStepMap, tmpVidsTraversedList,
levelCounter, delKeyHash, namedQueryElementHash, apiVer );
@@ -1601,15 +1591,15 @@ public class ModelBasedProcessing{
* @return MultiMap of valid next steps for each potential model-element
* @throws AAIException the AAI exception
*/
- public Multimap<String, String> genTopoMap4ModelVer( String transId, String fromAppId,
- Vertex modelVerVertex, String modelVerId)
+ public Multimap<String, String> genTopoMap4ModelVer(String transId, String fromAppId,
+ Vertex modelVerVertex, String modelVerId)
throws AAIException {
if( modelVerVertex == null ){
throw new AAIException("AAI_6114", "null modelVerVertex passed to genTopoMap4ModelVer()");
}
- Multimap <String, String> initialEmptyMap = ArrayListMultimap.create();
+ Multimap<String, String> initialEmptyMap = ArrayListMultimap.create();
List<String> vidsTraversed = new ArrayList<>();
String modelType = getModelTypeFromModelVer( modelVerVertex, "" );
if( modelType.equals("widget") ){
@@ -1618,7 +1608,7 @@ public class ModelBasedProcessing{
// an aai-node-type
Iterator<Vertex> vertI= this.traverseIncidentEdges(EdgeType.TREE, modelVerVertex, "model-element");
if( vertI != null && vertI.hasNext() ){
- throw new AAIException("AAI_6132", "Bad Model Definition: Widget Model has a startsWith edge to a model-element. "
+ throw new AAIException("AAI_6132", "Bad Model Definition: Widget Model has a startsWith edge to a model-element. "
+ " model-version-id = " + modelVerId);
}
else {
@@ -1629,7 +1619,7 @@ public class ModelBasedProcessing{
String firstModelVerId = modelVerVertex.<String>property("model-version-id").orElse(null);
String firstModelVersion = modelVerVertex.<String>property("model-version").orElse(null);
if( firstModelVerId == null || firstModelVerId.equals("") || firstModelVersion == null || firstModelVersion.equals("") ){
- throw new AAIException("AAI_6132", "Bad Model Definition: Bad model-version-id or model-version. model-version-id = "
+ throw new AAIException("AAI_6132", "Bad Model Definition: Bad model-version-id or model-version. model-version-id = "
+ modelVerId);
}
@@ -1637,18 +1627,18 @@ public class ModelBasedProcessing{
Vertex firstEleModVerVtx = getModelVerThatElementRepresents( firstElementVertex, "" );
String firstElemModelType = getModelTypeFromModelVer( firstEleModVerVtx, "" );
if( ! firstElemModelType.equals("widget") ){
- throw new AAIException("AAI_6132", "Bad Model Definition: First element must correspond to a widget type model. Model UUID = "
+ throw new AAIException("AAI_6132", "Bad Model Definition: First element must correspond to a widget type model. Model UUID = "
+ modelVerId);
}
Vertex firstModVtx = getModelGivenModelVer( modelVerVertex, "" );
String firstModelInvId = firstModVtx.<String>property("model-invariant-id").orElse(null);
if( firstModelInvId == null || firstModelInvId.equals("") ){
- throw new AAIException("AAI_6132", "Bad Model Definition: Could not find model.model-invariant-id given model-ver.model-version-id = "
+ throw new AAIException("AAI_6132", "Bad Model Definition: Could not find model.model-invariant-id given model-ver.model-version-id = "
+ modelVerId);
}
- Multimap <String, String> collectedMap = collectTopology4ModelVer( transId, fromAppId,
+ Multimap<String, String> collectedMap = collectTopology4ModelVer( transId, fromAppId,
firstElementVertex, "", initialEmptyMap, vidsTraversed, 0, null, firstModelInvId, firstModelVersion );
return collectedMap;
@@ -1686,7 +1676,7 @@ public class ModelBasedProcessing{
* @return HashMap of model-constraints that will be looked at for this model-element and what's "below" it.
* @throws AAIException the AAI exception
*/
- public Map<String, Vertex> getModConstraintHash( Vertex modelElementVtx, Map<String, Vertex> currentHash )
+ public Map<String, Vertex> getModConstraintHash(Vertex modelElementVtx, Map<String, Vertex> currentHash )
throws AAIException {
// For a given model-element vertex, look to see if there are any "model-constraint" elements that is has
@@ -1762,7 +1752,7 @@ public class ModelBasedProcessing{
* @return first element pointed to by this model-ver
* @throws AAIException the AAI exception
*/
- public Vertex getTopElementForSvcOrResModelVer( Vertex modelVerVtx, String trail )
+ public Vertex getTopElementForSvcOrResModelVer(Vertex modelVerVtx, String trail )
throws AAIException {
// For a "resource" or "service" type model, return the "top" element in that model
@@ -1819,8 +1809,8 @@ public class ModelBasedProcessing{
* @return HashMap of alternate properties to return for this element
* @throws AAIException the AAI exception
*/
- public Map<String,Object> getNamedQueryPropOverRide( String transId, String fromAppId,
- Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
+ public Map<String,Object> getNamedQueryPropOverRide(String transId, String fromAppId,
+ Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
throws AAIException {
// If this model-element says that they want an alternative set of properties returned, then pull that
@@ -1861,8 +1851,8 @@ public class ModelBasedProcessing{
* @return true - if a constraint was defined that has not been met by the passed instanceVertex
* @throws AAIException the AAI exception
*/
- public Boolean namedQueryConstraintSaysStop( String transId, String fromAppId,
- Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
+ public Boolean namedQueryConstraintSaysStop(String transId, String fromAppId,
+ Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
throws AAIException {
// For each (if any) property-constraint defined for this named-query-element, we will evaluate if
@@ -1943,8 +1933,8 @@ public class ModelBasedProcessing{
* @return HashMap of alternate properties to return for this element
* @throws AAIException the AAI exception
*/
- public Map<String,Object> getNamedQueryExtraDataLookup( String transId, String fromAppId,
- Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
+ public Map<String,Object> getNamedQueryExtraDataLookup(String transId, String fromAppId,
+ Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
throws AAIException {
// For each (if any) related-lookup defined for this named-query-element, we will go and
@@ -2053,10 +2043,10 @@ public class ModelBasedProcessing{
* @return HashMap of all widget-points on a namedQuery topology with the value being the "named-query-element-uuid" for that spot.
* @throws AAIException the AAI exception
*/
- public Map<String, String> collectNQElementHash( String transId, String fromAppId,
- Vertex thisLevelElemVtx, String incomingTrail,
- Map<String,String> currentHash, ArrayList <String> vidsTraversed,
- int levelCounter ) throws AAIException {
+ public Map<String, String> collectNQElementHash(String transId, String fromAppId,
+ Vertex thisLevelElemVtx, String incomingTrail,
+ Map<String,String> currentHash, ArrayList <String> vidsTraversed,
+ int levelCounter ) throws AAIException {
levelCounter++;
@@ -2064,7 +2054,7 @@ public class ModelBasedProcessing{
thisHash.putAll(currentHash);
if( levelCounter > MAX_LEVELS ) {
- throw new AAIException("AAI_6125", "collectNQElementHash() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
+ throw new AAIException("AAI_6125", "collectNQElementHash() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
String thisGuysTrail = "";
String thisElemVid = thisLevelElemVtx.id().toString();
@@ -2139,11 +2129,11 @@ public class ModelBasedProcessing{
* @return HashMap of all widget-points on a model topology with the value being the "newDataDelFlag" for that spot.
* @throws AAIException the AAI exception
*/
- public Map<String, String> collectDeleteKeyHash( String transId, String fromAppId,
- Vertex thisLevelElemVtx, String incomingTrail,
- Map<String,String> currentHash, ArrayList <String> vidsTraversed,
- int levelCounter, Map<String, Vertex> modConstraintHash,
- String overRideModelId, String overRideModelVersionId )
+ public Map<String, String> collectDeleteKeyHash(String transId, String fromAppId,
+ Vertex thisLevelElemVtx, String incomingTrail,
+ Map<String,String> currentHash, ArrayList <String> vidsTraversed,
+ int levelCounter, Map<String, Vertex> modConstraintHash,
+ String overRideModelId, String overRideModelVersionId )
throws AAIException {
levelCounter++;
@@ -2152,7 +2142,7 @@ public class ModelBasedProcessing{
thisHash.putAll(currentHash);
if( levelCounter > MAX_LEVELS ) {
- throw new AAIException("AAI_6125", "collectDeleteKeyHash() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
+ throw new AAIException("AAI_6125", "collectDeleteKeyHash() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
String thisGuysTrail = "";
String thisElemVid = thisLevelElemVtx.id().toString();
@@ -2374,14 +2364,14 @@ public class ModelBasedProcessing{
if( linkagePtList == null ){
String detail = " Bad (null) linkagePtList passed to getLinkageConnectNodeTypes() ";
- throw new AAIException("AAI_6125", detail);
+ throw new AAIException("AAI_6125", detail);
}
for( int i = 0; i < linkagePtList.size(); i++ ){
String [] trailSteps = linkagePtList.get(i).split("\\|");
if( trailSteps == null || trailSteps.length == 0 ){
String detail = " Bad incomingTrail passed to getLinkageConnectNodeTypes(): [" + linkagePtList + "] ";
- throw new AAIException("AAI_6125", detail);
+ throw new AAIException("AAI_6125", detail);
}
String lastStepNT = trailSteps[trailSteps.length - 1];
linkPtSet.add(lastStepNT);
@@ -2409,20 +2399,20 @@ public class ModelBasedProcessing{
* @return Map of the topology
* @throws AAIException the AAI exception
*/
- public Multimap<String, String> collectTopology4ModelVer( String transId, String fromAppId,
- Vertex thisLevelElemVtx, String incomingTrail,
- Multimap <String,String> currentMap, List<String> vidsTraversed,
- int levelCounter, Map<String, Vertex> modConstraintHash,
- String overRideModelInvId, String overRideModelVersionId )
+ public Multimap<String, String> collectTopology4ModelVer(String transId, String fromAppId,
+ Vertex thisLevelElemVtx, String incomingTrail,
+ Multimap<String,String> currentMap, List<String> vidsTraversed,
+ int levelCounter, Map<String, Vertex> modConstraintHash,
+ String overRideModelInvId, String overRideModelVersionId )
throws AAIException {
levelCounter++;
- Multimap <String, String> thisMap = ArrayListMultimap.create();
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
thisMap.putAll(currentMap);
if( levelCounter > MAX_LEVELS ) {
- throw new AAIException("AAI_6125", "collectTopology4ModelVer() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
+ throw new AAIException("AAI_6125", "collectTopology4ModelVer() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
String thisGuysTrail = "";
String thisElemVid = thisLevelElemVtx.id().toString();
@@ -2543,7 +2533,7 @@ public class ModelBasedProcessing{
// This is as far as we can go, we will use the linkage point info to define the
// rest of this "trail"
for( int i = 0; i < linkagePtList.size(); i++ ){
- Multimap<String, String> tmpMap = collectTopology4LinkagePoint( transId, fromAppId,
+ Multimap<String, String> tmpMap = collectTopology4LinkagePoint( transId, fromAppId,
linkagePtList.get(i), thisGuysTrail, currentMap);
thisMap.putAll(tmpMap);
}
@@ -2553,7 +2543,7 @@ public class ModelBasedProcessing{
thisMap.put(thisGuysTrail, tmpElStepName);
if( !thisTrailsVidsTraversed.contains(tmpElVid) ){
// This is one we would like to use - so we'll recursively get it's result set to add to ours
- Multimap<String, String> tmpMap = collectTopology4ModelVer( transId, fromAppId,
+ Multimap<String, String> tmpMap = collectTopology4ModelVer( transId, fromAppId,
elVert, thisGuysTrail,
currentMap, thisTrailsVidsTraversed, levelCounter,
modConstraintHash2Use, subModelFirstModInvId, subModelFirstModVerId );
@@ -2597,13 +2587,13 @@ public class ModelBasedProcessing{
loader.introspectorFromName(nodeTypeA);
} catch (AAIUnknownObjectException e) {
String emsg = " Unrecognized nodeType aa [" + nodeTypeA + "]\n";
- throw new AAIException("AAI_6115", emsg);
+ throw new AAIException("AAI_6115", emsg);
}
try {
loader.introspectorFromName(nodeTypeB);
} catch (AAIUnknownObjectException e) {
String emsg = " Unrecognized nodeType bb [" + nodeTypeB + "]\n";
- throw new AAIException("AAI_6115", emsg);
+ throw new AAIException("AAI_6115", emsg);
}
String msg = " No Edge Rule found for this pair of nodeTypes (order does not matter) ["
@@ -2627,11 +2617,11 @@ public class ModelBasedProcessing{
* @return Map of the topology
* @throws AAIException the AAI exception
*/
- public Multimap<String, String> collectTopology4LinkagePoint( String transId, String fromAppId,
- String linkagePointStrVal, String incomingTrail, Multimap <String,String> currentMap)
+ public Multimap<String, String> collectTopology4LinkagePoint(String transId, String fromAppId,
+ String linkagePointStrVal, String incomingTrail, Multimap<String,String> currentMap)
throws AAIException {
- Multimap <String, String> thisMap = ArrayListMultimap.create();
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
thisMap.putAll(currentMap);
String thisGuysTrail = incomingTrail;
@@ -2641,7 +2631,7 @@ public class ModelBasedProcessing{
String [] trailSteps = thisGuysTrail.split("\\|");
if( trailSteps == null || trailSteps.length == 0 ){
- throw new AAIException("AAI_6125", "Bad incomingTrail passed to collectTopology4LinkagePoint(): [" + incomingTrail + "] ");
+ throw new AAIException("AAI_6125", "Bad incomingTrail passed to collectTopology4LinkagePoint(): [" + incomingTrail + "] ");
}
String lastStepString = trailSteps[trailSteps.length - 1];
String [] stepPieces = lastStepString.split(",");
@@ -2666,7 +2656,7 @@ public class ModelBasedProcessing{
String thisStepNT = "";
String [] linkageSteps = linkage[x].split("\\|");
if( linkageSteps == null || linkageSteps.length == 0 ){
- throw new AAIException("AAI_6125", "Bad linkagePointStr passed to collectTopology4LinkagePoint(): [" + linkagePointStr + "] ");
+ throw new AAIException("AAI_6125", "Bad linkagePointStr passed to collectTopology4LinkagePoint(): [" + linkagePointStr + "] ");
}
for( int i=(linkageSteps.length - 1); i >= 0; i-- ){
thisStepNT = linkageSteps[i];
@@ -2688,7 +2678,7 @@ public class ModelBasedProcessing{
* @return Hash of the set of model-elements this set represents
* @throws AAIException the AAI exception
*/
- public Map<String,Object> getNextStepElementsFromSet( Vertex constrElemSetVtx )
+ public Map<String,Object> getNextStepElementsFromSet( Vertex constrElemSetVtx )
throws AAIException {
// Take a constrained-element-set and figure out the total set of all the possible elements that it
// represents and return them as a Hash.
@@ -2767,15 +2757,15 @@ public class ModelBasedProcessing{
* @return MultiMap of valid next steps for each potential query-element
* @throws AAIException the AAI exception
*/
- public Multimap<String, String> genTopoMap4NamedQ( String transId, String fromAppId,
- Vertex queryVertex, String namedQueryUuid )
+ public Multimap<String, String> genTopoMap4NamedQ(String transId, String fromAppId,
+ Vertex queryVertex, String namedQueryUuid )
throws AAIException {
if( queryVertex == null ){
throw new AAIException("AAI_6125", "null queryVertex passed to genTopoMap4NamedQ()");
}
- Multimap <String, String> initialEmptyMap = ArrayListMultimap.create();
+ Multimap<String, String> initialEmptyMap = ArrayListMultimap.create();
List<String> vidsTraversed = new ArrayList<>();
Vertex firstElementVertex = null;
@@ -2797,11 +2787,11 @@ public class ModelBasedProcessing{
Vertex modVtx = getModelThatNqElementRepresents( firstElementVertex, "" );
String modelType = getModelTypeFromModel( modVtx, "" );
if( ! modelType.equals("widget") ){
- throw new AAIException("AAI_6133", "Bad Named Query Definition: First element must correspond to a widget type model. Named Query UUID = "
+ throw new AAIException("AAI_6133", "Bad Named Query Definition: First element must correspond to a widget type model. Named Query UUID = "
+ namedQueryUuid);
}
- Multimap <String, String> collectedMap = collectTopology4NamedQ( transId, fromAppId,
+ Multimap<String, String> collectedMap = collectTopology4NamedQ( transId, fromAppId,
firstElementVertex, "",
initialEmptyMap, vidsTraversed, 0);
@@ -2821,19 +2811,19 @@ public class ModelBasedProcessing{
* @return resultSet
* @throws AAIException the AAI exception
*/
- public Multimap<String, String> collectTopology4NamedQ( String transId, String fromAppId,
- Vertex thisLevelElemVtx, String incomingTrail,
- Multimap <String,String> currentMap, List<String> vidsTraversed, int levelCounter )
+ public Multimap<String, String> collectTopology4NamedQ(String transId, String fromAppId,
+ Vertex thisLevelElemVtx, String incomingTrail,
+ Multimap<String,String> currentMap, List<String> vidsTraversed, int levelCounter )
throws AAIException {
levelCounter++;
- Multimap <String, String> thisMap = ArrayListMultimap.create();
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
thisMap.putAll(currentMap);
String thisElemVid = thisLevelElemVtx.id().toString();
if( levelCounter > MAX_LEVELS ) {
- throw new AAIException("AAI_6125", "collectModelStructure() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
+ throw new AAIException("AAI_6125", "collectModelStructure() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
String thisGuysTrail = "";
@@ -2859,7 +2849,7 @@ public class ModelBasedProcessing{
thisMap.put(thisGuysTrail, tmpElNT);
if( !vidsTraversed.contains(tmpVid) ){
// This is one we would like to use - so we'll recursively get it's result set to add to ours
- Multimap<String, String> tmpMap = collectTopology4NamedQ( transId, fromAppId,
+ Multimap<String, String> tmpMap = collectTopology4NamedQ( transId, fromAppId,
tmpVert, thisGuysTrail,
currentMap, vidsTraversed, levelCounter);
thisMap.putAll(tmpMap);
@@ -2879,7 +2869,7 @@ public class ModelBasedProcessing{
* @return the model that element represents
* @throws AAIException the AAI exception
*/
- public Vertex getModelThatNqElementRepresents( Vertex elementVtx, String elementTrail )
+ public Vertex getModelThatNqElementRepresents(Vertex elementVtx, String elementTrail )
throws AAIException {
// Get the model that a named-query element represents
@@ -2926,7 +2916,7 @@ public class ModelBasedProcessing{
* @return the model-ver that element represents
* @throws AAIException the AAI exception
*/
- public Vertex getModelVerThatElementRepresents( Vertex elementVtx, String elementTrail )
+ public Vertex getModelVerThatElementRepresents(Vertex elementVtx, String elementTrail )
throws AAIException {
// Get the model-ver that an element represents
@@ -2974,7 +2964,7 @@ public class ModelBasedProcessing{
* @return the model that element represents
* @throws AAIException the AAI exception
*/
- public Vertex getModelGivenModelVer( Vertex modVerVtx, String elementTrail )
+ public Vertex getModelGivenModelVer(Vertex modVerVtx, String elementTrail )
throws AAIException {
// Get the parent model for this "model-ver" node
@@ -3025,7 +3015,7 @@ public class ModelBasedProcessing{
* @return the model type
* @throws AAIException the AAI exception
*/
- public String getModelTypeFromModel( Vertex modelVtx, String elementTrail )
+ public String getModelTypeFromModel(Vertex modelVtx, String elementTrail )
throws AAIException {
// Get the model-type from a model vertex
@@ -3059,7 +3049,7 @@ public class ModelBasedProcessing{
* @return the model type
* @throws AAIException the AAI exception
*/
- public String getModelTypeFromModelVer( Vertex modelVerVtx, String elementTrail )
+ public String getModelTypeFromModelVer(Vertex modelVerVtx, String elementTrail )
throws AAIException {
// Get the model-type given a model-ver vertex
@@ -3095,7 +3085,7 @@ public class ModelBasedProcessing{
* @return the element step name
* @throws AAIException the AAI exception
*/
- public String getModelElementStepName( Vertex elementVtx, String elementTrail)
+ public String getModelElementStepName(Vertex elementVtx, String elementTrail)
throws AAIException {
// Get the "step name" for a model-element
@@ -3195,8 +3185,8 @@ public class ModelBasedProcessing{
* @return the element widget type
* @throws AAIException the AAI exception
*/
- public String getNqElementWidgetType( String transId, String fromAppId,
- Vertex elementVtx, String elementTrail )
+ public String getNqElementWidgetType(String transId, String fromAppId,
+ Vertex elementVtx, String elementTrail )
throws AAIException {
String thisNqElementWidgetType = "";
@@ -3209,7 +3199,7 @@ public class ModelBasedProcessing{
if( modelType == null || !modelType.equals("widget") ){
String emsg = " Model Type must be 'widget' for NamedQuery elements. Found [" + modelType + "] at [" +
elementTrail + "]\n";
- throw new AAIException("AAI_6132", emsg);
+ throw new AAIException("AAI_6132", emsg);
}
else {
// For a Widget model, the nodeType is just mapped to the model-element.model-name
@@ -3219,7 +3209,7 @@ public class ModelBasedProcessing{
}
if( thisNqElementWidgetType == null || thisNqElementWidgetType.equals("") ){
String emsg = " Widget type could not be determined at [" + elementTrail + "]\n";
- throw new AAIException("AAI_6132", emsg);
+ throw new AAIException("AAI_6132", emsg);
}
else {
return thisNqElementWidgetType;
@@ -3238,7 +3228,7 @@ public class ModelBasedProcessing{
* @return the element widget type
* @throws AAIException the AAI exception
*/
- public String getModElementWidgetType( Vertex elementVtx, String elementTrail )
+ public String getModElementWidgetType(Vertex elementVtx, String elementTrail )
throws AAIException {
// Get the associated node-type for the model-ver pointed to by a model-element.
@@ -3262,27 +3252,27 @@ public class ModelBasedProcessing{
* @return unique vertex found using UUID
* @throws AAIException the AAI exception
*/
- public Vertex getNodeUsingUniqueId( String transId, String fromAppId,
- String nodeType, String idPropertyName, String uniqueIdVal )
+ public Vertex getNodeUsingUniqueId(String transId, String fromAppId,
+ String nodeType, String idPropertyName, String uniqueIdVal )
throws AAIException {
// Given a unique identifier, get the Vertex
if( uniqueIdVal == null || uniqueIdVal.equals("") ){
String emsg = " Bad uniqueIdVal passed to getNodeUsingUniqueId(): ["
+ uniqueIdVal + "]\n";
- throw new AAIException("AAI_6118", emsg);
+ throw new AAIException("AAI_6118", emsg);
}
if( idPropertyName == null || idPropertyName.equals("") ){
String emsg = " Bad idPropertyName passed to getNodeUsingUniqueId(): ["
+ idPropertyName + "]\n";
- throw new AAIException("AAI_6118", emsg);
+ throw new AAIException("AAI_6118", emsg);
}
if( nodeType == null || nodeType.equals("") ){
String emsg = " Bad nodeType passed to getNodeUsingUniqueId(): ["
+ nodeType + "]\n";
- throw new AAIException("AAI_6118", emsg);
+ throw new AAIException("AAI_6118", emsg);
}
Vertex uniqVtx = null;
@@ -3292,7 +3282,7 @@ public class ModelBasedProcessing{
String emsg = "Node could not be found for nodeType = [" + nodeType
+ "], propertyName = [" + idPropertyName
+ "], propertyValue = [" + uniqueIdVal + "]\n";
- throw new AAIException("AAI_6114", emsg);
+ throw new AAIException("AAI_6114", emsg);
}
else {
int count = 0;
@@ -3301,7 +3291,7 @@ public class ModelBasedProcessing{
String emsg = "Node could not be found for nodeType = [" + nodeType
+ "], propertyName = [" + idPropertyName
+ "], propertyValue = [" + uniqueIdVal + "]\n";
- throw new AAIException("AAI_6114", emsg);
+ throw new AAIException("AAI_6114", emsg);
}
else {
while( uniqVertsIter.hasNext() ){
@@ -3311,7 +3301,7 @@ public class ModelBasedProcessing{
String emsg = "More than one node found for nodeType = [" + nodeType
+ "], propertyName = [" + idPropertyName
+ "], propertyValue = [" + uniqueIdVal + "]\n";
- throw new AAIException("AAI_6132", emsg);
+ throw new AAIException("AAI_6132", emsg);
}
}
}
@@ -3330,15 +3320,15 @@ public class ModelBasedProcessing{
* @return the model-ver's that use this name
* @throws AAIException the AAI exception
*/
- public List<Vertex> getModelVersUsingName( String transId, String fromAppId,
- String modelName )
+ public List<Vertex> getModelVersUsingName(String transId, String fromAppId,
+ String modelName )
throws AAIException {
// Given a "model-name", find the model-ver vertices that this maps to
if( modelName == null || modelName.equals("") ){
String emsg = " Bad modelName passed to getModelVersUsingName(): ["
+ modelName + "]\n";
- throw new AAIException("AAI_6118", emsg);
+ throw new AAIException("AAI_6118", emsg);
}
List<Vertex> retVtxArr = new ArrayList<>();
@@ -3346,7 +3336,7 @@ public class ModelBasedProcessing{
if( !modVertsIter.hasNext() ){
String emsg = "Model-ver record(s) could not be found for model-ver data passed. model-name = [" +
modelName + "]\n";
- throw new AAIException("AAI_6132", emsg);
+ throw new AAIException("AAI_6132", emsg);
}
else {
while( modVertsIter.hasNext() ){
@@ -3369,15 +3359,15 @@ public class ModelBasedProcessing{
* @return the model-ver's defined for the corresponding model
* @throws AAIException the AAI exception
*/
- public Iterator<Vertex> getModVersUsingModelInvId( String transId, String fromAppId,
- String modelInvId )
+ public Iterator<Vertex> getModVersUsingModelInvId(String transId, String fromAppId,
+ String modelInvId )
throws AAIException {
// Given a "model-invariant-id", find the model-ver nodes that this maps to
if( modelInvId == null || modelInvId.equals("") ){
String emsg = " Bad model-invariant-id passed to getModVersUsingModelInvId(): ["
+ modelInvId + "]\n";
- throw new AAIException("AAI_6118", emsg);
+ throw new AAIException("AAI_6118", emsg);
}
Vertex modVtx = getNodeUsingUniqueId(transId, fromAppId, "model", "model-invariant-id", modelInvId);
@@ -3385,7 +3375,7 @@ public class ModelBasedProcessing{
if( retVtxArr == null || retVtxArr.isEmpty() ){
String emsg = " Model-ver record(s) could not be found attached to model with model-invariant-id = [" +
modelInvId + "]\n";
- throw new AAIException("AAI_6132", emsg);
+ throw new AAIException("AAI_6132", emsg);
}
return retVtxArr.iterator();
@@ -3401,13 +3391,13 @@ public class ModelBasedProcessing{
* @return the model-ver's defined for the corresponding model
* @throws AAIException the AAI exception
*/
- public List<Vertex> getModVersUsingModel( String transId, String fromAppId,
- Vertex modVtx )
+ public List<Vertex> getModVersUsingModel(String transId, String fromAppId,
+ Vertex modVtx )
throws AAIException {
if( modVtx == null ){
String emsg = " Null model vertex passed to getModVersUsingModel(): ";
- throw new AAIException("AAI_6118", emsg);
+ throw new AAIException("AAI_6118", emsg);
}
List<Vertex> retVtxArr = new ArrayList<>();
@@ -3416,7 +3406,7 @@ public class ModelBasedProcessing{
String modelInvId = modVtx.<String>property("model-invariant-id").orElse(null);
String emsg = "Model-ver record(s) could not be found attached to model with model-invariant-id = [" +
modelInvId + "]\n";
- throw new AAIException("AAI_6132", emsg);
+ throw new AAIException("AAI_6132", emsg);
}
else {
while( modVerVertsIter.hasNext() ){
@@ -3446,7 +3436,7 @@ public class ModelBasedProcessing{
if( modelName == null || modelName.equals("") ){
String emsg = " Bad modelName passed to getModelVerIdsUsingName(): ["
+ modelName + "]\n";
- throw new AAIException("AAI_6118", emsg);
+ throw new AAIException("AAI_6118", emsg);
}
List<String> retArr = new ArrayList<>();
@@ -3454,7 +3444,7 @@ public class ModelBasedProcessing{
if( !modVerVertsIter.hasNext() ){
String emsg = " model-ver record(s) could not be found for model data passed. model-name = [" +
modelName + "]\n";
- throw new AAIException("AAI_6114", emsg);
+ throw new AAIException("AAI_6114", emsg);
}
else {
while( modVerVertsIter.hasNext() ){
@@ -3469,7 +3459,7 @@ public class ModelBasedProcessing{
if( retArr.isEmpty() ){
String emsg = "No model-ver record found for model-name = ["
+ modelName + "]\n";
- throw new AAIException("AAI_6132", emsg);
+ throw new AAIException("AAI_6132", emsg);
}
return retArr;
@@ -3516,14 +3506,14 @@ public class ModelBasedProcessing{
if( !modVerVertsIter.hasNext() ){
String emsg = "model-ver record(s) could not be found for model data passed: modelInvariantId = [" + modelInvId +
"], modeVersionId = [" + modelVersionId + "], modelName = [" + modelName + "]\n";
- throw new AAIException("AAI_6114", emsg);
+ throw new AAIException("AAI_6114", emsg);
}
else {
String lastNT = "";
if( !modVerVertsIter.hasNext() ){
String emsg = "model-ver record(s) could not be found for model data passed: modelInvariantId = [" + modelInvId +
"], modeVersionId = [" + modelVersionId + "], modelName = [" + modelName + "]\n";
- throw new AAIException("AAI_6114", emsg);
+ throw new AAIException("AAI_6114", emsg);
}
while( modVerVertsIter.hasNext() ){
Vertex tmpModVerVtx = (Vertex) modVerVertsIter.next();
@@ -3536,7 +3526,7 @@ public class ModelBasedProcessing{
"], modelId = [" + modelInvId +
"], modelName = [" + modelName +
"])\n";
- throw new AAIException("AAI_6114", emsg);
+ throw new AAIException("AAI_6114", emsg);
}
}
lastNT = tmpNT;
@@ -3557,7 +3547,7 @@ public class ModelBasedProcessing{
* @return the widget type of the starting node of this model
* @throws AAIException the AAI exception
*/
- public String getModelVerTopWidgetType( Vertex modVerVtx, String elementTrail )
+ public String getModelVerTopWidgetType(Vertex modVerVtx, String elementTrail )
throws AAIException {
// Get the associated nodeType (Ie. aai-node-type / widget-type) for a model-ver.
// NOTE -- if the element points to a resource or service model, then we'll return the
@@ -3608,11 +3598,11 @@ public class ModelBasedProcessing{
* @throws AAIException the AAI exception
*/
public void validateModel(String transId, String fromAppId, String modelVersionIdVal, String apiVersion )
- throws AAIException{
+ throws AAIException {
// Note - this will throw an exception if the model either can't be found, or if
// we can't figure out its topology map.
- Vertex modelVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
+ Vertex modelVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
"model-version-id", modelVersionIdVal);
if( modelVerVtx == null ){
String msg = " Could not find model-ver with modelVersionId = [" + modelVersionIdVal + "].";
@@ -3639,11 +3629,11 @@ public class ModelBasedProcessing{
* @throws AAIException the AAI exception
*/
public void validateNamedQuery(String transId, String fromAppId, String namedQueryUuid, String apiVersion )
- throws AAIException{
+ throws AAIException {
// Note - this will throw an exception if the named query either can't be found, or if
// we can't figure out its topology map.
- Vertex nqVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query",
+ Vertex nqVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query",
"named-query-uuid", namedQueryUuid);
if( nqVtx == null ){
@@ -3667,7 +3657,7 @@ public class ModelBasedProcessing{
* @param resSet the res set
* @param levelCount the level count
*/
- public void showResultSet( ResultSet resSet, int levelCount ) {
+ public void showResultSet(ResultSet resSet, int levelCount ) {
levelCount++;
String propsStr = "";
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 ab986a2..f140bcd 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
@@ -1063,37 +1063,28 @@ public class SearchGraph {
String modelName = null;
try {
+ // Try to get the modelName if we can. Otherwise, do not fail, just return what we have already.
String modelInvariantIdLocal = (String)vert.<String>property("model-invariant-id-local").orElse(null); // this one points at a model
String modelVersionIdLocal = (String)vert.<String>property("model-version-id-local").orElse(null); // this one points at a model-ver
if ( (modelInvariantIdLocal != null && modelVersionIdLocal != null)
&& (modelInvariantIdLocal.length() > 0 && modelVersionIdLocal.length() > 0) ) {
- HashMap<String,Object> modelLookupHash = new HashMap<String,Object>();
-
Introspector modelVer = loader.introspectorFromName("model-ver");
modelVer.setValue("model-version-id", modelVersionIdLocal);
QueryBuilder builder = engine.getQueryBuilder().createDBQuery(modelVer);
-
List<Vertex> modelVerVerts = builder.toList();
- if (modelVerVerts.size() != 1) {
- throw new AAIException("AAI_6112");
- }
- Vertex modelVerVert = modelVerVerts.get(0);
-
- modelName = modelVerVert.<String>property("model-name").orElse(null);
-
- if (modelName != null && modelName.length() > 0) {
- inventoryItem.setValue("model-name", modelName);
+ if( (modelVerVerts != null) && (modelVerVerts.size() == 1) ) {
+ Vertex modelVerVert = modelVerVerts.get(0);
+ modelName = modelVerVert.<String>property("model-name").orElse(null);
+ if (modelName != null && modelName.length() > 0) {
+ inventoryItem.setValue("model-name", modelName);
+ }
}
}
} catch (DynamicException e) {
; // it's ok, dynamic object might not have these fields
- } catch (AAIException e) {
- if (e.getErrorObject().getErrorCode().equals("6114")) {
- // it's ok, couldn't find a matching model
- } else {
- throw e;
- }
+ } catch (Exception e) {
+ ; // it's ok, couldn't find a matching model
}
if (resultSet.getSubResultSet() != null) {
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java
index 30382e4..1849b10 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java
@@ -48,16 +48,18 @@ public class PostAaiAjscInterceptor implements AjscInterceptor {
@Override
public boolean allowOrReject(HttpServletRequest req, HttpServletResponse resp, Map<?, ?> paramMap)
throws Exception {
- final String responseCode = LoggingContext.responseCode();
-
- if (responseCode != null && responseCode.startsWith("ERR.")) {
+ final int httpStatusCode = resp.getStatus();
+ LoggingContext.responseCode(Integer.toString(httpStatusCode));
+ if ( httpStatusCode < 200 || httpStatusCode > 299 ) {
LoggingContext.statusCode(StatusCode.ERROR);
- LOGGER.error(req.getRequestURL() + " call failed with responseCode=" + responseCode);
- } else {
+ LoggingContext.responseDescription("Error");
+ LOGGER.error(req.getRequestURL() + " call failed with responseCode=" + httpStatusCode);
+ }
+ else {
+ LoggingContext.responseDescription(LoggingContext.responseMap.get(LoggingContext.SUCCESS));
LoggingContext.statusCode(StatusCode.COMPLETE);
LOGGER.info(req.getRequestURL() + " call succeeded");
}
-
LoggingContext.clear();
return true;
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java
index 7d1ae73..b510d4b 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java
@@ -31,6 +31,7 @@ import org.onap.aai.logging.LoggingContext;
import ajsc.beans.interceptors.AjscInterceptor;
public class PreAaiAjscInterceptor implements AjscInterceptor {
+ private final static String TARGET_ENTITY = "aai-traversal";
private static class LazyAaiAjscInterceptor {
public static final PreAaiAjscInterceptor INSTANCE = new PreAaiAjscInterceptor();
@@ -46,10 +47,17 @@ public class PreAaiAjscInterceptor implements AjscInterceptor {
LoggingContext.init();
- LoggingContext.requestId(req.getHeader("X-TransactionId"));
+ String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
LoggingContext.partnerName(req.getHeader("X-FromAppId"));
- LoggingContext.serviceName(req.getMethod() + " " + req.getRequestURI().toString());
-
+ String queryStr = req.getQueryString();
+ if ( queryStr != null ) {
+ serviceName = serviceName + "?" + queryStr;
+ }
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName("allowOrReject");
+ LoggingContext.requestId(req.getHeader("X-TransactionId"));
+ LoggingContext.successStatusFields();
return true;
}
}
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 1f4f359..57e4188 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
@@ -7,9 +7,9 @@
* 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.
@@ -23,10 +23,11 @@ package org.onap.aai.rest;
import java.net.URI;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.Callable;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
@@ -67,10 +68,16 @@ import org.onap.aai.serialization.queryformats.Format;
import org.onap.aai.serialization.queryformats.FormatFactory;
import org.onap.aai.serialization.queryformats.Formatter;
import org.onap.aai.serialization.queryformats.SubGraphStyle;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
+import org.onap.aai.logging.StopWatch;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import org.onap.aai.util.AAIConstants;
@Path("{version: v9|v1[012]}/query")
public class QueryConsumer extends RESTAPI {
@@ -83,11 +90,32 @@ public class QueryConsumer extends RESTAPI {
private QueryProcessorType processorType = QueryProcessorType.LOCAL_GROOVY;
/** The query style. */
private QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+
+ private static final String TARGET_ENTITY = "DB";
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(QueryConsumer.class);
+
@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){
+ return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ headers,
+ info,
+ HttpMethod.GET,
+ new Callable<Response>() {
+ @Override
+ public Response call() {
+ return processExecuteQuery(content, versionParam, uri, queryFormat, subgraph, headers, info, 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) {
+
+ String methodName = "executeQuery";
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
String queryProcessor = headers.getRequestHeaders().getFirst("QueryProcessor");
@@ -95,6 +123,7 @@ public class QueryConsumer extends RESTAPI {
Response response = null;
TransactionalGraphEngine dbEngine = null;
try {
+ LoggingContext.save();
this.checkQueryParams(info.getQueryParameters());
Format format = Format.valueOf(queryFormat);
if (queryProcessor != null) {
@@ -108,9 +137,11 @@ public class QueryConsumer extends RESTAPI {
JsonElement startElement = input.get("start");
JsonElement queryElement = input.get("query");
JsonElement gremlinElement = input.get("gremlin");
+ JsonElement dslElement = input.get("dsl");
List<URI> startURIs = new ArrayList<>();
String queryURI = "";
String gremlin = "";
+ String dsl = "";
Version version = Version.valueOf(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
@@ -133,6 +164,9 @@ public class QueryConsumer extends RESTAPI {
if (gremlinElement != null) {
gremlin = gremlinElement.getAsString();
}
+ if (dslElement != null) {
+ dsl = dslElement.getAsString();
+ }
URI queryURIObj = new URI(queryURI);
CustomQueryConfig customQueryConfig = getCustomQueryConfig(queryURIObj);
@@ -148,6 +182,11 @@ public class QueryConsumer extends RESTAPI {
GenericQueryProcessor processor = null;
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(methodName);
+ LoggingContext.startTime();
+ StopWatch.conditionalStart();
+
if (!startURIs.isEmpty()) {
Set<Vertex> vertexSet = new LinkedHashSet<>();
QueryParser uriQuery;
@@ -165,13 +204,18 @@ public class QueryConsumer extends RESTAPI {
processor = new GenericQueryProcessor.Builder(dbEngine)
.queryFrom(queryURIObj)
.processWith(processorType).create();
- } else {
+ } else if(!dsl.equals("")){
+ processor = new GenericQueryProcessor.Builder(dbEngine)
+ .queryFrom(dsl, "dsl")
+ .processWith(processorType).create();
+ }else {
processor = new GenericQueryProcessor.Builder(dbEngine)
- .queryFrom(gremlin)
+ .queryFrom(gremlin, "gremlin")
.processWith(processorType).create();
}
String result = "";
List<Object> vertices = processor.execute(subGraphStyle);
+
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
FormatFactory ff = new FormatFactory(httpEntry.getLoader(), serializer);
@@ -179,6 +223,12 @@ public class QueryConsumer extends RESTAPI {
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();
@@ -187,12 +237,14 @@ public class QueryConsumer extends RESTAPI {
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e);
} catch (Exception e ) {
AAIException ex = new AAIException("AAI_4000", e);
-
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex);
} finally {
+ LoggingContext.restoreIfPossible();
+ LoggingContext.successStatusFields();
if (dbEngine != null) {
dbEngine.rollback();
}
+
}
return response;
@@ -213,10 +265,8 @@ public class QueryConsumer extends RESTAPI {
private List<String> checkForMissingQueryParameters( List<String> requiredParameters, MultivaluedMap<String, String> queryParams ) {
List<String> result = new ArrayList<>();
- Iterator it = requiredParameters.iterator();
- String param;
- while(it.hasNext()) {
- param = (String)it.next();
+
+ for ( String param : requiredParameters ) {
if ( !queryParams.containsKey(param)) {
result.add(param);
}
@@ -254,16 +304,12 @@ public class QueryConsumer extends RESTAPI {
if (templateVars.isEmpty()) {
templateVars.add(missingRequiredQueryParams.toString());
}
- Status s = e.getErrorObject().getHTTPResponseCode();
- String errorResponse = ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
- templateVars);
- Response response = Response.status(s).entity(errorResponse).build();
- /*
+
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/dsl/DslListener.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java
new file mode 100644
index 0000000..0685674
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java
@@ -0,0 +1,306 @@
+/**
+ * ============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.dsl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+
+import org.antlr.v4.runtime.tree.TerminalNode;
+
+import org.onap.aai.AAIDslParser;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.AAIDslBaseListener;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+/**
+ * The Class DslListener.
+ */
+public class DslListener extends AAIDslBaseListener {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DslQueryProcessor.class);
+ private final EdgeRules edgeRules = EdgeRules.getInstance();
+
+ protected List<String> list = null;
+ //TODO Use StringBuilder to build the query than concat
+ String query = "";
+
+ Map<Integer, String> unionMap = new HashMap<>();
+ Map<String, String> flags = new HashMap<>();
+
+ String currentNode = "";
+ String prevsNode = "";
+ int commas = 0;
+
+ int unionKey = 0;
+ int unionMembers = 0;
+ boolean isUnionBeg = false;
+ boolean isUnionTraversal = false;
+
+ boolean isTraversal = false;
+ boolean isWhereTraversal = false;
+ String whereTraversalNode = "";
+
+ String limitQuery = "";
+ boolean isNot = false;
+
+ /**
+ * Instantiates a new DslListener.
+ */
+
+ public DslListener() {
+ list = new ArrayList<>();
+ }
+
+ @Override
+ public void enterAaiquery(AAIDslParser.AaiqueryContext ctx) {
+ query += "builder";
+ }
+
+ @Override
+ public void enterDslStatement(AAIDslParser.DslStatementContext ctx) {
+ // LOGGER.info("Statement Enter"+ctx.getText());
+ /*
+ * This block of code is entered for every query statement
+ */
+ if (isUnionBeg) {
+ isUnionBeg = false;
+ isUnionTraversal = true;
+
+ } else if (unionMembers > 0) {
+ unionMembers--;
+ query += ",builder.newInstance()";
+ isUnionTraversal = true;
+ }
+
+ }
+
+ @Override
+ public void exitDslStatement(AAIDslParser.DslStatementContext ctx) {
+ /*
+ * Nothing to be done here for now
+ * LOGGER.info("Statement Exit"+ctx.getText());
+ */
+ }
+
+ @Override
+ public void exitAaiquery(AAIDslParser.AaiqueryContext ctx) {
+ /*
+ * dedup is by default for all queries If the query has limit in it
+ * include this as well LOGGER.info("Statement Exit"+ctx.getText());
+ */
+
+ query += ".cap('x').unfold().dedup()" + limitQuery;
+ }
+
+ /*
+ * TODO: The contexts are not inherited from a single parent in AAIDslParser
+ * Need to find a way to do that
+ */
+ @Override
+ public void enterSingleNodeStep(AAIDslParser.SingleNodeStepContext ctx) {
+
+ prevsNode = currentNode;
+ currentNode = ctx.NODE().getText();
+
+ this.generateQuery();
+ if (ctx.STORE() != null && ctx.STORE().getText().equals("*")) {
+ flags.put(currentNode, "store");
+ }
+
+ }
+
+ @Override
+ public void enterSingleQueryStep(AAIDslParser.SingleQueryStepContext ctx) {
+
+ prevsNode = currentNode;
+ currentNode = ctx.NODE().getText();
+ this.generateQuery();
+
+ if (ctx.STORE() != null && ctx.STORE().getText().equals("*")) {
+ flags.put(currentNode, "store");
+ }
+ }
+
+ @Override
+ public void enterMultiQueryStep(AAIDslParser.MultiQueryStepContext ctx) {
+
+ prevsNode = currentNode;
+ currentNode = ctx.NODE().getText();
+ this.generateQuery();
+
+ if (ctx.STORE() != null && ctx.STORE().getText().equals("*")) {
+ flags.put(currentNode, "store");
+ }
+
+ }
+
+ /*
+ * Generates the QueryBuilder syntax for the dsl query
+ */
+ private void generateQuery() {
+ String edgeType = "";
+
+ if (isUnionTraversal || isTraversal || isWhereTraversal) {
+ String previousNode = prevsNode;
+ if (isUnionTraversal) {
+ previousNode = unionMap.get(unionKey);
+ isUnionTraversal = false;
+ }
+
+ if (edgeRules.hasTreeEdgeRule(previousNode, currentNode)) {
+ edgeType = "EdgeType.TREE";
+ }else if (edgeRules.hasCousinEdgeRule(previousNode, currentNode, "")) {
+ edgeType = "EdgeType.COUSIN";
+ } else
+ edgeType = "EdgeType.COUSIN";
+
+ query += ".createEdgeTraversal(" + edgeType + ", '" + previousNode + "','" + currentNode + "')";
+
+ }
+
+ else
+ query += ".getVerticesByProperty('aai-node-type', '" + currentNode + "')";
+ }
+
+ @Override
+ public void exitSingleNodeStep(AAIDslParser.SingleNodeStepContext ctx) {
+
+ generateExitStep();
+ }
+
+ @Override
+ public void exitSingleQueryStep(AAIDslParser.SingleQueryStepContext ctx) {
+ generateExitStep();
+ }
+
+ @Override
+ public void exitMultiQueryStep(AAIDslParser.MultiQueryStepContext ctx) {
+ generateExitStep();
+
+ }
+
+ private void generateExitStep() {
+ if (flags.containsKey(currentNode)) {
+ String storeFlag = flags.get(currentNode);
+ if (storeFlag != null && storeFlag.equals("store"))
+ query += ".store('x')";
+ flags.remove(currentNode);
+ }
+ }
+
+ @Override
+ public void enterUnionQueryStep(AAIDslParser.UnionQueryStepContext ctx) {
+ isUnionBeg = true;
+
+ unionKey++;
+ unionMap.put(unionKey, currentNode);
+ query += ".union(builder.newInstance()";
+
+ List<TerminalNode> commaNodes = ctx.COMMA();
+
+ for (TerminalNode node : commaNodes) {
+ unionMembers++;
+ }
+ }
+
+ @Override
+ public void exitUnionQueryStep(AAIDslParser.UnionQueryStepContext ctx) {
+ isUnionBeg = false;
+ unionMap.remove(unionKey);
+
+ query += ")";
+ unionKey--;
+
+ }
+
+ @Override
+ public void enterFilterTraverseStep(AAIDslParser.FilterTraverseStepContext ctx) {
+ isWhereTraversal = true;
+ whereTraversalNode = currentNode;
+ query += ".where(builder.newInstance()";
+ }
+
+ @Override
+ public void exitFilterTraverseStep(AAIDslParser.FilterTraverseStepContext ctx) {
+ query += ")";
+ isWhereTraversal = false;
+ currentNode = whereTraversalNode;
+ }
+
+ @Override
+ public void enterFilterStep(AAIDslParser.FilterStepContext ctx) {
+ if (ctx.NOT() != null && ctx.NOT().getText().equals("!"))
+ isNot = true;
+
+ List<TerminalNode> nodes = ctx.KEY();
+ String key = ctx.KEY(0).getText();
+
+ if (isNot) {
+ query += ".getVerticesExcludeByProperty(";
+ isNot = false;
+ } else
+ query += ".getVerticesByProperty(";
+
+ if (nodes.size() == 2) {
+ query += key + "," + ctx.KEY(1).getText();
+ query += ")";
+ }
+
+ if (nodes.size() > 2) {
+
+ for (TerminalNode node : nodes) {
+ if (node.getText().equals(key))
+ continue;
+
+ query += key + "," + node.getText();
+ query += ")";
+ }
+
+ }
+
+ }
+
+ @Override
+ public void exitFilterStep(AAIDslParser.FilterStepContext ctx) {
+ // For now do nothing
+ }
+
+ @Override
+ public void enterTraverseStep(AAIDslParser.TraverseStepContext ctx) {
+ isTraversal = true;
+ }
+
+ @Override
+ public void exitTraverseStep(AAIDslParser.TraverseStepContext ctx) {
+ isTraversal = false;
+ }
+
+ @Override
+ public void enterLimitStep(AAIDslParser.LimitStepContext ctx) {
+ String value = ctx.NODE().getText();
+ limitQuery += ".limit(" + value + ")";
+ }
+}
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
new file mode 100644
index 0000000..f88f8c0
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java
@@ -0,0 +1,99 @@
+/**
+ * ============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.dsl;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+
+import org.antlr.v4.runtime.CharStreams;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+
+import org.onap.aai.AAIDslLexer;
+import org.onap.aai.AAIDslParser;
+
+import org.onap.aai.rest.dsl.DslListener;
+import org.antlr.v4.runtime.Token;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+/**
+ * The Class DslQueryProcessor.
+ */
+public class DslQueryProcessor {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DslQueryProcessor.class);
+
+ public String parseAaiQuery(String aaiQuery) {
+ try {
+ // Create a input stream that reads our string
+ InputStream stream = new ByteArrayInputStream(aaiQuery.getBytes(StandardCharsets.UTF_8));
+
+ // Create a lexer from the input CharStream
+ AAIDslLexer lexer = new AAIDslLexer(CharStreams.fromStream(stream, StandardCharsets.UTF_8));
+
+ // 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);
+
+ // Specify our entry point
+ ParseTree ptree = parser.aaiquery();
+ LOGGER.info("QUERY-interim" + ptree.toStringTree(parser));
+
+ // Walk it and attach our listener
+ ParseTreeWalker walker = new ParseTreeWalker();
+ DslListener listener = new DslListener();
+ walker.walk(listener, ptree);
+ LOGGER.info("Final QUERY" + listener.query);
+
+ /*
+ * TODO - Visitor patternQueryDslVisitor visitor = new
+ * QueryDslVisitor(); String query = visitor.visit(ptree);
+ *
+ */
+ return listener.query;
+ } catch (Exception e) {
+ LOGGER.error("Error while processing the query"+e.getMessage());
+ }
+ return "";
+ }
+
+ public static class Builder {
+
+ /*
+ * Builder constructor doesnt do anything
+ */
+ public Builder() {
+ // Do nothing
+ }
+
+ public String build(String aaiQuery) {
+
+ return new DslQueryProcessor().parseAaiQuery(aaiQuery);
+ }
+ }
+}
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 14e218f..a230dfa 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
@@ -23,14 +23,7 @@ package org.onap.aai.rest.search;
import java.io.FileNotFoundException;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Vector;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -44,6 +37,7 @@ import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
import org.onap.aai.query.builder.MissingOptionalParameter;
+import org.onap.aai.rest.dsl.DslQueryProcessor;
import org.onap.aai.restcore.util.URITools;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.SubGraphStyle;
@@ -61,6 +55,11 @@ public abstract class GenericQueryProcessor {
protected static GremlinServerSingleton gremlinServerSingleton = GremlinServerSingleton.getInstance();
protected static GroovyQueryBuilderSingleton queryBuilderSingleton = GroovyQueryBuilderSingleton.getInstance();
protected final boolean isGremlin;
+ /* dsl parameters to store dsl query and to check
+ * if this is a DSL request
+ */
+ protected Optional<String> dsl;
+ protected final boolean isDsl ;
protected GenericQueryProcessor(Builder builder) {
this.uri = builder.getUri();
@@ -68,6 +67,9 @@ public abstract class GenericQueryProcessor {
this.vertices = builder.getVertices();
this.gremlin = builder.getGremlin();
this.isGremlin = builder.isGremlin();
+ this.dsl = builder.getDsl();
+ this.isDsl = builder.isDsl();
+
if (uri.isPresent()) {
queryParams = URITools.getQueryMap(uri.get());
} else {
@@ -116,7 +118,18 @@ public abstract class GenericQueryProcessor {
protected Pair<String, Map<String, Object>> createQuery() {
Map<String, Object> params = new HashMap<>();
String query = "";
- if (!this.isGremlin) {
+ if (this.isGremlin) {
+ query = gremlin.get();
+
+ }else if (this.isDsl) {
+ String dslUserQuery = dsl.get();
+ String dslQuery = new DslQueryProcessor.Builder().build(dslUserQuery);
+
+ query = queryBuilderSingleton.executeTraversal(dbEngine, dslQuery, params);
+ String startPrefix = "g.V()";
+ query = startPrefix + query;
+
+ }else {
Matcher m = p.matcher(uri.get().getPath());
String queryName = "";
List<String> optionalParameters = Collections.emptyList();
@@ -143,22 +156,25 @@ public abstract class GenericQueryProcessor {
}
}
- List<Object> ids = new ArrayList<>();
-
if (vertices.isPresent() && !vertices.get().isEmpty()) {
- for (Vertex v : vertices.get()) {
- ids.add(v.id());
- }
+
+ // Get the vertices and convert them into object array
+ // The reason for this was .V() takes in an array of objects
+ // not a list of objects so that needs to be converted
+ // Also instead of statically creating the list which is a bad practice
+ // We are binding the array dynamically to the groovy processor correctly
+ // This will fix the memory issue of the method size too big
+ // as statically creating a list string and passing is not appropriate
+ params.put("startVertexes", vertices.get().toArray());
+
if (query == null) {
query = "";
} else {
query = queryBuilderSingleton.executeTraversal(dbEngine, query, params);
}
- StringBuilder sb = new StringBuilder();
- sb.append("[");
- sb.append(Joiner.on(",").join(ids));
- sb.append("]");
- String startPrefix = "aaiStartQuery = " + sb.toString() + " as Object[];g.V(aaiStartQuery)";
+
+ String startPrefix = "g.V(startVertexes)";
+
if (!"".equals(query)) {
query = startPrefix + query;
} else {
@@ -166,8 +182,6 @@ public abstract class GenericQueryProcessor {
}
}
- } else {
- query = gremlin.get();
}
return new Pair<>(query, params);
@@ -182,6 +196,9 @@ public abstract class GenericQueryProcessor {
private Optional<Collection<Vertex>> vertices = Optional.empty();
private QueryProcessorType processorType = QueryProcessorType.GREMLIN_SERVER;
+ private Optional<String> dsl = Optional.empty();
+ private boolean isDsl = false;
+
public Builder(TransactionalGraphEngine dbEngine) {
this.dbEngine = dbEngine;
}
@@ -197,9 +214,16 @@ public abstract class GenericQueryProcessor {
return this;
}
- public Builder queryFrom(String gremlin) {
- this.gremlin = Optional.of(gremlin);
- this.isGremlin = true;
+ public Builder queryFrom( String query, String queryType) {
+
+ if(queryType.equals("gremlin")){
+ this.gremlin = Optional.of(query);
+ this.isGremlin = true;
+ }
+ if(queryType.equals("dsl")){
+ this.dsl = Optional.of(query);
+ this.isDsl = true;
+ }
return this;
}
@@ -222,6 +246,14 @@ public abstract class GenericQueryProcessor {
public boolean isGremlin() {
return isGremlin;
}
+
+ public Optional<String> getDsl() {
+ return dsl;
+ }
+
+ public boolean isDsl() {
+ return isDsl;
+ }
public Optional<Collection<Vertex>> getVertices() {
return vertices;
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
index 9ea0b1d..760146e 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.List;
import org.onap.aai.util.AAIConstants;
@@ -98,6 +99,8 @@ public class GetCustomQueryConfig {
private void getStoredQueryBlock( JsonObject configObject, String config ) {
if ( !configObject.has(config)) {
+ customQueryConfig.setQueryRequiredProperties( new ArrayList<String>() );
+ customQueryConfig.setQueryOptionalProperties( new ArrayList<String>() );
return;
}
@@ -109,18 +112,15 @@ public class GetCustomQueryConfig {
queryConfig = configObject.get(config);
subObject = queryConfig.getAsJsonObject();
propertyList = getPropertyList(subObject, REQUIRED_CONFIG);
- if ( QUERY_CONFIG.equals(config)) {
- customQueryConfig.setQueryRequiredProperties( propertyList );
- } else {
- customQueryConfig.setQueryRequiredProperties( null );
+ if ( propertyList == null ) {
+ propertyList = new ArrayList<String>();
}
-
+ customQueryConfig.setQueryRequiredProperties( propertyList );
propertyList = getPropertyList(subObject, OPTIONAL_CONFIG);
- if ( QUERY_CONFIG.equals(config)) {
- customQueryConfig.setQueryOptionalProperties( propertyList );
- } else {
- customQueryConfig.setQueryOptionalProperties( null );
+ if ( propertyList == null ) {
+ propertyList = new ArrayList<String>();
}
+ customQueryConfig.setQueryOptionalProperties( propertyList );
}
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 2265680..b1d68bc 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
@@ -21,6 +21,7 @@
*/
package org.onap.aai.rest.search;
+import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.util.AAIConstants;
import org.onap.aai.util.FileWatcher;
import com.att.eelf.configuration.EELFLogger;
@@ -79,7 +80,7 @@ public class GremlinServerSingleton {
.maxContentLength(6537920)
.create();
} catch (FileNotFoundException e) {
- logger.error("Unable to find the file: " + e);
+ logger.error("Unable to find the file: " + LogFormatTools.getStackTop(e));
}
try {
@@ -90,7 +91,7 @@ public class GremlinServerSingleton {
queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
} catch (IOException e) {
- logger.error("Error occurred during the processing of query json file: " + e);
+ logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
}
@@ -103,7 +104,7 @@ public class GremlinServerSingleton {
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: " + e);
+ logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
}
}
};
@@ -127,6 +128,9 @@ public class GremlinServerSingleton {
*/
public String getStoredQueryFromConfig(String key){
CustomQueryConfig customQueryConfig = queryConfig.getStoredQuery(key);
+ if ( customQueryConfig == null ) {
+ return null;
+ }
return customQueryConfig.getQuery();
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
index 49d9dc5..67883fb 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
@@ -21,26 +21,30 @@
*/
package org.onap.aai.rest.search;
-import java.util.ArrayList;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.onap.aai.dbgraphmap.SearchGraph;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.extensions.AAIExtensionMap;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.StopWatch;
+import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.util.AAIApiVersion;
+import org.onap.aai.util.AAIConstants;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.*;
+import javax.ws.rs.core.Response.Status;
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
/**
* Implements the search subdomain in the REST API. All API calls must include
@@ -59,6 +63,9 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
public static final String MODEL_QUERY = "/model";
+ public static final String TARGET_ENTITY = "DB";
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ModelAndNamedQueryRestProvider.class);
+
/**
* Gets the named query response.
*
@@ -72,19 +79,44 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path(NAMED_QUERY)
public Response getNamedQueryResponse(@Context HttpHeaders headers,
- @Context HttpServletRequest req,
- String queryParameters) {
+ @Context HttpServletRequest req,
+ String queryParameters,
+ @Context UriInfo info) {
+ return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ headers,
+ info,
+ HttpMethod.GET,
+ new Callable<Response>() {
+ @Override
+ public Response call() {
+ return processNamedQueryResponse(headers, req, queryParameters);
+ }
+ }
+ );
+ }
+
+ public Response processNamedQueryResponse(@Context HttpHeaders headers,
+ @Context HttpServletRequest req,
+ String queryParameters) {
+ String methodName = "getNamedQueryResponse";
AAIException ex = null;
Response response = null;
String fromAppId = null;
String transId = null;
+ double dbTimeMsecs = 0;
String rqstTm = genDate();
ArrayList<String> templateVars = new ArrayList<String>();
try {
+ LoggingContext.save();
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(methodName);
+
fromAppId = getFromAppId(headers);
transId = getTransId(headers);
- AAIExtensionMap aaiExtMap = new AAIExtensionMap();
+ AAIExtensionMap aaiExtMap = new AAIExtensionMap();
aaiExtMap.setHttpHeaders(headers);
aaiExtMap.setServletRequest(req);
aaiExtMap.setApiVersion(AAIApiVersion.get());
@@ -93,11 +125,25 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
DBConnectionType type = this.determineConnectionType("force-cache", realTime);
SearchGraph searchGraph = new SearchGraph();
+ LoggingContext.startTime();
+ StopWatch.conditionalStart();
+
response = searchGraph.runNamedQuery(fromAppId, transId, queryParameters, type, aaiExtMap);
+ dbTimeMsecs += StopWatch.stopIfStarted();
+ LoggingContext.elapsedTime((long)dbTimeMsecs,TimeUnit.MILLISECONDS);
+ LoggingContext.successStatusFields();
+
+
+ LOGGER.info ("Completed");
+
+ LoggingContext.restoreIfPossible();
+ LoggingContext.successStatusFields();
+
String respTm = genDate();
} catch (AAIException e) {
+ LoggingContext.restoreIfPossible();
// send error response
ex = e;
templateVars.add("POST Search");
@@ -107,6 +153,7 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e, templateVars))
.build();
} catch (Exception e) {
+ LoggingContext.restoreIfPossible();
// send error response
ex = new AAIException("AAI_4000", e);
templateVars.add("POST Search");
@@ -138,20 +185,47 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path(MODEL_QUERY)
public Response getModelQueryResponse(@Context HttpHeaders headers,
- @Context HttpServletRequest req,
- String inboundPayload,
- @QueryParam("action") String action) {
+ @Context HttpServletRequest req,
+ String inboundPayload,
+ @QueryParam("action") String action,
+ @Context UriInfo info) {
+ return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ headers,
+ info,
+ HttpMethod.GET,
+ new Callable<Response>() {
+ @Override
+ public Response call() {
+ return processModelQueryResponse(headers, req, inboundPayload, action);
+ }
+ }
+ );
+ }
+
+ public Response processModelQueryResponse(@Context HttpHeaders headers,
+ @Context HttpServletRequest req,
+ String inboundPayload,
+ @QueryParam("action") String action) {
+ String methodName = "getModelQueryResponse";
AAIException ex = null;
Response response = null;
String fromAppId = null;
String transId = null;
+ double dbTimeMsecs = 0;
+
String rqstTm = genDate();
ArrayList<String> templateVars = new ArrayList<String>();
try {
+ LoggingContext.save();
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(methodName);
+
fromAppId = getFromAppId(headers);
transId = getTransId(headers);
- AAIExtensionMap aaiExtMap = new AAIExtensionMap();
+ AAIExtensionMap aaiExtMap = new AAIExtensionMap();
aaiExtMap.setHttpHeaders(headers);
aaiExtMap.setServletRequest(req);
aaiExtMap.setApiVersion(AAIApiVersion.get());
@@ -163,14 +237,26 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
DBConnectionType type = this.determineConnectionType("force-cache", realTime);
SearchGraph searchGraph = new SearchGraph();
+ LoggingContext.startTime();
+ StopWatch.conditionalStart();
+
if (action != null && action.equalsIgnoreCase("DELETE")) {
response = searchGraph.executeModelOperation(fromAppId, transId, inboundPayload, type, true, aaiExtMap);
} else {
response = searchGraph.executeModelOperation(fromAppId, transId, inboundPayload, type, false, aaiExtMap);
}
+ dbTimeMsecs += StopWatch.stopIfStarted();
+ LoggingContext.elapsedTime((long)dbTimeMsecs,TimeUnit.MILLISECONDS);
+ LoggingContext.successStatusFields();
+
+ LOGGER.info ("Completed");
+
+ LoggingContext.restoreIfPossible();
+ LoggingContext.successStatusFields();
String respTm = genDate();
} catch (AAIException e) {
+ LoggingContext.restoreIfPossible();
// send error response
ex = e;
templateVars.add("POST Search");
@@ -180,6 +266,7 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e, templateVars))
.build();
} catch (Exception e) {
+ LoggingContext.restoreIfPossible();
// send error response
ex = new AAIException("AAI_4000", e);
templateVars.add("POST Search");
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
index dbc618e..501e019 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,6 +23,8 @@ package org.onap.aai.rest.search;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.Callable;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
@@ -35,6 +37,7 @@ import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbgraphmap.SearchGraph;
@@ -45,13 +48,20 @@ import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.Version;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.StopWatch;
+import org.onap.aai.logging.LoggingContext.StatusCode;
+import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TitanDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+import org.onap.aai.util.AAIConstants;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
/**
* Implements the search subdomain in the REST API. All API calls must include
* X-FromAppId and X-TransactionId in the header.
@@ -60,7 +70,7 @@ import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
*
*/
-@Path("/{version: v2|v[789]|v1[012]|latest}/search")
+@Path("/{version: v[789]|v1[012]|latest}/search")
public class SearchProvider extends RESTAPI {
protected static String authPolicyFunctionName = "search";
@@ -69,6 +79,8 @@ public class SearchProvider extends RESTAPI {
public static final String NODES_QUERY = "/nodes-query";
+ public static final String TARGET_ENTITY = "DB";
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SearchProvider.class);
/**
* Gets the generic query response.
*
@@ -90,16 +102,46 @@ public class SearchProvider extends RESTAPI {
@QueryParam("key") final List<String> startNodeKeyParams,
@QueryParam("include") final List<String> includeNodeTypes,
@QueryParam("depth") final int depth,
- @PathParam("version")String versionParam
+ @PathParam("version")String versionParam,
+ @Context UriInfo info
+ ) {
+ return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ headers,
+ info,
+ HttpMethod.GET,
+ new Callable<Response>() {
+ @Override
+ public Response call() {
+ return processGenericQueryResponse(headers, req, startNodeType, startNodeKeyParams, includeNodeTypes, depth, versionParam);
+ }
+ }
+ );
+ }
+
+ public Response processGenericQueryResponse(@Context HttpHeaders headers,
+ @Context HttpServletRequest req,
+ @QueryParam("start-node-type") final String startNodeType,
+ @QueryParam("key") final List<String> startNodeKeyParams,
+ @QueryParam("include") final List<String> includeNodeTypes,
+ @QueryParam("depth") final int depth,
+ @PathParam("version")String versionParam
) {
+ String methodName = "getGenericQueryResponse";
AAIException ex = null;
Response searchResult = null;
String fromAppId = null;
String transId = null;
String rqstTm = genDate();
ArrayList<String> templateVars = new ArrayList<String>();
+ double dbTimeMsecs = 0;
try {
+ LoggingContext.save();
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(methodName);
+
fromAppId = getFromAppId(headers);
transId = getTransId(headers);
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
@@ -120,6 +162,9 @@ public class SearchProvider extends RESTAPI {
DBSerializer dbSerializer = new DBSerializer(version, dbEngine, factoryType, fromAppId);
UrlBuilder urlBuilder = new UrlBuilder(version, dbSerializer);
SearchGraph searchGraph = new SearchGraph();
+
+ LoggingContext.startTime();
+ StopWatch.conditionalStart();
searchResult = searchGraph.runGenericQuery(
headers,
startNodeType,
@@ -131,10 +176,19 @@ public class SearchProvider extends RESTAPI {
urlBuilder
);
+ dbTimeMsecs += StopWatch.stopIfStarted();
+
+ LoggingContext.successStatusFields();
+ LoggingContext.elapsedTime((long)dbTimeMsecs,TimeUnit.MILLISECONDS);
+
+ LOGGER.info ("Completed");
+ LoggingContext.restoreIfPossible();
+ LoggingContext.successStatusFields();
String respTm = genDate();
-
+
} catch (AAIException e) {
+ LoggingContext.restoreIfPossible();
// send error response
ex = e;
templateVars.add("GET Search");
@@ -144,6 +198,7 @@ public class SearchProvider extends RESTAPI {
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e, templateVars))
.build();
} catch (Exception e) {
+ LoggingContext.restoreIfPossible();
// send error response
ex = new AAIException("AAI_4000", e);
templateVars.add("GET Search");
@@ -179,18 +234,47 @@ public class SearchProvider extends RESTAPI {
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path(NODES_QUERY)
public Response getNodesQueryResponse(@Context HttpHeaders headers,
- @Context HttpServletRequest req,
- @QueryParam("search-node-type") final String searchNodeType,
- @QueryParam("edge-filter") final List<String> edgeFilterList,
- @QueryParam("filter") final List<String> filterList,
- @PathParam("version")String versionParam) {
+ @Context HttpServletRequest req,
+ @QueryParam("search-node-type") final String searchNodeType,
+ @QueryParam("edge-filter") final List<String> edgeFilterList,
+ @QueryParam("filter") final List<String> filterList,
+ @PathParam("version")String versionParam,
+ @Context UriInfo info)
+
+ {
+ return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ headers,
+ info,
+ HttpMethod.GET,
+ new Callable<Response>() {
+ @Override
+ public Response call() {
+ return processNodesQueryResponse(headers, req, searchNodeType, edgeFilterList, filterList, versionParam);
+ }
+ }
+ );
+ }
+ public Response processNodesQueryResponse(@Context HttpHeaders headers,
+ @Context HttpServletRequest req,
+ @QueryParam("search-node-type") final String searchNodeType,
+ @QueryParam("edge-filter") final List<String> edgeFilterList,
+ @QueryParam("filter") final List<String> filterList,
+ @PathParam("version")String versionParam) {
+ String methodName = "getNodesQueryResponse";
AAIException ex = null;
Response searchResult = null;
String fromAppId = null;
String transId = null;
String rqstTm = genDate();
ArrayList<String> templateVars = new ArrayList<String>();
+ double dbTimeMsecs = 0;
try {
+ LoggingContext.save();
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(methodName);
+
fromAppId = getFromAppId(headers);
transId = getTransId(headers);
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
@@ -213,6 +297,9 @@ public class SearchProvider extends RESTAPI {
UrlBuilder urlBuilder = new UrlBuilder(version, dbSerializer);
SearchGraph searchGraph = new SearchGraph();
+ LoggingContext.startTime();
+ StopWatch.conditionalStart();
+
searchResult = searchGraph.runNodesQuery(headers,
searchNodeType,
edgeFilterList,
@@ -220,9 +307,17 @@ public class SearchProvider extends RESTAPI {
dbEngine,
loader,
urlBuilder);
+ dbTimeMsecs += StopWatch.stopIfStarted();
+ LoggingContext.elapsedTime((long)dbTimeMsecs,TimeUnit.MILLISECONDS);
+ LoggingContext.successStatusFields();
+ LOGGER.info ("Completed");
+
+ LoggingContext.restoreIfPossible();
+ LoggingContext.successStatusFields();
String respTm = genDate();
- } catch (AAIException e) {
+ } catch (AAIException e) {
+ LoggingContext.restoreIfPossible();
// send error response
ex = e;
templateVars.add("GET Search");
@@ -232,6 +327,7 @@ public class SearchProvider extends RESTAPI {
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e, templateVars))
.build();
} catch (Exception e) {
+ LoggingContext.restoreIfPossible();
// send error response
ex = new AAIException("AAI_4000", e);
templateVars.add("GET Search");
diff --git a/aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java b/aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java
index 49a77d8..86fefdd 100644
--- a/aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java
+++ b/aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java
@@ -7,9 +7,9 @@
* 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
- *
+ *
+ * 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.
@@ -19,27 +19,33 @@
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
+
package org.onap.aai.util;
import java.io.IOException;
-
+import java.util.UUID;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
-//import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.BrokerService;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.ModelInjestor;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LogFormatTools;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class AAIAppServletContextListener implements ServletContextListener {
+ private static final String MICRO_SVC="aai-traversal";
+ private static final String ACTIVEMQ_TCP_URL = "tcp://localhost:61446";
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAIAppServletContextListener.class.getName());
-
- //private BrokerService broker = new BrokerService();
+ private BrokerService broker = new BrokerService();
/**
* Destroys Context
@@ -47,16 +53,6 @@ public class AAIAppServletContextListener implements ServletContextListener {
* @param arg0 the ServletContextEvent
*/
public void contextDestroyed(ServletContextEvent arg0) {
- LOGGER.info("AAIGraph shutting down");
- AAIGraph.getInstance().graphShutdown();
- LOGGER.info("AAIGraph shutdown");
-
- //try {
- ////broker.stop();
- //} catch (Exception e) {
- //// TODO Auto-generated catch block
- //e.printStackTrace();
- //}
}
/**
@@ -66,8 +62,17 @@ public class AAIAppServletContextListener implements ServletContextListener {
*/
public void contextInitialized(ServletContextEvent arg0) {
System.setProperty("org.onap.aai.serverStarted", "false");
- LOGGER.info("***AAI Server initialization started...");
-
+ System.setProperty("aai.service.name", "traversal");
+
+ LoggingContext.save();
+ LoggingContext.component("init");
+ LoggingContext.partnerName("NA");
+ LoggingContext.targetEntity(MICRO_SVC);
+ LoggingContext.requestId(UUID.randomUUID().toString());
+ LoggingContext.serviceName(MICRO_SVC);
+ LoggingContext.targetServiceName("contextInitialized");
+ LoggingContext.statusCode(StatusCode.COMPLETE);
+ LOGGER.info("AAI Server initialization started...");
try {
LOGGER.info("Loading aaiconfig.properties");
AAIConfig.init();
@@ -81,30 +86,45 @@ public class AAIAppServletContextListener implements ServletContextListener {
ModelInjestor.getInstance();
// Jsm internal broker for aai events
- //broker = new BrokerService();
- //broker.addConnector("tcp://localhost:61446");
- //broker.setPersistent(false);
- //broker.setUseJmx(false);
- //broker.setSchedulerSupport(false);
- //broker.start();
-
- LOGGER.info("AAI Server initialization succcessful.");
+ broker = new BrokerService();
+ broker.addConnector(ACTIVEMQ_TCP_URL);
+ broker.setPersistent(false);
+ broker.setUseJmx(false);
+ broker.setSchedulerSupport(false);
+ broker.start();
+
+ LOGGER.info("A&AI Server initialization succcessful.");
+ System.setProperty("activemq.tcp.url", ACTIVEMQ_TCP_URL);
System.setProperty("org.onap.aai.serverStarted", "true");
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ LOGGER.info("AAIGraph shutting down");
+ AAIGraph.getInstance().graphShutdown();
+ LOGGER.info("AAIGraph shutdown");
+ try {
+ broker.stop();
+ } catch (Exception e) {
+ LOGGER.error("Issue closing broker " + LogFormatTools.getStackTop(e));
+ }
+ System.out.println("Shutdown hook triggered.");
+ }
+ });
+
} catch (AAIException e) {
ErrorLogHelper.logException(e);
- throw new RuntimeException("AAIException caught while initializing AAI server", e);
+ throw new RuntimeException("AAIException caught while initializing A&AI server", e);
} catch (IOException e) {
ErrorLogHelper.logError("AAI_4000", e.getMessage());
- throw new RuntimeException("IOException caught while initializing AAI server", e);
+ throw new RuntimeException("IOException caught while initializing A&AI server", e);
} catch (Exception e) {
- LOGGER.error("Unknown failure while initializing AAI Server", e);
- throw new RuntimeException("Unknown failure while initializing AAI server", e);
+ LOGGER.error("Unknown failure while initializing A&AI Server" + LogFormatTools.getStackTop(e));
+ throw new RuntimeException("Unknown failure while initializing A&AI server", e);
}
LOGGER.info("Graph-Query MicroService Started");
- LOGGER.error("Graph-Query MicroService Started");
LOGGER.debug("Graph-Query MicroService Started");
+ LoggingContext.restore();
}
}
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
new file mode 100644
index 0000000..2713677
--- /dev/null
+++ b/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
@@ -0,0 +1,66 @@
+/**
+ * Define a grammar called AAIDsl
+ */
+grammar AAIDsl;
+
+
+aaiquery: dslStatement;
+
+dslStatement: (queryStep) (traverseStep | unionTraverseStep)* limitStep*;
+
+queryStep : (singleNodeStep |singleQueryStep | multiQueryStep);
+
+unionQueryStep: LBRACKET dslStatement ( COMMA (dslStatement))* RBRACKET;
+
+traverseStep: (TRAVERSE ( queryStep | unionQueryStep));
+
+unionTraverseStep: TRAVERSE unionQueryStep;
+
+singleNodeStep: NODE STORE? ;
+singleQueryStep: NODE STORE? (filterStep | filterTraverseStep);
+multiQueryStep: NODE STORE? (filterStep | filterTraverseStep) (filterStep)+;
+
+filterStep: NOT? (LPAREN KEY COMMA KEY (COMMA KEY)*RPAREN);
+filterTraverseStep: (LPAREN traverseStep* RPAREN);
+
+limitStep: LIMIT NODE;
+
+LIMIT: 'LIMIT';
+NODE: ID;
+
+KEY: ['] ID ['] ;
+
+AND: [&];
+
+STORE: [*];
+
+OR: [|];
+
+TRAVERSE: [>] ;
+
+LPAREN: [(];
+
+RPAREN: [)];
+
+COMMA: [,] ;
+
+EQUAL: [=];
+
+LBRACKET: [[];
+
+RBRACKET: [\]];
+
+NOT: [!];
+
+VALUE: DIGIT;
+
+fragment LOWERCASE : [a-z] ;
+fragment UPPERCASE : [A-Z] ;
+fragment DIGIT : [0-9] ;
+ID
+ : ( LOWERCASE | UPPERCASE | DIGIT) ( LOWERCASE | UPPERCASE | DIGIT | '-' |'.' |'_')*
+ ;
+
+WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
+
+
diff --git a/aai-traversal/src/main/scripts/deleteNamedQuery.sh b/aai-traversal/src/main/scripts/deleteNamedQuery.sh
index 16b20a7..2d19a9c 100644
--- a/aai-traversal/src/main/scripts/deleteNamedQuery.sh
+++ b/aai-traversal/src/main/scripts/deleteNamedQuery.sh
@@ -26,7 +26,11 @@
#
PROGNAME=$(basename $0)
+<<<<<<< HEAD
OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
+=======
+OUTFILE=/opt/app/aai-traversal/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
+>>>>>>> codecloud/release/1802
#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
TS=$(date "+%Y-%m-%d %H:%M:%S")
@@ -45,7 +49,11 @@ error_exit () {
}
j=0
+<<<<<<< HEAD
for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f`
+=======
+for filepath in `ls /opt/app/aai-traversal/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f`
+>>>>>>> codecloud/release/1802
#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/named-query-json/*.json|sort -f`
do
j=$(expr "$j" + 1)
@@ -53,7 +61,11 @@ filename=$(basename $filepath)
echo "Begin deleteTool for named-query $filename" | tee -a $OUTFILE
vers=`grep named-query-uuid $filepath|cut -d':' -f2|cut -d'"' -f2`
resource=service-design-and-creation/named-queries/named-query/$vers
+<<<<<<< HEAD
echo "y" | $PROJECT_HOME/scripts/deleteTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+=======
+echo "y" | /opt/app/aai-traversal/scripts/deleteTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+>>>>>>> codecloud/release/1802
echo "End deleteTool for named-query $filename" | tee -a $OUTFILE
done
diff --git a/aai-traversal/src/main/scripts/putTool.sh b/aai-traversal/src/main/scripts/putTool.sh
index ea529f1..be273a2 100644
--- a/aai-traversal/src/main/scripts/putTool.sh
+++ b/aai-traversal/src/main/scripts/putTool.sh
@@ -22,8 +22,14 @@
#
#
+<<<<<<< HEAD
# The script is called with a resource, filepath and an optional argument to
# ignore HTTP failure codes which would otherwise indicate a failure.
+=======
+# The script is called with a resource, filepath, an optional argument to
+# ignore HTTP failure codes which would otherwise indicate a failure,
+# and an optional argument to display more data.
+>>>>>>> codecloud/release/1802
# It invokes a PUT on the resource with the file using curl
# Uses aaiconfig.properties for authorization type and url. The HTTP response
# code is checked. Responses between 200 and 299 are considered success.
@@ -45,6 +51,26 @@ contains() {
fi
}
+<<<<<<< HEAD
+=======
+display_usage() {
+ cat <<EOF
+ Usage: $0 [options]
+
+ 1. Usage: putTool.sh <resource-path> <json payload file> <optional HTTP Response code> <optional -display>
+ 2. This script requires two arguments, a resource path and a file path to a json file containing the payload.
+ 3. Example: query?format=xxxx customquery.json (possible formats are simple, raw, console, count, graphson, id, pathed, resource and resource_and_url)
+ 4. Adding the optional HTTP Response code will allow the script to ignore HTTP failure codes that match the input parameter.
+ 5. Adding the optional "-display" argument will display all data returned from the request, instead of just a response code.
+
+EOF
+}
+if [ $# -eq 0 ]; then
+ display_usage
+ exit 1
+fi
+
+>>>>>>> codecloud/release/1802
# remove leading slash when present
RESOURCE=`echo $1 | sed "s,^/,,"`
if [ -z $RESOURCE ]; then
@@ -76,6 +102,21 @@ prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties
log_dir=$PROJECT_HOME/logs/misc
today=$(date +\%Y-\%m-\%d)
+<<<<<<< HEAD
+=======
+RETURNRESPONSE=false
+if [ ${#} -ne 2 ]; then
+ if [ "$3" = "-display" ]; then
+ RETURNRESPONSE=true
+ fi
+fi
+if [ ${#} -ne 3 ]; then
+ if [ "$4" = "-display" ]; then
+ RETURNRESPONSE=true
+ fi
+fi
+
+>>>>>>> codecloud/release/1802
MISSING_PROP=false
RESTURL=`grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015"`
if [ -z $RESTURL ]; then
@@ -106,10 +147,22 @@ if [ $MISSING_PROP = false ]; then
else
AUTHSTRING="-u $CURLUSER:$CURLPASSWORD"
fi
+<<<<<<< HEAD
result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
#echo "result is $result."
RC=0;
if [ $? -eq 0 ]; then
+=======
+
+ if [ $RETURNRESPONSE = true ]; then
+ curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE | python -mjson.tool
+ RC=$?
+ else
+ result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
+ #echo "result is $result."
+ RC=0;
+ if [ $? -eq 0 ]; then
+>>>>>>> codecloud/release/1802
case $result in
+([0-9])?)
#if [[ "$result" -eq 412 || "$result" -ge 200 && $result -lt 300 ]]
@@ -138,10 +191,18 @@ if [ $MISSING_PROP = false ]; then
;;
esac
+<<<<<<< HEAD
else
echo "FAILED to send request to $RESTURL"
RC=-1
fi
+=======
+ else
+ echo "FAILED to send request to $RESTURL"
+ RC=-1
+ fi
+ fi
+>>>>>>> codecloud/release/1802
else
echo "usage: $0 resource file [expected-failure-codes]"
RC=-1
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
new file mode 100644
index 0000000..bd3705e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
@@ -0,0 +1,984 @@
+/**
+ * ============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.dbgraphgen;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyMap;
+import static org.mockito.Matchers.anyMapOf;
+import static org.mockito.Mockito.*;
+
+import com.bazaarvoice.jolt.modifier.DataType;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.Multimap;
+import com.thinkaurelius.titan.graphdb.olap.computer.VertexMapJob;
+import com.thinkaurelius.titan.graphdb.types.VertexLabelVertex;
+import com.thinkaurelius.titan.graphdb.types.system.BaseVertexLabel;
+import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
+import com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex;
+import com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.openjpa.kernel.exps.Exp;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.aai.db.DbMethHelper;
+import org.onap.aai.db.props.AAIProperties;
+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.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import javax.inject.Inject;
+import java.util.*;
+@RunWith(MockitoJUnitRunner.class)
+public class ModelBasedProcessingInvalidDataTest {
+
+ @Mock
+ private static TransactionalGraphEngine dbEngine;
+ private static Loader loader;
+ @Mock
+ private static DBSerializer serializer;
+ ModelBasedProcessing processor;
+
+ @Mock
+ private ModelBasedProcessing mockProcessor;
+
+
+ @Mock
+ private DbMethHelper dbMethHelper;
+
+ @BeforeClass
+ public static void configure() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+
+
+ }
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ dbMethHelper = new DbMethHelper(loader, dbEngine);
+
+ }
+
+ @Test
+ public void getStartNodesAndModVersionIdsTest() throws AAIException {
+
+
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result=new HashMap<>();
+
+ Map<String, String> result1 = mockProcessor.getStartNodesAndModVersionIds("test", "test",
+ "test", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsTest2() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsTest3() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsTest4() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsTest5() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsNullTest() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+
+ assertNotNull(result);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest1() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "Test", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+
+ assertNotNull(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest2() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "test", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest3() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "test",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerTopWidgetTypeTest() throws AAIException {
+ Vertex vertex = new EmptyVertex();
+ //Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(Vertex.class), Mockito.any(String.class))).thenReturn("Sucess");
+ String result = processor.getModelVerTopWidgetType(vertex, "test");
+ assertEquals("result has -local tacked on the end as it should", "Sucess", result
+ );
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerTopWidgetType() throws AAIException {
+ /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class))
+ ).thenReturn("Sucess");*/
+ String result = processor.getModelVerTopWidgetType("test", "test", "test", "Test", "test");
+ assertEquals("result has -local tacked on the end as it should", "Sucess", result
+ );
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByModel() throws AAIException {
+ /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class))
+ ).thenReturn("Sucess");*/
+ List<ResultSet> result = processor.queryByModel("test", "test",
+ "test", "test", "test",
+ "generic-vnf", null,
+ "test");
+ assertEquals("result has -local tacked on the end as it should", 0, result.size());
+
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void queryByModel_Timed() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ List<ResultSet> result = processor.queryByModel_Timed("test", "test",
+ "test", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertEquals("result has -local tacked on the end as it should", 0, result.size());
+
+
+ }
+
+ @Mock
+ Map<String, Object> startNodeFilterHash;
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModel() throws AAIException {
+ Map<String, String> resultMock = new HashMap<String, String>();
+
+ // when(mockProcessor.getNodeUsingUniqueId(any(String.class),any(String.class),any(String.class),any(String.class),any(String.class))).thenReturn(vertex);
+ when(mockProcessor.runDeleteByModel(any(String.class),
+ any(String.class), any(String.class),
+ any(String.class), anyMapOf(String.class, Object.class), any(String.class), any(String.class))
+ ).thenReturn(resultMock);
+ Map<String, String> result = processor.runDeleteByModel("test", "test",
+ "test", "test", startNodeFilterHash,
+ "test",
+ "test");
+ assertEquals("result has -local tacked on the end as it should", result.size(), resultMock.size());
+
+
+ }
+
+ Optional<Vertex> vertext = Optional.empty();
+
+ @Test(expected = AAIException.class)
+ public void runDeleteByModelWithNullParams() throws AAIException {
+ Map<String, String> resultMock = new HashMap<String, String>();
+
+
+ Map<String, String> result = processor.runDeleteByModel("test", "test",
+ null, null, null,
+ "test",
+ "test");
+
+ assertNotNull(result);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModelWithNullParams1() throws AAIException {
+
+ Map<String, String> result1 = processor.runDeleteByModel("test", "test",
+ null, "unknown", null,
+ "test",
+ "test");
+ assertNotNull(result1);
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModelWithNullParams2() throws AAIException {
+
+ Map<String, String> result1 = processor.runDeleteByModel("test", "test",
+ null, "unknown", null,
+ "test",
+ "test");
+ assertNotNull(result1);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery() throws AAIException{
+ String transId="test";
+ String fromAppId="test";
+ String namedQueryUuid="test";
+ ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
+ String apiVer="test";
+ List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer);
+ assertNotNull(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery1() throws AAIException{
+ String transId="teet";
+ String fromAppId="test";
+ String namedQueryUuid="test";
+ String secondaryFilterCutPoint="test";
+ List <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
+ String apiVer="test";
+ Map<String,Object> secondaryFilterHash=new HashMap<String,Object>();
+ List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer,secondaryFilterCutPoint,secondaryFilterHash);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void deleteAsNeededFromResultSet() throws AAIException {
+ Vertex vert = new BaseVertexLabel("Test");
+ Map<String, String> resultMock = new HashMap<String, String>();
+ ResultSet resultSet = new ResultSet();
+ resultSet.setVert(null);
+
+ Map<String, String> result = processor.deleteAsNeededFromResultSet("test", "test",
+ resultSet, "test", "test",
+ "test",
+ resultMock);
+
+ assertEquals(result.size(), 0);
+
+ resultSet.setVert(vert);
+
+ Map<String, String> result1 = processor.deleteAsNeededFromResultSet("test", "test",
+ resultSet, "test", "test",
+ "test",
+ resultMock);
+
+ assertEquals(result.size(), 0);
+
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void pruneResultSetTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ ResultSet resultSet = processor.pruneResultSet(rs, "testr", map);
+ assertNotNull(resultSet);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void satisfiesFiltersTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ rs.getVert().property(AAIProperties.NODE_TYPE);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+
+ map.put("modern.vertex-id", new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, true);
+ }
+
+ @Test
+ public void satisfiesFiltersTest1() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ //map.put("test.filter",new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, false);
+ }
+
+ @Test(expected = AAIException.class)
+ public void satisfiesFiltersTest2() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("testfilter", new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, false);
+ }
+
+ @Test
+ public void collapseForDoNotOutputTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ rs.setDoNotOutputFlag("true");
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ List<ResultSet> result = processor.collapseForDoNotOutput(rs);
+ assertEquals(result.size(), 1);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectInstanceDataTest() throws AAIException {
+
+ BaseVertexLabel bs = new BaseVertexLabel("test");
+ //bs.setId(80);
+ EmptyVertex ev = new EmptyVertex();
+ //ev.setId(50l);
+ Vertex thisLevelElemVtx = ev;
+
+
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ List<String> vidsTraversed = new ArrayList<String>();
+ // only applies when collecting data using the default model for delete
+ Multimap<String, String> validNextStepMap = ArrayListMultimap.create();
+ Map<String, String> namedQueryElementHash = new HashMap<String, String>();
+ namedQueryElementHash.put("test", "test");
+ Map<String, String> delKeyHash = new HashMap<String, String>();
+
+ ResultSet rs = processor.collectInstanceData("test", "test", thisLevelElemVtx, "test", validNextStepMap, vidsTraversed, 1, delKeyHash, namedQueryElementHash, "test");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void genTopoMap4ModelVerTest() throws
+ AAIException {
+ Vertex vertext = new EmptyVertex();
+ Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
+ assertNotEquals(map, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4ModelVerTestNull() throws
+ AAIException {
+ Vertex vertext = null;
+ Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
+ assertNotEquals(map, null);
+ }
+
+ @Test
+ public void makeSureItsAnArrayListTest() {
+ String input = "model-versionId,modelTestID,modelTestid2;";
+ List<String> result = processor.makeSureItsAnArrayList(input);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModConstraintHashTest() throws AAIException {
+ Vertex modelElementVtx = new EmptyVertex();
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = new EmptyVertex();
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModConstraintHashTestNull() throws AAIException {
+ Vertex modelElementVtx = null;
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 =null;
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getTopElementForSvcOrResModelVerTest() throws AAIException {
+ Vertex modelElementVtx = new EmptyVertex();
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = new EmptyVertex();
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Vertex result = processor.getTopElementForSvcOrResModelVer(modelElementVtx, "test");
+ assertNotEquals(result, null);
+ }
+
+ @Test
+ public void getNamedQueryPropOverRideTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNamedQueryPropOverRideTestNull() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void namedQueryConstraintSaysStopTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void namedQueryConstraintSaysStopTestNull() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void namedQuerynamedQueryElementVertexNullTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = null;
+ String apiVer = "test";
+
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+
+ public void getNamedQueryExtraDataLookupTest() throws Exception {
+
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryExtraDataLookup(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectNQElementHash() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, String> currentHash = new HashMap<String, String>();
+ ArrayList<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Map<String, String> result = processor.collectNQElementHash(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, currentHash,
+ vidsTraversed, levelCounter);
+
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectDeleteKeyHash() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, String> currentHash = new HashMap<String, String>();
+ ArrayList<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+ Map<String, Vertex> modConstraintHash = new HashMap<String, Vertex>();
+ String overRideModelId = "test";
+ String overRideModelVersionId = "test";
+
+ Map<String, String> result = processor.collectDeleteKeyHash(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, currentHash,
+ vidsTraversed, levelCounter, modConstraintHash, overRideModelId, overRideModelVersionId);
+
+ assertNotEquals(result, null);
+ }
+
+ @Test
+ public void getLinkageConnectNodeTypesTest() throws AAIException {
+ List<String> linkagePtList = new ArrayList<String>();
+ linkagePtList.add("modern\\|testdata\\|");
+ Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
+ assertNotEquals(result, null);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getLinkageConnectNodeTypesTest1() throws AAIException {
+
+ Set<String> result1 = processor.getLinkageConnectNodeTypes(null);
+ assertNotEquals(result1, null);
+
+ List<String> linkagePtList = new ArrayList<String>();
+ linkagePtList.add("moderntestdata");
+ Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectTopology4ModelVerTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ List<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Multimap<String, String> result = processor.collectTopology4ModelVer(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter, currentHash
+ , "test", "test");
+
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void check4EdgeRuleTest() throws AAIException {
+ processor.check4EdgeRule("test", "test");
+ }
+
+ @Test(expected = AAIException.class)
+ public void collectTopology4LinkagePointTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ String linkagePointStrVal = "test";
+ String incomingTrail = "test";
+ Multimap<String, String> currentMap = ArrayListMultimap.create();
+
+ Multimap<String, String> result = processor.collectTopology4LinkagePoint(transId, fromAppId, linkagePointStrVal, incomingTrail, currentMap);
+ assertNotEquals(result, null);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getNextStepElementsFromSet() throws AAIException {
+ Vertex constrElemSetVtx = new EmptyVertex();
+ constrElemSetVtx.<String>property(AAIProperties.NODE_TYPE);
+ Map<String, Object> result = processor.getNextStepElementsFromSet(constrElemSetVtx);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void genTopoMap4NamedQTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex queryVertex = new EmptyVertex();
+ String namedQueryUuid = "E44533334343";
+ Multimap<String, String> result = processor.genTopoMap4NamedQ(transId, fromAppId, queryVertex, namedQueryUuid);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectTopology4NamedQTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ List<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Multimap<String, String> result = processor.collectTopology4NamedQ(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelThatNqElementRepresentsTest() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Vertex vertex = processor.getModelThatNqElementRepresents(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelGivenModelVer() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Vertex vertex = processor.getModelGivenModelVer(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelTypeFromModel() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelTypeFromModel(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelTypeFromModelVer() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelTypeFromModelVer(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelElementStepName() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelElementStepName(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void nodeTypeSupportsPersona() throws AAIException {
+ String incomingTrail = "";
+ boolean vertex = processor.nodeTypeSupportsPersona(incomingTrail);
+ assertFalse(vertex);
+
+
+ incomingTrail = "test";
+ boolean vertex1 = processor.nodeTypeSupportsPersona(incomingTrail);
+ assertTrue(vertex1);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNqElementWidgetType() throws AAIException{
+ String appId="test";
+ String transID="test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex1 = processor.getNqElementWidgetType(appId,transID,thisLevelElemVtx,incomingTrail);
+ assertNotEquals(vertex1,null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getModElementWidgetType() throws AAIException{
+ String appId="test";
+ String transID="test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex1 = processor.getModElementWidgetType(thisLevelElemVtx,incomingTrail);
+ assertNotEquals(vertex1,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNodeUsingUniqueId() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "test";
+ String uniqueIdVal="test";
+ Vertex vertex1 = processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "test";
+ String uniqueIdVal="";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull1() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName="";
+ String uniqueIdVal="test";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull2() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "";
+ String idPropertyName="test";
+ String uniqueIdVal="test";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVersUsingName() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+
+ List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getModelVersUsingNameNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "";
+
+ List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModelInvId() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+
+ Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModVersUsingModelInvIdNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "";
+
+ Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModel() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModVersUsingModel1() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ Vertex thisLevelElemVtx = null;
+ List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerIdsUsingName() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelName= "test";
+ List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelVerIdsUsingName1() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelName= "";
+ List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected =NullPointerException.class)
+ public void validateModel() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelVersionId= "test";
+ String modelInvId= "test";
+ String modelName= "test";
+ processor.validateModel(transID,appId,modelName,modelVersionId);
+
+
+ }
+
+
+
+}
+
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
index 624bf19..406d122 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
@@ -21,891 +21,522 @@
*/
package org.onap.aai.dbgraphgen;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Map.Entry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import com.bazaarvoice.jolt.modifier.DataType;
+import com.google.common.collect.Multimap;
+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.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.mockito.internal.exceptions.MockitoLimitations;
+import org.mockito.runners.MockitoJUnitRunner;
import org.onap.aai.db.DbMethHelper;
import org.onap.aai.db.props.AAIProperties;
-import org.onap.aai.dbmap.DBConnectionType;
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.introspection.Version;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.parsers.exceptions.AAIIdentityMapParseException;
+import org.onap.aai.query.builder.GraphTraversalBuilder;
+import org.onap.aai.query.builder.QueryBuilder;
+import org.onap.aai.query.builder.TraversalQuery;
+import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.db.EdgeType;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
+import java.util.*;
+@RunWith(MockitoJUnitRunner.class)
public class ModelBasedProcessingTest {
- private static final Version version = Version.getLatest();
- private static final ModelType introspectorFactoryType = ModelType.MOXY;
- private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private static final DBConnectionType type = DBConnectionType.REALTIME;
-
- private static final String TRANSACTION_ID = "transaction-1";
- private static final String FROM_APP_ID = "JUNIT";
- private static final String API_VERSION = "1.0";
- private static final String AAI_NODE_TYPE = "aai-node-type";
-
- private static final String MODEL_VESION_NODE_VALUE = "model-ver";
- private static final String MODEL_VERSION_ID_KEY = "model-version-id";
- private static final String MODEL_VERSION_ID_VALUE = "model-version-id-1";
-
- private static final String MODEL_INVARIANT_ID_NODE_VALUE = "model-invariant-id-local";
- private static final String MODEL_INVARIANT_ID_KEY = "model-invariant-id-local";
- private static final String MODEL_INVARIANT_ID_VALUE = "model-invariant-id-1";
-
- private static final String MODEL_NAME_NODE_VALUE = "model-name";
- private static final String MODEL_NAME_ID_KEY = "model-name";
- private static final String MODEL_NAME_ID_VALUE = "generic-vnf";
-
-
- private static TransactionalGraphEngine dbEngine;
- private static TransactionalGraphEngine.Admin admin;
- DBSerializer serializer;
+ @Mock private static TransactionalGraphEngine dbEngine;
private static Loader loader;
- EdgeRules rules;
-
- ModelBasedProcessing modelBasedProcessor;
-
- GraphTraversalSource source;
-
- Graph graph;
-
- Vertex model;
- Vertex modelVersion;
- Vertex modelElement;
- Vertex constrainedElementSet;
- Vertex namedQueryElement;
- Vertex linkagePoints;
- Vertex namedQuery;
-
+ @Mock private static DBSerializer serializer;
+ @Mock private static TransactionalGraphEngine.Admin admin;
+ ModelBasedProcessing mockProcessor;
+ @Mock
+ private DbMethHelper dbMethHelper;
+
@BeforeClass
public static void configure() throws Exception {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+
+
}
-
+
@Before
- public void init() throws AAIException {
+ public void init() {
+ mockProcessor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
MockitoAnnotations.initMocks(this);
- rules = EdgeRules.getInstance();
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, AAIProperties.LATEST);
- TransactionalGraphEngine newDbEngine = new TitanDBEngine(queryStyle, type, loader);
- dbEngine = Mockito.spy(newDbEngine);
- serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- admin = Mockito.spy(dbEngine.asAdmin());
- modelBasedProcessor = new ModelBasedProcessing(loader, dbEngine, serializer);
- graph = TinkerGraph.open();
- source = createGraph();
- }
-
- private GraphTraversalSource createGraph() throws AAIException {
- model = graph.addVertex(T.label, "model", T.id, "0", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "widget");
- modelVersion = graph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "1", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE, MODEL_VERSION_ID_KEY,
- MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- graph.addVertex(T.label, MODEL_INVARIANT_ID_NODE_VALUE, T.id, "2", MODEL_INVARIANT_ID_KEY, MODEL_INVARIANT_ID_VALUE, "model-version-id-local", MODEL_VERSION_ID_VALUE);
- namedQuery = graph.addVertex(T.label, "named-query", T.id, "3","aai-node-type", "named-query", "named-query-uuid", "named-query-uuid-1");
- graph.addVertex(T.label, MODEL_NAME_NODE_VALUE, T.id, "4", AAI_NODE_TYPE, MODEL_NAME_NODE_VALUE, MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE);
- modelElement = graph.addVertex(T.label, "model-element", T.id, "5", AAI_NODE_TYPE, "model-element");
- Vertex modelConstraint = graph.addVertex(T.label, "model-constraint", T.id, "6", AAI_NODE_TYPE, "model-constraint","constrained-element-set-uuid-2-replace","cesu2r-1");
- constrainedElementSet = graph.addVertex(T.label, "constrained-element-set", T.id, "7", AAI_NODE_TYPE, "constrained-element-set");
- Vertex elementChoiceSet = graph.addVertex(T.label, "element-choice-set", T.id, "8", AAI_NODE_TYPE, "element-choice-set");
- namedQueryElement = graph.addVertex(T.label, "named-query-element", T.id, "9","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- linkagePoints = graph.addVertex(T.label, "linkage-points", T.id, "10", AAI_NODE_TYPE, "linkage-points", "linkage-points", getArrayListAsString(),
- "new-data-del-flag", "F");
-
- GraphTraversalSource g = graph.traversal();
- rules.addTreeEdge(g, model, modelVersion);
- rules.addTreeEdge(g, modelElement, modelConstraint);
- rules.addTreeEdge(g, constrainedElementSet, modelConstraint);
- rules.addTreeEdge(g, modelVersion, modelElement);
- rules.addTreeEdge(g, modelElement, constrainedElementSet);
- rules.addTreeEdge(g, constrainedElementSet, elementChoiceSet);
- rules.addTreeEdge(g, modelElement, elementChoiceSet);
- rules.addTreeEdge(g, namedQuery, namedQueryElement);
- rules.addTreeEdge(g, namedQueryElement, namedQueryElement);
- rules.addEdge(g, modelVersion, modelElement);
- rules.addEdge(g, model, namedQueryElement);
- return g;
- }
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NullId_ExpectException() throws AAIException {
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelVerId = null;
- String passedModelInvId = null;
- String passedModelName = null;
- modelBasedProcessor.getStartNodesAndModVersionIds("9999","postmen",passedModelVerId,passedModelInvId,
- passedModelName,"generic-vnf",startNodeFilterArrayOfHashes,"");
- }
-
- @Test
- public void testGetStartNodesAndModVersionIds_ModelVersion() throws AAIException{
-
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelInvId = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, passedModelInvId, passedModelName,
- AAI_NODE_TYPE, startNodeFilterArrayOfHashes, API_VERSION);
- }
-
- @Test
- public void testGetStartNodesAndModVersionIds_ModelInId() throws AAIException {
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelVersion = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,MODEL_INVARIANT_ID_VALUE, passedModelName,
- AAI_NODE_TYPE, startNodeFilterArrayOfHashes, API_VERSION);
}
@Test
- public void testGetStartNodesAndModVersionIds_ModelName() throws AAIException {
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelVersion = null;
- String passedModelInvId = null;
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,passedModelInvId, MODEL_NAME_ID_VALUE,
- AAI_NODE_TYPE, startNodeFilterArrayOfHashes, API_VERSION);
+ public void testPropNameChange1() throws AAIUnknownObjectException {
+ String result;
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id");
+ assertEquals("result has -local tacked on the end as it should", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "vnf-id");
+ assertEquals("result does NOT have -local tacked on the end as it should", "vnf-id", result);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX);
+ assertEquals("property not modified because it already includes the right suffix", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
}
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_ModelVersion() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelInvId = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, passedModelInvId, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_ModelInvId() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelVersion = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,MODEL_INVARIANT_ID_VALUE, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_ModelName() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelVersion = null;
- String passedModelInvId = null;
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,passedModelInvId, MODEL_NAME_ID_VALUE,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testQueryByModel() throws AAIException {
+
+ @Mock
+ GraphTraversal<Vertex, Vertex> v;
+ @Mock
+ GraphTraversal<Vertex, Vertex> graphTraversal;
+ @Mock
+ GraphTraversalSource graphTraversalSource;
+ @Mock Iterable <?> uniqVerts;
+ List<Vertex> vertexList=new ArrayList<>();
+ @Mock Vertex vertex;
+ @Mock Vertex vertex1;
+ @Mock
+ QueryBuilder<Vertex> queryBuilder;
+
+ EdgeType treeType;
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIds() throws AAIException{
+
+ vertex.property("model-ver","model-version-id");
+ vertex1.property(AAIProperties.NODE_TYPE,"model-ver");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-ver","model-version-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
+
+ queryBuilder.toList().add(vertex);
+ Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder);
+
+ Introspector obj=loader.introspectorFromName("model-ver");
+
+ Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder);
+ //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1");
+
+
List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelInvId = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.queryByModel(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, passedModelInvId, passedModelName,
- AAI_NODE_TYPE, startNodeFilterArrayOfHashes, API_VERSION);
+
+ Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
+ "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
}
-
- @Test(expected=AAIException.class)
- public void testQueryByModel_Timed() throws AAIException {
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIds1() throws AAIException{
+
+ vertex.property("model-version-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"model-ver");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-version-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
+
+ queryBuilder.toList().add(vertex);
+ Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder);
+
+ Introspector obj=loader.introspectorFromName("generic-vnf");
+ Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder);
+ //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1");
+
+
List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelVersion = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.queryByModel_Timed(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,MODEL_INVARIANT_ID_VALUE, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
- }
- @Test(expected=AAIException.class)
- public void testgetModelTypeFromModelVer_NullVertexArg() throws AAIException{
- Vertex nullVertex = null;
- modelBasedProcessor.getModelVerTopWidgetType(nullVertex, "");
- }
-
- @Test
- public void testValidateNamedQuery_FoundQuery() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- modelBasedProcessor.validateNamedQuery("9999", "JUNIT", "named-query-uuid-1", "1.0");
- }
-
- @Test(expected=AAIException.class)
- public void testValidateNamedQuery_NotFoundQuery() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- modelBasedProcessor.validateNamedQuery("9999", "JUNIT", "named-query-uuid", "1.0");
- }
-
- @Test(expected=AAIException.class)
- public void testGetNodeUsingUniqueId_NullUniqueId() throws AAIException{
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","");
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id",null);
- }
-
- @Test(expected=AAIException.class)
- public void testGetNodeUsingUniqueId_NullPropertyName() throws AAIException{
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","","vnf-id-1");
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","generic-vnf",null,"vnf-id-1");
- }
-
- @Test(expected=AAIException.class)
- public void testGetNodeUsingUniqueId_NullNodeType() throws AAIException{
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","","vnf-id","vnf-id-1");
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen",null,"vnf-id","vnf-id-1");
- }
-
- @Test(expected=AAIException.class)
- public void testValidateModel() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.validateModel("9999", "JUNIT", MODEL_VERSION_ID_VALUE, "1.0");
- }
-
- @Test
- public void testShowResultSet_NullVertex() {
- ResultSet rs = getResultSet();
- rs.setVert(null);
- modelBasedProcessor.showResultSet(rs, 1);
- }
-
- @Test
- public void testShowResultSet_NonEmptyOverrideHash() {
- ResultSet rs = getResultSet();
- modelBasedProcessor.showResultSet(rs, 2);
- }
-
- @Test
- public void testShowResultSet_EmptyOverrideHash() {
- ResultSet rs = getResultSet();
- rs.setPropertyOverRideHash(new HashMap<String, Object>());
- modelBasedProcessor.showResultSet(rs, 2);
- }
-
- private ResultSet getResultSet() {
- ResultSet rs = new ResultSet();
- rs.setVert(model);
- rs.setLocationInModelSubGraph("2");
- Map<String,Object> overrideHash = new HashMap<String, Object>();
- rs.setPropertyOverRideHash(overrideHash);
- overrideHash.put("key1", "value1");
- overrideHash.put("key2", "value2");
- overrideHash.put("key3", "value3");
- overrideHash.put("key4", "value4");
-
- Map<String,Object> extraHash = new HashMap<String, Object>();
- rs.setExtraPropertyHash(extraHash);
- extraHash.put("key1", "value1");
- extraHash.put("key2", "value2");
- extraHash.put("key3", "value3");
- extraHash.put("key4", "value4");
-
- return rs;
- }
-
- @Test
- public void testPruneResultSet_NotCutPointType() throws AAIException{
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- ResultSet rs = getResultSet();
- List<ResultSet> subResultSet = new ArrayList<>();
- subResultSet.add(getResultSet());
- rs.setSubResultSet(subResultSet);
- modelBasedProcessor.pruneResultSet(rs, "mdl", new HashMap<>());
- }
-
- @Test
- public void testPruneResultSet_CutPointType() throws AAIException{
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- ResultSet rs = getResultSet();
- Map<String, Object> startNodeFilterHash = new HashMap<>();
- startNodeFilterHash.put("model.model_type","widget");
- startNodeFilterHash.put("named_query.named-query-uuid","named-query-uuid-1");
- modelBasedProcessor.pruneResultSet(rs, "model", startNodeFilterHash);
- }
-
- @Test
- public void testCollapseForDoNotOutput_FlagTrue() throws AAIException{
-
- ResultSet rs = getResultSet();
- List<ResultSet> subResultSet = new ArrayList<>();
- subResultSet.add(getResultSet());
- rs.setSubResultSet(subResultSet);
- rs.setDoNotOutputFlag("true");
- modelBasedProcessor.collapseForDoNotOutput(rs);
- }
-
- @Test
- public void testCollapseForDoNotOutput_FlagFalse() throws AAIException{
-
- ResultSet rs = getResultSet();
- List<ResultSet> subResultSet = new ArrayList<>();
- subResultSet.add(getResultSet());
- rs.setSubResultSet(subResultSet);
- rs.setDoNotOutputFlag("false");
- modelBasedProcessor.collapseForDoNotOutput(rs);
- }
-
- @Test
- public void testMakeSureItsAnArrayList() {
- String listString = getArrayListAsString();
- modelBasedProcessor.makeSureItsAnArrayList(listString);
- }
-
- private String getArrayListAsString() {
- List<String> strList = new ArrayList<>();
- strList.add("1");
- strList.add("2");
- strList.add("3");
- String listString = strList.toString();
- return listString;
+ Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
+ "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
}
@Test
- public void testGetModConstraintHash() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getModConstraintHash(modelElement, new HashMap<>());
- }
-
- @Test(expected=AAIException.class)
- public void testGenTopoMap4ModelVer_WidgetType() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.genTopoMap4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelVersion, MODEL_VERSION_ID_VALUE);
- }
-
- @Test(expected=AAIException.class)
- public void testGenTopoMap4ModelVer_ServiceType() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "20", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "service");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "21", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "22", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.genTopoMap4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelVerV, MODEL_VERSION_ID_VALUE);
- }
-
- @Test(expected=AAIException.class)
- public void testCollectTopology4ModelVer() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- Multimap <String, String> initialEmptyMap = ArrayListMultimap.create();
- List<String> vidsTraversed = new ArrayList<>();
- modelBasedProcessor.collectTopology4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelElement, "", initialEmptyMap, vidsTraversed,
- 0, null, MODEL_INVARIANT_ID_VALUE, MODEL_VERSION_ID_VALUE);
- }
-
- @Test(expected=AAIException.class)
- public void testGetNextStepElementsFromSet_NullVertex() throws AAIException{
- modelBasedProcessor.getNextStepElementsFromSet(null);
- }
-
- @Test
- public void testRundeleteAsNeededFromResultSet() throws AAIException{
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- ResultSet rs = getResultSet();
- rs.setNewDataDelFlag("T");
- modelBasedProcessor.deleteAsNeededFromResultSet(TRANSACTION_ID, FROM_APP_ID, rs,
- "", API_VERSION, API_VERSION, new HashMap<>());
- }
-
- @Test(expected=AAIException.class)
- public void testQueryByNamedQuery() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.queryByNamedQuery(TRANSACTION_ID, FROM_APP_ID, "named-query-uuid-1", new ArrayList<>(), API_VERSION);
- }
-
- @Test
- public void testCollectInstanceData() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- Multimap <String, String> validNextStepMap = ArrayListMultimap.create();
- validNextStepMap.put("named-query-element-uuid-1", "named-query-element-uuid-1");
- List<String> vidsTraversed=new ArrayList<>();
- vidsTraversed.add("named-query-element-uuid-1");
- Map<String,String> namedQueryElementHash = new HashMap<>();
- namedQueryElementHash.put("named-query-element-uuid-1", "named-query-element-uuid-1");
- modelBasedProcessor.collectInstanceData(TRANSACTION_ID, FROM_APP_ID, modelElement, "named-query-element-uuid-1",
- validNextStepMap, vidsTraversed, 0, new HashMap<>(), namedQueryElementHash, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullNamedQueryVertex() throws AAIException {
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, null, model, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullInstanceVertex() throws AAIException {
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, model, null, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullContraintType() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "30","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "31", AAI_NODE_TYPE, "property-constraint");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "32", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullPropertyName() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "33","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "34", AAI_NODE_TYPE, "property-constraint", "constraint-type", "EQUALS");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "35", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullPropertyValue() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "36","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "37", AAI_NODE_TYPE, "property-constraint",
- "constraint-type", "EQUALS", "property-name", "property-name");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "38", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test
- public void testNamedQueryConstraintSaysStop_ConstraintTypeEquals() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "39","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "40", AAI_NODE_TYPE, "property-constraint",
- "constraint-type", "EQUALS", "property-name", "property-name", "property-value", "property-value");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "41", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test
- public void testNamedQueryConstraintSaysStop_ConstraintTypeNotEquals() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "42","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "43", AAI_NODE_TYPE, "property-constraint",
- "constraint-type", "NOT-EQUALS", "property-name", "property-name", "property-value", "property-value");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "44", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testGetNamedQueryExtraDataLookup_TargetNodeTypeNull() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "45","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex relatedLookUpV = graph.addVertex(T.label, "related-lookup", T.id, "46", AAI_NODE_TYPE, "related-lookup",
- "source-node-property", "source-node-property", "source-node-type", "generic-vnf");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "47", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getNamedQueryExtraDataLookup(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test
- public void testGetNamedQueryExtraDataLookup_InvalidSourceProperty() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "51","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex relatedLookUpV = graph.addVertex(T.label, "related-lookup", T.id, "52", AAI_NODE_TYPE, "related-lookup",
- "source-node-property", "source-node-property", "source-node-type", "generic-vnf", "target-node-type", "generic-vnf",
- "target-node-property", "generic-vnf", "property-collect-list", "property-collect-list");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "53", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getNamedQueryExtraDataLookup(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testGetNamedQueryExtraDataLookup_ValidSourceProperty() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "54","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex relatedLookUpV = graph.addVertex(T.label, "related-lookup", T.id, "55", AAI_NODE_TYPE, "related-lookup",
- "source-node-property", "source-node-property", "source-node-type", "generic-vnf", "target-node-type", "generic-vnf", "target-node-property", "generic-vnf");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "56", AAI_NODE_TYPE, "instance-vertex", "source-node-property", "source-node-property");
- GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getNamedQueryExtraDataLookup(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test
- public void testCollectNQElementHash() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.collectNQElementHash(TRANSACTION_ID, FROM_APP_ID, namedQueryElement, "", new HashMap<>(), new ArrayList<>(), 0);
+ public void getNodeUsingUniqueIdTest() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
}
-
+
@Test
- public void testCollectDeleteKeyHash() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.collectDeleteKeyHash(TRANSACTION_ID, FROM_APP_ID, linkagePoints, "", new HashMap<>(), new ArrayList<>(),
- 0, new HashMap<>(), "model-version-1", "model-version-id-local");
- }
-
- @Test(expected=AAIException.class)
- public void testCheck4EdgeRule_InvalidNodeA() throws AAIException {
- modelBasedProcessor.check4EdgeRule("model-version1", "model-ver");
+ public void getNodeUsingUniqueIdTest1() throws AAIException{
+ vertex.property("named-query-uui","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uui","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","named-query","named-query-uui","vnf-id-1");
+
+ assertNotNull(result);
}
- @Test(expected=AAIException.class)
- public void testCheck4EdgeRule_InvalidNodeB() throws AAIException {
- modelBasedProcessor.check4EdgeRule("model-ver", "model-version1");
+ @Test(expected = AAIException.class)
+ public void getModelVersUsingNameTest() throws AAIException{
+
+ vertex.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ vertex1.property("generic-vnf","generic-vnf");
+ graphTraversal.addV(vertex1);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-name","generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ //Mockito.when(vertexList.listIterator().hasNext()).thenReturn(true);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ List<Vertex> result=processor.getModelVersUsingName("9999","postment","generic-vnf");
+
+ assertTrue(result.size()>0);
}
-
- @Test(expected=AAIException.class)
- public void testCheck4EdgeRule_InvalidEdge() throws AAIException {
- modelBasedProcessor.check4EdgeRule("model-ver", "named-query");
+
+ //uniqueIdVal Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","");
+
+
}
-
- @Test
- public void testCollectTopology4LinkagePoint() throws AAIException {
- String linkagePointStrVal = new String("model-ver|model");
- String incomingTrail = new String("model|model-ver");
- Multimap <String, String> currentMap = ArrayListMultimap.create();
- modelBasedProcessor.collectTopology4LinkagePoint(TRANSACTION_ID, FROM_APP_ID, linkagePointStrVal, incomingTrail, currentMap);
+
+ //idPropertyName Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","","vnf-id-1");
+
+
}
-
- @Test
- public void testGenTopoMap4NamedQ() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.genTopoMap4NamedQ(TRANSACTION_ID, FROM_APP_ID, namedQuery, "named-query-uuid-1");
+
+ //idPropertyName Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull2() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","","vnf-id","vnf-id-1");
+
+
}
-
- @Test
- public void testGetModelThatNqElementRepresents() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getModelThatNqElementRepresents(namedQueryElement, "");
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestTwoVertex() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
}
-
- @Test
- public void testGetModelVerThatElementRepresents() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getModelVerThatElementRepresents(modelElement, "");
+
+ //uniqVerts Null Expection AAI Exception
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestVertexNull() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(null);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
}
-
- @Test
- public void testGetModelTypeFromModel() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getModelTypeFromModel(model, "");
+
+ //uniqVerts Null Expection AAI Exception
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestVertexHasNot() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ //vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
}
-
- @Test
- public void testGetModelVerTopWidgetType() throws AAIException {
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "57", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "service");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "58", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "59", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getModelVerTopWidgetType(modelVerV, "");
+
+ @Test(expected = AAIIdentityMapParseException.class)
+ public void runDeleteByModelTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Optional<Vertex> vertex=Optional.empty();
+ Map<String,Object> startNodeFilterHash=new HashMap<>();
+ startNodeFilterHash.put("related-link.data","relationshipdata");
+ startNodeFilterHash.put("generic-vnf.d","relationshipdata");
+ Mockito.when(dbMethHelper.searchVertexByIdentityMap("relationship-data",startNodeFilterHash)).thenReturn(vertex);
+ Map<String,String> re =processor.runDeleteByModel("9999","postmen","","relationship-data",startNodeFilterHash,"vnf-id","vnf-id");
+ assertNotNull(re);
+
+
}
-
- @Test
- public void testGetModelElementStepName() throws AAIException {
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "60", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "service");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "61", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "62", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getModelElementStepName(modelElementV, "");
+
+ @Test(expected = AAIException.class)
+ public void getModelGivenModelVerTest() throws AAIException{
+ vertex.property("named-query-uuid","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uuid","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getModelGivenModelVer(vertex,"");
+ assertNotNull(result);
+
}
-
- @Test(expected=IllegalArgumentException.class)
- public void testRunDeleteByModel() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- Map<String, Object> map = new HashMap<>();
- map.put("generic-vnf.d","relationshipdata");
-
- modelBasedProcessor.runDeleteByModel(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, "model-ver", map, API_VERSION, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery_TimedTest() throws AAIException{
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uuid","named-query-element")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
+ Map<String,Object> secondaryFilterHash=new HashMap<>();
+
+ List<ResultSet> res=processor.queryByNamedQuery_Timed("99999","postmen","named-query-element",startNodeFilterArrayOfHashes,"vnf","vnf",
+ secondaryFilterHash);
+
+
}
-
- @Test
- public void testSecondConstructor() {
- ModelBasedProcessing mdp = new ModelBasedProcessing();
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4NamedQTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",vertex,"named-query-element");
}
-
- @Test(expected=AAIIdentityMapParseException.class)
- public void testQueryByNamedQuery_NonEmptyMap() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- modelBasedProcessor.queryByNamedQuery(TRANSACTION_ID, FROM_APP_ID, "named-query-uuid-1", startNodeFilterArrayOfHashes, API_VERSION, null, null);
-
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4NamedQTest1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",null,"named-query-element");
}
-
- @Test(expected=AAIIdentityMapParseException.class)
- public void testRunDeleteByModel_Service() throws AAIException {
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "63", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "service");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "64", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "65", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
-
- Map<String, Object> map = new HashMap<>();
- map.put("generic-vnf.d","relationshipdata");
-
- modelBasedProcessor.runDeleteByModel(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, "model-ver", map, API_VERSION, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void getModelThatNqElementRepresentsTest() throws AAIException{
+ vertex.property("model-ver","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex v=processor.getModelThatNqElementRepresents(vertex,"g");
}
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_AllEmpty() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelInvId = null;
- String passedModelName = null;
- String passedModelVerId = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID, passedModelVerId, passedModelInvId, passedModelName,
- "", startNodeFilterArrayOfHashes, API_VERSION);
+
+ @Test(expected = NullPointerException.class)
+ public void getModelTypeFromModel() throws AAIException{
+ Vertex vt=Mockito.mock(Vertex.class);
+ vt.property("model-type","named-query-element");
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ String v=processor.getModelTypeFromModel(vt,"g");
}
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_ModelTypeNonNull() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelInvId = null;
- String passedModelName = null;
- String passedModelVerId = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID, passedModelVerId, passedModelInvId, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void getModelTypeFromModel1() throws AAIException{
+ Vertex vt=Mockito.mock(Vertex.class);
+ vt.property("model-type","named-query-element");
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ String v=processor.getModelTypeFromModel(null,"g");
}
-
- @Test(expected=AAIException.class)
- public void testQueryByModel_Timed_NonEmptyHash() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelVersion = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.queryByModel_Timed(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,MODEL_INVARIANT_ID_VALUE, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModelInvId() throws AAIException{
+
+ vertex.property(AAIProperties.NODE_TYPE,"model-invariant-id");
+ vertex1.property("model","model-invariant-id");
+ graphTraversal.addV(vertex1);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-invariant-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model","model-invariant-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Iterator<Vertex> result=processor.getModVersUsingModelInvId("9999","postment","model");
}
-
- @Test(expected=AAIException.class)
- public void testRunDeleteByModel_NullVersionAndNode() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- Map<String, Object> map = new HashMap<>();
- map.put("generic-vnf.d","relationshipdata");
-
- modelBasedProcessor.runDeleteByModel(TRANSACTION_ID, FROM_APP_ID, "", "", map, API_VERSION, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void getNamedQueryExtraDataLookupTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",null,vertex,
+ "");
}
-
- @Test(expected=AAIException.class)
- public void testRunDeleteByModel_NullVersion() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- Map<String, Object> map = new HashMap<>();
- map.put("generic-vnf.d","relationshipdata");
-
- modelBasedProcessor.runDeleteByModel(TRANSACTION_ID, FROM_APP_ID, "", "model-ver", map, API_VERSION, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void getNamedQueryExtraDataLookupTest1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",vertex,null,
+ "");
}
-
- @Test
- public void testGenTopoMap4ModelVer_WidgetType_Map() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "66", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "widget");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "67", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- //Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "68", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- //rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- //rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.genTopoMap4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelVerV, MODEL_VERSION_ID_VALUE);
+
+ @Test(expected = NullPointerException.class)
+ public void showResultSet() throws AAIException{
+ vertex.property("model-ver","model-versionId");
+ vertex.property("aai","model-versionId");
+
+
+ ResultSet rs= Mockito.mock(ResultSet.class);
+ Mockito.when(rs.getVert()).thenReturn(vertex);
+
+ List<VertexProperty<String>> vb=new ArrayList<>();
+ VertexProperty<String> v=Mockito.mock(VertexProperty.class);
+ v.property("model-ver","1");
+ vb.add(v);
+ v.property("aai","5");
+ vb.add(v);
+ v.property("source-of-truth","6");
+ vb.add(v);
+
+ vertex.properties("model-ver","aai");
+ Mockito.when(vertex.<String>property(AAIProperties.NODE_TYPE)).thenReturn(v);
+ //Mockito.when(vertex.properties()).thenReturn(Mockito.any());
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ processor.showResultSet(rs,8);
+
}
-
}
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
new file mode 100644
index 0000000..f86010e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.dbgraphmap;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.onap.aai.exceptions.AAIException;
+
+@Ignore
+public class SearchGraphEdgeRuleTest {
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
+ @Test
+ public void getEdgeLabelTest() throws AAIException {
+ String[] label = SearchGraph.getEdgeLabel("customer", "service-subscription");
+
+ assertEquals("subscribesTo", 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.");
+ SearchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
+ }
+
+ @Test
+ 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.");
+ SearchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java
index 6efb0d1..fcc1ee3 100644
--- a/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java
@@ -27,6 +27,7 @@ import org.mockito.Mockito;
import org.onap.aai.logging.LoggingContext;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -50,11 +51,11 @@ public class PostAaiAjscInterceptorTest {
public void testAllowOrRejectIfSuccess() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-
- LoggingContext.put(LoggingContext.LoggingField.RESPONSE_CODE.toString(), "SUCCESS");
+ HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
+ response.setStatus(200);
Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj"));
- boolean success = postAaiAjscInterceptor.allowOrReject(request, null, null);
+ boolean success = postAaiAjscInterceptor.allowOrReject(request, response, null);
assertTrue("Expecting the post interceptor to return success regardless", success);
}
@@ -63,11 +64,11 @@ public class PostAaiAjscInterceptorTest {
public void testAllowOrRejectIfFailure() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-
- LoggingContext.put(LoggingContext.LoggingField.RESPONSE_CODE.toString(), "ERR.");
+ HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
+ response.setStatus(400);
Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj"));
- boolean success = postAaiAjscInterceptor.allowOrReject(request, null, null);
+ boolean success = postAaiAjscInterceptor.allowOrReject(request, response, null);
assertTrue("Expecting the post interceptor to return success regardless", success);
}
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
new file mode 100644
index 0000000..a351de0
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
@@ -0,0 +1,315 @@
+/**
+ * ============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;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.jayway.jsonpath.JsonPath;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.HttpTestUtil;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.introspection.Version;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.*;
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class GfpVserverDataStoredQueryTest {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(GfpVserverDataStoredQueryTest.class);
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private HttpHeaders httpHeaders;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private HttpTestUtil httpTestUtil;
+
+ private QueryConsumer queryConsumer;
+
+ private static final Version VERSION = Version.v11;
+ private static final String CLOUD_REGION_URI = "/aai/" + VERSION.toString()
+ + "/cloud-infrastructure/cloud-regions/"
+ + "cloud-region/testOwner1/testRegion1";
+
+ @Before
+ public void setup() throws Exception {
+ httpTestUtil = new HttpTestUtil();
+
+ Map<String, String> templateValues = new HashMap<>();
+
+ templateValues.put("cloud-owner", "testOwner1");
+ templateValues.put("cloud-region-id", "testRegion1");
+ templateValues.put("tenant-id", "testTenant1");
+ templateValues.put("tenant-name", "testTenantName1");
+ templateValues.put("vserver-id", "testVserver1");
+ templateValues.put("vserver-name", "junit-vservers");
+ templateValues.put("interface-name", "testlInterfaceName1");
+ templateValues.put("ipv4-address", "192.33.233.233");
+ templateValues.put("ipv6-address", "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
+ templateValues.put("vlan-interface", "vlan-interface1");
+
+ String cloudRegionPayload = PayloadUtil.
+ getTemplatePayload("cloud-region-with-linterface.json", templateValues);
+
+ Response response = httpTestUtil.doPut(CLOUD_REGION_URI, cloudRegionPayload);
+ logger.info("Response status received {}", response.getEntity());
+
+ assertNotNull("Expected the response to be not null", response);
+ assertEquals("Expecting the cloud region to be created", 201, response.getStatus());
+ logger.info("Successfully created the cloud region with linterface");
+
+ queryConsumer = new QueryConsumer();
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Ignore("This is more of a performance test to ensure no failure when too many starting vertexes")
+ @Test
+ public void testStoredQueryVerifyDoesNotThrowMethodTooLargeWhenLargeNumberOfStartingVertexes() throws Exception {
+
+ // Add hundred thousand vserver vertexes to properly
+ // test the scenario where the application was
+ // failing with method too large
+ addVservers(1000000);
+
+ Map<String, String> templateValues = new HashMap<>();
+
+ // Purposefully putting the filter to the testVserver1 as
+ // since this is a junit test other junit tests could put
+ // vserver and not properly clean up after the test
+ // so doing this to ensure that this is testing against the particular vserver
+ // as not to fail when another unit test decide to put vserver and not clean up
+ templateValues.put("start", "nodes/vservers?vserver-name=junit-vservers");
+ templateValues.put("query", "gfp-vserver-data");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
+ String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+
+ UriInfo uriInfo = Mockito.mock(UriInfo.class);
+ HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
+
+ queryParameters.add("format", "resource_and_url");
+ Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getPath()).thenReturn(query);
+
+ Response response = queryConsumer.executeQuery(
+ payload,
+ VERSION.toString(),
+ query,
+ "resource_and_url", "" +
+ "no_op",
+ httpHeaders,
+ uriInfo,
+ httpServletRequest
+ );
+
+ String entity = response.getEntity().toString();
+ assertEquals("Expected the response to be 200 but got this returned: " + response.getEntity().toString(),
+ 200, response.getStatus());
+ List<String> urls = JsonPath.read(entity, "$.results[*].url");
+ assertEquals("Expected the urls to be 3", 3, urls.size());
+ removeVertexes();
+ }
+
+ @Test
+ public void testStoredQueryWhenQueryDoesNotExistShouldReturnBadRequest() throws Exception {
+
+ Map<String, String> templateValues = new HashMap<>();
+
+ templateValues.put("start", "nodes/vservers");
+ templateValues.put("query", "fake-query");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
+ String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+
+ UriInfo uriInfo = Mockito.mock(UriInfo.class);
+ HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
+
+ queryParameters.add("format", "resource_and_url");
+ Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getPath()).thenReturn(query);
+
+ Response response = queryConsumer.executeQuery(
+ payload,
+ VERSION.toString(),
+ query,
+ "resource_and_url", "" +
+ "no_op",
+ httpHeaders,
+ uriInfo,
+ httpServletRequest
+ );
+
+ String entity = response.getEntity().toString();
+
+ assertEquals("Expected the response to be 400 but got this returned: " + entity,
+ 400, response.getStatus());
+
+ assertThat("Expecting error message since query doesn't exist", entity,
+ containsString("Query payload is invalid"));
+ }
+
+ @Test
+ public void testStoredQueryWhenStartFilterReturnsZeroVertexesItShouldHandleProperly() throws Exception {
+
+ Map<String, String> templateValues = new HashMap<>();
+
+ templateValues.put("start", "nodes/vservers?vserver-name=nonexistent-filter");
+ templateValues.put("query", "gfp-vserver-data");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
+ String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+
+ UriInfo uriInfo = Mockito.mock(UriInfo.class);
+ HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
+
+ queryParameters.add("format", "resource_and_url");
+ Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getPath()).thenReturn(query);
+
+ Response response = queryConsumer.executeQuery(
+ payload,
+ VERSION.toString(),
+ query,
+ "resource_and_url", "" +
+ "no_op",
+ httpHeaders,
+ uriInfo,
+ httpServletRequest
+ );
+
+ String entity = response.getEntity().toString();
+
+ assertEquals("Expected the response to be 500 but got this returned: " + entity,
+ 500, response.getStatus());
+
+ assertThat(entity, containsString("Internal Error:groovy.lang.MissingPropertyException"));
+ }
+
+ @After
+ public void tearDown(){
+ removeVertexes();
+ }
+
+ private void removeVertexes(){
+
+ TitanGraph titanGraph = AAIGraph.getInstance().getGraph();
+ TitanTransaction transaction = titanGraph.newTransaction();
+
+ boolean success = true;
+
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ g.V().has("source-of-truth", "JUNIT").toList().stream()
+ .forEach((vertex) -> vertex.remove());
+ } catch(Exception ex){
+ success = false;
+ logger.error("Unable to remove all of the junit vservers due to {}", ex);
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ }
+ }
+
+ }
+
+ private void addVservers(int vserversCount){
+
+ TitanGraph titanGraph = AAIGraph.getInstance().getGraph();
+ TitanTransaction transaction = titanGraph.newTransaction();
+
+ boolean success = true;
+
+ try {
+
+ GraphTraversalSource g = transaction.traversal();
+ for(int index = 0; index < vserversCount; index++){
+ String randomVserverId = UUID.randomUUID().toString();
+ g.addV().property("aai-node-type", "vserver")
+ .property( "vserver-id", "random-" + randomVserverId)
+ .property( "vserver-name", "junit-vservers")
+ .property( "source-of-truth", "JUNIT")
+ .next();
+ }
+
+ } catch(Exception ex){
+ success = false;
+ logger.error("Unable to add all of the vservers due to {}", ex);
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ }
+ }
+ }
+}
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
new file mode 100644
index 0000000..d05702e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
@@ -0,0 +1,234 @@
+/**
+ * ============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.dsl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.onap.aai.exceptions.AAIException;
+
+/**
+ * The Class DslMain.
+ */
+public class DslQueryProcessorTest {
+
+
+ @Test
+ public void cloudRegion1Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String aaiQuery = "cloud-region* !('cloud-owner','coid')('cloud-region-id','crid') LIMIT 10";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".getVerticesByProperty('cloud-region-id','crid').store('x').cap('x').unfold().dedup().limit(10)";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_entitlementTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ 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')"
+ + ".getVerticesByProperty('cloud-region-id','One').store('x'))"
+ + ".createEdgeTraversal(EdgeType.TREE, 'generic-vnf','entitlement').store('x').cap('x').unfold().dedup()";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void complex_az_fromComplexTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') > [ availability-zone* , complex*]";
+ String query = dslTest.parseAaiQuery(aaiQuery);
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ + ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
+ + ".union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'cloud-region','availability-zone').store('x')"
+ + ",builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','complex').store('x')).cap('x').unfold().dedup()";
+
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromComplex1Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('country','count-name')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x').cap('x').unfold().dedup()";
+ String aaiQuery = "complex('country','count-name') > cloud-region*";
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromComplex2Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('country','count-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 query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromNfTypeTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'image').getVerticesByProperty('application-vendor','F5')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'image','vserver')"
+ + ".where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver','generic-vnf').getVerticesByProperty('vnf-name','ZALL1MMSC03'))"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ + ".store('x').cap('x').unfold().dedup()";
+ String aaiQuery = "image('application-vendor','F5') > vserver (>generic-vnf('vnf-name','ZALL1MMSC03')) > tenant > cloud-region*";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromNfTypeVendorVersionTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'image').getVerticesByProperty('application-vendor','vendor')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'image','vserver').where("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver','generic-vnf').getVerticesByProperty('nf-type','nfType')"
+ + ").createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "image('application-vendor','vendor') > vserver( >generic-vnf('nf-type', 'nfType') ) > tenant > cloud-region*";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloud_region_fromVnfTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vnfc','vserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').store('x')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region').store('x')"
+ + ".cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf('vnf-id','vnfId') > vnfc* > vserver* > tenant* > cloud-region*";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloud_region_sitesTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')."
+ + "getVerticesByProperty('cloud-owner','co').store('x').createEdgeTraversal(EdgeType.COUSIN, "
+ + "'cloud-region','complex').store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "cloud-region*('cloud-owner','co') > complex*";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void complex_fromVnf2Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ 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')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ + ").cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-Id','vnfId') > " + "[ pserver* > complex*, "
+ + " vserver > pserver* > complex* " + "]";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void complex_fromVnfTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ 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')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ + ").cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-Id','vnfId') > " + "[ pserver* > complex*, "
+ + " vserver > pserver* > complex* " + "]";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void fn_topology1Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'business')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'business','customer').getVerticesByProperty('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')"
+ + ".union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').store('x'),"
+ + "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') "
+ + " > service-instance('service-instance-id','sid') > generic-vnf* "
+ + " > [ vnfc* , vserver*, pserver* , pnf* ]";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java
new file mode 100644
index 0000000..f6f2a63
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java
@@ -0,0 +1,124 @@
+/**
+* ============LICENSE_START=======================================================
+* org.onap.aai
+* ================================================================================
+* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+*/
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class AccessServiceFromServiceInstanceTest extends QueryTest {
+
+ public AccessServiceFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-type", "service-subcription-1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "global-customer-id", "customer-id-1", "subscriber-name", "customer-name1", "subscriber-type", "customer-type1");
+ Vertex forwardingPath = graph.addVertex(T.label, "forwarding-path", T.id, "4", "aai-node-type", "forwarding-path", "forwarding-path-id", "forwarding-path-id-1", "forwarding-path-name", "forwarding-path-name-1");
+ Vertex configuration = graph.addVertex(T.label, "configuration", T.id, "5", "aai-node-type", "configuration", "configuration-id", "configuration-1", "configuration-type", "configuration-type-1", "configuration-sub-type", "configuration-sub-type-1");
+ Vertex evc = graph.addVertex(T.label, "evc", T.id, "6", "aai-node-type", "evc", "evc-id", "evc-1");
+ Vertex forwarder = graph.addVertex(T.label, "forwarder", T.id,"7", "aai-node-type", "forwarder", "sequence", "forwarder-1");
+ Vertex forwarderEvc = graph.addVertex(T.label, "forwarder-evc", T.id, "8", "aai-node-type", "forwarder-evc", "forwarder-evc-id", "forwarder-evc-1");
+ Vertex pInterface = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "p-interface-1");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "10", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex lagInterface = graph.addVertex(T.label, "lag-interface", T.id, "11", "aai-node-type", "lag-interface","interface-name", "lagint1");
+ Vertex logicalLink = graph.addVertex(T.label, "logical-link", T.id, "12", "aai-node-type", "logical-link", "link-name", "logical-link-1", "link-type", "LAG");
+ Vertex badLogicalLink = graph.addVertex(T.label, "logical-link", T.id, "13", "aai-node-type", "logical-link", "link-name", "logical-link-bad", "link-type", "BAD");
+ Vertex wrongInterfaceOne = graph.addVertex(T.label, "l-interface", T.id, "14", "aai-node-type", "l-interface", "interface-name", "wrong-interface-1");
+ Vertex wrongInterfaceTwo = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "interface-name", "wrong-interface-2");
+ Vertex wrongInterfaceThree = graph.addVertex(T.label, "l-interface", T.id, "16", "aai-node-type", "l-interface", "interface-name", "wrong-interface-3");
+ Vertex wrongInterfaceFour = graph.addVertex(T.label, "l-interface", T.id, "17", "aai-node-type", "l-interface", "interface-name", "wrong-interface-4");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, serviceInstance, serviceSubscription);
+ rules.addTreeEdge(g, serviceSubscription, customer);
+ rules.addEdge(g, serviceInstance,forwardingPath);
+ rules.addEdge(g, forwardingPath, configuration);
+ rules.addTreeEdge(g, configuration,evc);
+ rules.addTreeEdge(g, forwardingPath,forwarder);
+ rules.addEdge(g, forwarder, configuration);
+ rules.addTreeEdge(g, configuration,forwarderEvc);
+ rules.addEdge(g, forwarder, pInterface);
+ rules.addTreeEdge(g, pnf,pInterface);
+ rules.addEdge(g, forwarder, lagInterface);
+ rules.addTreeEdge(g, lagInterface,pnf);
+ rules.addEdge(g, logicalLink,lagInterface);
+
+ //incorrect nodes
+ rules.addEdge(g, badLogicalLink, lagInterface);
+ rules.addEdge(g, configuration, wrongInterfaceOne);
+ rules.addEdge(g, forwarder, wrongInterfaceTwo);
+ rules.addTreeEdge(g, pInterface, wrongInterfaceThree);
+ rules.addTreeEdge(g, lagInterface, wrongInterfaceFour);
+
+
+ expectedResult.add(serviceInstance);
+ expectedResult.add(serviceSubscription);
+ expectedResult.add(customer);
+ expectedResult.add(forwardingPath);
+ expectedResult.add(configuration);
+ expectedResult.add(evc);
+ expectedResult.add(forwarder);
+ expectedResult.add(forwarderEvc);
+ expectedResult.add(pInterface);
+ expectedResult.add(pnf);
+ expectedResult.add(lagInterface);
+ expectedResult.add(logicalLink);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "access-service-fromServiceInstance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "customer").has("global-customer-id", "customer-id-1").in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "service-subscription").has("service-type", "service-subcription-1").in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java
new file mode 100644
index 0000000..295194f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class AvailabilityZoneAndComplexfromCloudRegionQueryTest extends QueryTest {
+ public AvailabilityZoneAndComplexfromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
+ Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "2", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1","country","country1");
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
+ Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex", "physical-location-id", "physical-location-id-20","country","country20");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, cloudregion, availibityzone);
+ rules.addEdge(g, cloudregion,complex);
+
+ rules.addTreeEdge(g, cloudregion1, availibityzone1);
+ rules.addEdge(g, cloudregion1,complex1);
+
+ expectedResult.add(availibityzone);
+ expectedResult.add(complex);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "availabilityZoneAndComplex-fromCloudRegion";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","cloud-region").has("cloud-owner","cloud-owner-1").has("cloud-region-id","cloud-region-id-1");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java
new file mode 100644
index 0000000..59d2167
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionSitesQueryTest extends QueryTest {
+
+ public CloudRegionSitesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region3 = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region4 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner2");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "4", "aai-node-type", "complex");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex");
+ Vertex complex3 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, region1, complex1);
+ rules.addEdge(g, region2, complex1);
+ rules.addEdge(g, region3, complex2);
+ rules.addEdge(g, region4, complex3);
+
+ expectedResult.add(region1);
+ expectedResult.add(region2);
+ expectedResult.add(region3);
+ expectedResult.add(complex1);
+ expectedResult.add(complex2);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloud-region-sites";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "cloud-region");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("owner", "cloudOwner1");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java
new file mode 100644
index 0000000..9cffc37
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ColocatedDevicesQueryTest extends QueryTest {
+ public ColocatedDevicesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserverint1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "3", "aai-node-type", "pnf", "pnf-name", "pnfname1");
+ Vertex pnfint1 = graph.addVertex(T.label, "p-interface", T.id, "4", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "5", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex", "physical-location-id", "clli2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "xe0/0/1");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "9", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex pserverint3 = graph.addVertex(T.label, "p-interface", T.id, "10", "aai-node-type", "p-interface", "interface-name", "xe0/0/3");
+ Vertex plink2 = graph.addVertex(T.label, "physical-link", T.id, "11", "aai-node-type", "physical-link", "link-name", "xe0/0/1-to-xe0/0/3");
+
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "12", "aai-node-type", "pnf", "pnf-name", "pnfname2");
+ Vertex pnfint2 = graph.addVertex(T.label, "p-interface", T.id, "13", "aai-node-type", "p-interface", "interface-name", "ge0/0/2");
+ Vertex pnf3 = graph.addVertex(T.label, "pnf", T.id, "14", "aai-node-type", "pnf", "pnf-name", "pnfname3");
+ Vertex pnfint3 = graph.addVertex(T.label, "p-interface", T.id, "15", "aai-node-type", "p-interface", "interface-name", "ge0/0/3");
+ Vertex plink3 = graph.addVertex(T.label, "physical-link", T.id, "16", "aai-node-type", "physical-link", "link-name", "ge0/0/2-to-ge0/0/3");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver1, complex1);
+ rules.addTreeEdge(g, pserver1, pserverint1);
+ rules.addEdge(g, pnf1, complex1);
+ rules.addTreeEdge(g, pnf1, pnfint1);
+ rules.addEdge(g, pserverint1, plink1);
+ rules.addEdge(g, pnfint1, plink1);
+
+ rules.addEdge(g, pserver2, complex1);
+ rules.addTreeEdge(g, pserver2, pserverint2);
+ rules.addEdge(g, pserver3, complex2);
+ rules.addTreeEdge(g, pserver3, pserverint3);
+ rules.addEdge(g, pserverint2, plink2);
+ rules.addEdge(g, pserverint3, plink2);
+
+ rules.addEdge(g, pnf2, complex2);
+ rules.addTreeEdge(g, pnf2, pnfint2);
+ rules.addEdge(g, pnf3, complex2);
+ rules.addTreeEdge(g, pnf3, pnfint3);
+ rules.addEdge(g, pnfint2, plink3);
+ rules.addEdge(g, pnfint3, plink3);
+
+
+ expectedResult.add(pnf1);
+ expectedResult.add(pnfint1);
+ expectedResult.add(pserver1);
+ expectedResult.add(pserverint1);
+ expectedResult.add(plink1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserverint2);
+ expectedResult.add(plink2);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "colocated-devices";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java
new file mode 100644
index 0000000..e0ae06c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ComplexFromVnfTest extends QueryTest {
+ public ComplexFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "1", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "hostname-1");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1", "country", "US");
+
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "hostname-2");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2", "country", "US");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gnvf1, vserver1);
+ rules.addEdge(g, vserver1, pserver1);
+ rules.addEdge(g, pserver1, complex1);
+ rules.addEdge(g, gnvf1, pserver2);
+ rules.addEdge(g, pserver2, complex2);
+
+ expectedResult.add(gnvf1);
+ expectedResult.add(pserver1);
+ expectedResult.add(complex1);
+ expectedResult.add(pserver2);
+ expectedResult.add(complex2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "complex-fromVnf";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-name", "vnf-name-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java
new file mode 100644
index 0000000..523693e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java
@@ -0,0 +1,80 @@
+/**
+* ============LICENSE_START=======================================================
+* org.onap.aai
+* ================================================================================
+* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+*/
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CountVnfByVnfTypeTest extends QueryTest {
+
+ public CountVnfByVnfTypeTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run(true);
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex genericVnfTypeA1 = graph.addVertex(T.label, "genric-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1", "vnf-type", "A");
+ Vertex genericVnfTypeB1 = graph.addVertex(T.label, "genric-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name-2", "vnf-type", "B");
+ Vertex genericVnfTypeC1 = graph.addVertex(T.label, "genric-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-3", "vnf-name", "vnf-name-3", "vnf-type", "C");
+ Vertex genericVnfTypeA2 = graph.addVertex(T.label, "genric-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-4", "vnf-name", "vnf-name-4", "vnf-type", "A");
+ Vertex genericVnfTypeB2 = graph.addVertex(T.label, "genric-vnf", T.id, "5", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-5", "vnf-name", "vnf-name-5", "vnf-type", "B");
+ Vertex genericVnfTypeA3 = graph.addVertex(T.label, "genric-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-6", "vnf-name", "vnf-name-6", "vnf-type", "A");
+ Vertex genericVnfTypeA4 = graph.addVertex(T.label, "genric-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-7", "vnf-name", "vnf-name-7", "vnf-type", "A");
+
+ GraphTraversalSource g = graph.traversal();
+
+ expectedResultForMaps = expectedResultForMaps + "[A=4, B=2, C=1]";
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "count-vnf-byVnfType";
+ }
+
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ return;
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java
new file mode 100644
index 0000000..f3d374c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java
@@ -0,0 +1,138 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GFPVnfDataTest extends QueryTest {
+ public GFPVnfDataTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0","vnf-name", "vnf-name-1", "nf-type", "sample-nf-type");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "3", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-0");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "4", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-0");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "5", "aai-node-type", "vlan","vlan-interface", "vlan1");
+ Vertex vnfImage = graph.addVertex(T.label, "vnf-image", T.id, "6", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid");
+ Vertex networkProfile = graph.addVertex(T.label, "network-profile", T.id, "7","aai-node-type", "network-profile","nm-profile-name", "nm-profile-name-1");
+ Vertex lagint = graph.addVertex(T.label, "lag-interface", T.id, "8", "aai-node-type", "lag-interface","interface-name", "lagint1");
+
+ Vertex lagint0 = graph.addVertex(T.label, "lag-interface", T.id, "11", "aai-node-type", "lag-interface","interface-name", "lagint31");
+ Vertex linterface0 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id30", "l-interface-name", "l-interface-name30");
+ Vertex vlan0 = graph.addVertex(T.label, "vlan", T.id, "13", "aai-node-type", "vlan","vlan-interface", "vlan31");
+ Vertex l3inter1ipv4addresslist0 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "14", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-30");
+ Vertex l3inter1ipv6addresslist0 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "15", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-30");
+
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "10", "aai-node-type", "generic-vnf", "vnf-id", "vnfid10","vnf-name", "vnf-name-11", "nf-type", "sample-nf-type11");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "20", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id10", "l-interface-name", "l-interface-name10");
+ Vertex l3inter1ipv4addresslist1 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "30", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-10");
+ Vertex l3inter1ipv6addresslist1 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "40", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-10");
+ Vertex vlan1 = graph.addVertex(T.label, "vlan", T.id, "50", "aai-node-type", "vlan","vlan-interface", "vlan11");
+ Vertex vnfImage1 = graph.addVertex(T.label, "vnf-image", T.id, "60", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid11");
+ Vertex networkProfile1 = graph.addVertex(T.label, "network-profile", T.id, "70","aai-node-type", "network-profile","nm-profile-name", "nm-profile-name-11");
+ Vertex lagint1 = graph.addVertex(T.label, "lag-interface", T.id, "80", "aai-node-type", "lag-interface","interface-name", "lagint11");
+
+
+ Vertex lagint2 = graph.addVertex(T.label, "lag-interface", T.id, "21", "aai-node-type", "lag-interface","interface-name", "lagint312");
+ Vertex linterface2 = graph.addVertex(T.label, "l-interface", T.id, "22", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id30", "l-interface-name", "l-interface-name302");
+ Vertex vlan2 = graph.addVertex(T.label, "vlan", T.id, "23", "aai-node-type", "vlan","vlan-interface", "vlan312");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "24", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-302");
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "25", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-302");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, genericvnf, linterface);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addTreeEdge(g, linterface,vlan);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, vlan);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, vlan);
+
+ rules.addTreeEdge(g, genericvnf, lagint0);
+ rules.addTreeEdge(g, lagint0,linterface0);
+ rules.addTreeEdge(g, linterface0,vlan0);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist0, linterface0);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist0, linterface0);
+
+ rules.addEdge(g, genericvnf, vnfImage);
+ rules.addEdge(g, genericvnf, networkProfile);
+
+
+
+ //false
+ rules.addTreeEdge(g, genericvnf1, linterface1);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist1, linterface1);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist1, linterface1);
+ rules.addTreeEdge(g, linterface1,vlan1);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist1, vlan1);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist1, vlan1);
+
+ rules.addTreeEdge(g, genericvnf1, lagint2);
+ rules.addTreeEdge(g, linterface2,lagint2);
+ rules.addTreeEdge(g, linterface2,vlan2);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist2, linterface2);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist2, linterface2);
+
+ rules.addEdge(g, genericvnf1, vnfImage1);
+ rules.addEdge(g, genericvnf1, networkProfile1);
+
+
+ expectedResult.add(genericvnf);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(vlan);
+ expectedResult.add(linterface0);
+ expectedResult.add(vnfImage);
+ expectedResult.add(networkProfile);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "gfp-vnf-data";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-name", "vnf-name-1").has("vnf-id", "vnfid0");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
index 58c5876..9001f48 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
@@ -2,6 +2,8 @@ package org.onap.aai.rest.search;
import static org.junit.Assert.*;
+import java.util.ArrayList;
+
import org.junit.Before;
import org.junit.Test;
@@ -43,7 +45,7 @@ public class GetCustomQueryConfigTest {
CustomQueryConfig cqc = getCustomQueryConfig.getStoredQuery("queryName2");
assertEquals(Lists.newArrayList("prop5"), cqc.getQueryOptionalProperties());
- assertEquals(null, cqc.getQueryRequiredProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryRequiredProperties());
assertEquals("out('bar').has('stuff','baz')", cqc.getQuery());
}
@@ -54,8 +56,8 @@ public class GetCustomQueryConfigTest {
GetCustomQueryConfig getCustomQueryConfig = new GetCustomQueryConfig(configJson);
CustomQueryConfig cqc = getCustomQueryConfig.getStoredQuery("queryName3");
- assertEquals(null, cqc.getQueryOptionalProperties());
- assertEquals(null, cqc.getQueryRequiredProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryOptionalProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryRequiredProperties());
assertEquals("out('bar1').has('stuff','baz1')", cqc.getQuery());
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
new file mode 100644
index 0000000..2c67917
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
@@ -0,0 +1,84 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GfpVserverDataQueryTest extends QueryTest {
+ public GfpVserverDataQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0", "nf-type", "sample-nf-type");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "2", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "4", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "5", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-0");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-0");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "9", "aai-node-type", "vlan", "vlan-interface", "vlan-interface0");
+ Vertex sriovVf = graph.addVertex(T.label, "sriov-vf", T.id, "10", "aai-node-type", "sriov-vf", "pci-id", "pci-id0");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addEdge(g, genericvnf, vserver);
+ rules.addTreeEdge(g, linterface, vserver);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addTreeEdge(g, vlan, linterface);
+ rules.addTreeEdge(g, sriovVf, linterface);
+
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(vlan);
+ }
+ @Override
+ protected String getQueryName() {
+ return "gfp-vserver-data";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vserver");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
index 5c6a45f..1ef953a 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
@@ -135,7 +135,7 @@ public class GremlinServerImplTest {
loader);
GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
builder.queryFrom(URI.create("te"));
-builder.queryFrom("te");
+builder.queryFrom("te", "gremlin");
builder.create();
builder.processWith(QueryProcessorType.GREMLIN_SERVER);
builder.processWith(QueryProcessorType.LOCAL_GROOVY);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
index 3735e97..f1eacc6 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
@@ -135,7 +135,7 @@ public class GroovyShellImplTest {
loader);
GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
builder.queryFrom(URI.create("te"));
-builder.queryFrom("te");
+builder.queryFrom("te", "gremlin");
builder.create();
builder.processWith(QueryProcessorType.GREMLIN_SERVER);
builder.processWith(QueryProcessorType.LOCAL_GROOVY);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
index dcc3d32..e57c698 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
@@ -70,7 +70,7 @@ public class LinkedDevices_NewvceVserverTest extends QueryTest {
"interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region",
- "cloud-owner", "att", "cloud-region-id", "crId");
+ "cloud-owner", "onap", "cloud-region-id", "crId");
Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "60", "aai-node-type", "tenant",
"tenant-id", "tenId", "tenant-name", "verity");
Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "30", "aai-node-type", "vserver",
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
index ea5bc85..9ab7bc5 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
@@ -95,6 +95,8 @@ public class ModelAndNamedQueryRestProviderTest {
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
+ when(uriInfo.getPath()).thenReturn("JUNITURI");
+
headersMultiMap = new MultivaluedHashMap<>();
queryParameters = Mockito.spy(new MultivaluedHashMap<>());
@@ -143,7 +145,8 @@ public class ModelAndNamedQueryRestProviderTest {
Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
httpHeaders,
request,
- queryParameters
+ queryParameters,
+ uriInfo
);
assertNotNull(response);
@@ -164,13 +167,58 @@ public class ModelAndNamedQueryRestProviderTest {
Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
httpHeaders,
null,
- "cloud-region"
+ "cloud-region",
+ uriInfo
);
assertNotNull(response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
+ @Test
+ public void testNamedQueryCallTimeoutThrown() throws Exception {
+
+ String queryParameters = getPayload("payloads/named-queries/named-query.json");
+ HttpServletRequest request = mock(HttpServletRequest.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(request.getContentType()).thenReturn("application/json");
+
+ Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
+ httpHeaders,
+ request,
+ queryParameters,
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testNamedQueryCallTimeoutBypassed() throws Exception {
+
+ String queryParameters = getPayload("payloads/named-queries/named-query.json");
+ HttpServletRequest request = mock(HttpServletRequest.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(request.getContentType()).thenReturn("application/json");
+
+ Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
+ httpHeaders,
+ request,
+ queryParameters,
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ }
+
public String getPayload(String filename) throws IOException {
InputStream inputStream = getClass()
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java
new file mode 100644
index 0000000..226c9fc
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PnfTopologyQueryTest extends QueryTest {
+
+ public PnfTopologyQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "0", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "1", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pnf1int1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex pnf1int2 = graph.addVertex(T.label, "p-interface", T.id, "3", "aai-node-type", "p-interface", "interface-name", "ge0/0/1");
+ Vertex pnf1int3 = graph.addVertex(T.label, "p-interface", T.id, "4", "aai-node-type", "p-interface", "interface-name", "ge0/0/2");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "7", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "8", "aai-node-type", "pnf", "pnf-name", "pnf2name");
+ Vertex pnf2int = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "ge0/1/0");
+ Vertex plink2 = graph.addVertex(T.label, "physical-link", T.id, "10", "aai-node-type", "physical-link", "link-name", "ge0/0/1-to-ge0/1/0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "xe0/0/1");
+ Vertex pnf2int2 = graph.addVertex(T.label, "p-interface", T.id, "13", "aai-node-type", "p-interface", "interface-name", "ge0/1/0");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pnf1, complex);
+ rules.addTreeEdge(g, pnf1, pnf1int1);
+ rules.addTreeEdge(g, pnf1, pnf1int2);
+ rules.addTreeEdge(g, pnf1, pnf1int3);
+ rules.addEdge(g, pserver, complex);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addEdge(g, pnf1int1, plink1);
+ rules.addEdge(g, pserverint, plink1);
+ rules.addEdge(g, pnf2, complex);
+ rules.addTreeEdge(g, pnf2, pnf2int);
+ rules.addEdge(g, pnf1int2, plink2);
+ rules.addEdge(g, pnf2int, plink2);
+ rules.addEdge(g, vserver, pserver);
+ rules.addTreeEdge(g, pserver, pserverint2);
+ rules.addTreeEdge(g, pnf2, pnf2int2);
+
+ expectedResult.add(pnf1);
+ expectedResult.add(complex);
+ expectedResult.add(pnf1int1);
+ expectedResult.add(pnf1int2);
+ expectedResult.add(pserver);
+ expectedResult.add(pserverint);
+ expectedResult.add(plink1);
+ expectedResult.add(pnf2);
+ expectedResult.add(pnf2int);
+ expectedResult.add(plink2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ // TODO Auto-generated method stub
+ return "pnf-topology";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("pnf-name", "pnf1name");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
index 9a427ca..d445a51 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
@@ -53,6 +53,8 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
"link-type", "link-type1");
Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored", "true",
"in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
// Following are extra nodes that should not be picked up in
// expectedResults
@@ -71,10 +73,10 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
rules.addEdge(g, lint2, loglink1);
rules.addEdge(g, loglink1, pserver1);
rules.addEdge(g, loglink1, gvnf1);
+ rules.addEdge(g, gvnf1, pnf1);
// These should not be picked up in expectedResults
//rules.addEdge(g, config2, loglink2);
- rules.addEdge(g, lint2, loglink2);
rules.addEdge(g, loglink2, pserver2);
rules.addEdge(g, loglink2, gvnf2);
@@ -84,6 +86,7 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
expectedResult.add(lint1);
expectedResult.add(pserver1);
expectedResult.add(gvnf1);
+ expectedResult.add(pnf1);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
index 9638cfd..d4fe7d9 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
@@ -53,6 +53,8 @@ public class PserverfromConfigurationTest extends QueryTest {
"link-type", "link-type1");
Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored", "true",
"in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
// Following are extra nodes that should not be picked up in
// expectedResults
@@ -63,6 +65,8 @@ public class PserverfromConfigurationTest extends QueryTest {
"link-type", "link-type2");
Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "16", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored",
"true", "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id2");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "18", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor2", "equip-model",
+ "equip-model2");
GraphTraversalSource g = graph.traversal();
rules.addEdge(g, config1, loglink1);
@@ -70,18 +74,20 @@ public class PserverfromConfigurationTest extends QueryTest {
rules.addEdge(g, lint2, loglink1);
rules.addEdge(g, loglink1, pserver1);
rules.addEdge(g, loglink1, gvnf1);
+ rules.addEdge(g, gvnf1, pnf1);
// These should not be picked up in expectedResults
rules.addEdge(g, config2, loglink2);
- rules.addEdge(g, lint2, loglink2);
rules.addEdge(g, loglink2, pserver2);
rules.addEdge(g, loglink2, gvnf2);
+ rules.addEdge(g, gvnf2, pnf2);
expectedResult.add(config1);
expectedResult.add(lint1);
expectedResult.add(lint2);
expectedResult.add(pserver1);
expectedResult.add(gvnf1);
+ expectedResult.add(pnf1);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java
new file mode 100644
index 0000000..64971d6
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserversWithNoComplexTest extends QueryTest {
+
+ public PserversWithNoComplexTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex pserver4 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername4");
+ Vertex pserver5 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername5");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex",
+ "physical-location-id", "physical-location-id-1", "country", "US");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "7", "aai-node-type", "complex",
+ "physical-location-id", "physical-location-id-2", "country", "USA");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver4,complex1);
+ rules.addEdge(g, pserver5,complex2);
+
+ expectedResult.add(pserver1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserver3);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pservers-withNoComplex";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ return;
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java
new file mode 100644
index 0000000..c9a83e7
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java
@@ -0,0 +1,111 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class QueryPnfFromModelByRegionTest extends QueryTest {
+ public QueryPnfFromModelByRegionTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //serviceInstance 1,2,3 are good and 4 is bad based upon the filters
+ Vertex serviceInst1 = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance1", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst2 = graph.addVertex(T.label, "service-instance", T.id, "2", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance2", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst3 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance3", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst4 = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance4", "model-invariant-id", "miid2", "model-version-id", "mvid2");
+
+ //pnf 1,2 & 3 are good based upon the filters
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "5", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "6", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf3 = graph.addVertex(T.label, "pnf", T.id, "7", "aai-node-type", "pnf", "pnf-name", "pnf3name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf4 = graph.addVertex(T.label, "pnf", T.id, "12", "aai-node-type", "pnf", "pnf-name", "pnf4name", "equip-vendor", "equip-vendor4",
+ "equip-model", "equip-model4");
+
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "9", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
+
+ //cr 1 is good based upon the filter
+ Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region1");
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "11", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region2");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, serviceInst1, pnf1);
+ rules.addEdge(g, serviceInst2, pnf2);
+ rules.addEdge(g, serviceInst3, pnf3);
+ rules.addEdge(g, serviceInst4, pnf4);
+
+ rules.addEdge(g, pnf1, complex1);
+ rules.addEdge(g, pnf2, complex1);
+ rules.addEdge(g, pnf3, complex2);
+ rules.addEdge(g, pnf4, complex2);
+
+ rules.addEdge(g, cloudRegion1, complex1);
+ rules.addEdge(g, cloudRegion2, complex2);
+
+
+ expectedResult.add(pnf1);
+ expectedResult.add(pnf2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pnf-fromModel-byRegion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("model-invariant-id", "miid1").has("model-version-id", "mvid1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionId", "cloud-region1");
+ params.put("equipVendor", "equip-vendor1");
+ params.put("equipModel", "equip-model1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
index a7c8470..ae54449 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
@@ -21,15 +21,21 @@
*/
package org.onap.aai.rest.search;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -48,18 +54,23 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
public abstract class QueryTest {
-
+
+ private EELFLogger logger;
protected Graph graph;
private GremlinServerSingleton gremlinServerSingleton;
private GremlinGroovyShellSingleton shell;
@Mock private TransactionalGraphEngine dbEngine;
protected final List<Vertex> expectedResult = new ArrayList<>();
+ //expectedResultForMaps is for when the query returns a HashMap, not a Vertex
+ protected String expectedResultForMaps = new String();
protected final EdgeRules rules = EdgeRules.getInstance();
protected Loader loader;
public QueryTest() throws AAIException, NoEdgeRuleFoundException {
setUp();
+ logger = EELFManager.getInstance().getLogger(getClass());
}
+
public void setUp() throws AAIException, NoEdgeRuleFoundException {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
@@ -72,23 +83,61 @@ public abstract class QueryTest {
}
public void run() {
+ this.run(false);
+ }
+
+ public void run(boolean isHashMap) {
String query = gremlinServerSingleton.getStoredQueryFromConfig(getQueryName());
Map<String, Object> params = new HashMap<>();
addParam(params);
when(dbEngine.getQueryBuilder(any(QueryStyle.class))).thenReturn(new GremlinTraversal<>(loader, graph.traversal()));
+ logger.info("Stored query in abstraction form {}", query);
query = GroovyQueryBuilderSingleton.getInstance().executeTraversal(dbEngine, query, params);
+ logger.info("After converting to gremlin query {}", query);
query = "g" + query;
GraphTraversal<Vertex, Vertex> g = graph.traversal().V();
addStartNode(g);
params.put("g", g);
- GraphTraversal<Vertex, Vertex> result = (GraphTraversal<Vertex, Vertex>)shell.executeTraversal(query, params);
- List<Vertex> vertices = result.toList();
- assertTrue("all vertices found", vertices.containsAll(expectedResult) && expectedResult.containsAll(vertices));
+ //Certain custom queries return HashMaps instead of Vertex; different code must used for both cases to avoid a ClassCastException
+ if(!isHashMap) {
+ GraphTraversal<Vertex, Vertex> result = (GraphTraversal<Vertex, Vertex>)shell.executeTraversal(query, params);
+
+ List<Vertex> vertices = result.toList();
+
+ logger.info("Expected result set of vertexes [{}]", convert(expectedResult));
+ logger.info("Actual Result set of vertexes [{}]", convert(vertices));
+ List<Vertex> nonDuplicateExpectedResult = new ArrayList<>(new HashSet<>(expectedResult));
+ vertices = new ArrayList<>(new HashSet<>(vertices));
+
+ nonDuplicateExpectedResult.sort(Comparator.comparing(vertex -> vertex.id().toString()));
+ vertices.sort(Comparator.comparing(vertex -> vertex.id().toString()));
+
+ // Use this instead of the assertTrue as this provides more useful
+ // debugging information such as this when expected and actual differ:
+ // java.lang.AssertionError: Expected all the vertices to be found
+ // Expected :[v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]]
+ // Actual :[v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]]
+ assertEquals("Expected all the vertices to be found", nonDuplicateExpectedResult, vertices);
+ }
+ else {
+ GraphTraversal<HashMap<String,Long>, HashMap<String,Long>> result = (GraphTraversal<HashMap<String,Long>, HashMap<String,Long>>)shell.executeTraversal(query, params);
+
+ String map = result.toList().toString();
+ System.out.println(map);
+ assertTrue("all hash maps found", map.equals(expectedResultForMaps) && expectedResultForMaps.equals(map));
+ }
}
-
+
+ private String convert(List<Vertex> vertices){
+ return vertices
+ .stream()
+ .map(vertex -> vertex.property("aai-node-type").value().toString())
+ .collect(Collectors.joining(","));
+ }
+
protected abstract void createGraph() throws AAIException, NoEdgeRuleFoundException;
protected abstract String getQueryName();
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
index 67f7d11..6d6cf10 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
@@ -80,10 +80,7 @@ public class QueryVnfFromModelByRegionTest extends QueryTest {
rules.addEdge(g, genericVnf3, vserver3);
rules.addTreeEdge(g, tenant1, vserver3);
- rules.addEdge(g, serviceInst1, genericVnf3);
-
expectedResult.add(genericVnf1);
- expectedResult.add(genericVnf3);
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
index 8633cb4..bb04653 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
@@ -91,6 +91,8 @@ public class SearchProviderTest {
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
+ when(uriInfo.getPath()).thenReturn("JUNITURI");
+
headersMultiMap = new MultivaluedHashMap<>();
queryParameters = Mockito.spy(new MultivaluedHashMap<>());
@@ -146,7 +148,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -158,7 +161,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- "latest"
+ "latest",
+ uriInfo
);
assertNotNull(response);
@@ -188,7 +192,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -196,6 +201,73 @@ public class SearchProviderTest {
}
@Test
+ public void testNodesQueryTimeoutThrown() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getNodesQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("7406"));
+ }
+
+ @Test
+ public void testNodesQueryTimeoutBypassed() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getNodesQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("4009"));
+ }
+
+
+ @Test
public void testGenericQueryInvalidData() throws Exception {
List<String> keys = new ArrayList<>();
@@ -214,7 +286,8 @@ public class SearchProviderTest {
keys,
includeStrings,
0,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -226,7 +299,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- "latest"
+ "latest",
+ uriInfo
);
assertNotNull(response);
@@ -257,11 +331,81 @@ public class SearchProviderTest {
keys,
includeStrings,
0,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
+ @Test
+ public void testGenericQueryTimeoutThrown() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getGenericQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ 0,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("7406"));
+ }
+
+ @Test
+ public void testGenericQueryBypassTimeout() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getGenericQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ 0,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("4009"));
+ }
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
index 3be5b34..26b34a4 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
@@ -78,7 +78,6 @@ public class ServiceFromPserverAndSubsNameTest extends QueryTest {
rules.addEdge(g, vserver2, pserver1); //true
rules.addEdge(g, vnf2, vserver2); //true
rules.addEdge(g, vnf2, servinst2); //true
- rules.addEdge(g, vnf2, servinst3); //false
rules.addTreeEdge(g, servinst2, servsub2); //true
rules.addTreeEdge(g, servsub2, customer1); //true
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
index abf9139..93a8195 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
@@ -47,16 +47,24 @@ public class ServiceModelsByDistributionStatusTest extends QueryTest {
Vertex modelver11 = graph.addVertex(T.label, "model-ver", T.id, "21", "aai-node-type", "model-ver", "model-version-id", "model-version-id-11","model-name","model-name11", "model-version","model-version-1", "distribution-status", "distribution-status2");
Vertex model2 = graph.addVertex(T.label, "model", T.id, "3", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-2", "model-type", "resource");
- Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver", "model-version-id", "model-version-id-2","model-name","model-name2", "model-version","model-version-1", "distribution-status", "distribution-status2");
- GraphTraversalSource g = graph.traversal();
+ Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver", "model-version-id", "model-version-id-2","model-name","model-name2", "model-version","model-version-22", "distribution-status", "distribution-status2");
+
+ Vertex model3 = graph.addVertex(T.label, "model", T.id, "5", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-3", "model-type", "service");
+ Vertex modelver3 = graph.addVertex(T.label, "model-ver", T.id, "6", "aai-node-type", "model-ver", "model-version-id", "model-version-id-13","model-name","model-name3", "model-version","model-version-3", "distribution-status", "distribution-status1");
+ Vertex modelver13 = graph.addVertex(T.label, "model-ver", T.id, "7", "aai-node-type", "model-ver", "model-version-id", "model-version-id-33","model-name","model-name33", "model-version","model-version-33", "distribution-status", "distribution-status2");
+
+ GraphTraversalSource g = graph.traversal();
- rules.addTreeEdge(g, modelver1, model1);
- rules.addTreeEdge(g, modelver11, model1);
- rules.addTreeEdge(g, modelver2, model1);
+ rules.addTreeEdge(g, modelver2,model2);
+
+ rules.addTreeEdge(g, modelver3, model3);
+ rules.addTreeEdge(g, modelver13, model3);
+ rules.addTreeEdge(g, modelver11, model3);
- expectedResult.add(model1);
+ expectedResult.add(model3);
+ expectedResult.add(modelver13);
expectedResult.add(modelver11);
- expectedResult.add(modelver2);
+
}
@Override
@@ -65,7 +73,7 @@ public class ServiceModelsByDistributionStatusTest extends QueryTest {
}
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1");
+ g.has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-3");
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java
new file mode 100644
index 0000000..55510fa
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ServiceSitesQueryTest extends QueryTest {
+
+ public ServiceSitesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "0", "aai-node-type", "customer", "global-customer-id", "customer1");
+ Vertex customer2 = graph.addVertex(T.label, "customer", T.id, "1", "aai-node-type", "customer", "global-customer-id", "customer2");
+ Vertex service1 = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-type", "service1");
+ Vertex service2 = graph.addVertex(T.label, "service-subscription", T.id, "3", "aai-node-type", "service-subscription", "service-type", "service2");
+ Vertex instance = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance");
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "5", "aai-node-type", "generic-vnf");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "9", "aai-node-type", "tenant");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, customer1, service1);
+ rules.addTreeEdge(g, customer1, service2);
+ rules.addTreeEdge(g, service1, instance);
+ rules.addEdge(g, vnf, instance);
+ rules.addEdge(g, vnf, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, region);
+ rules.addEdge(g, region, complex);
+ rules.addEdge(g, vserver, pserver);
+ rules.addEdge(g, pserver, complex);
+
+ expectedResult.add(instance);
+ expectedResult.add(vnf);
+ expectedResult.add(region);
+ expectedResult.add(complex);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "service-sites";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "customer");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("customerId", "customer1");
+ params.put("type", "service1");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java
new file mode 100644
index 0000000..92d925b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java
@@ -0,0 +1,149 @@
+package org.onap.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class ServiceTopologyTest extends QueryTest {
+ public ServiceTopologyTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex servinst = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "servInstId01", "service-type", "servType01");
+ Vertex gv = graph.addVertex(T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "name", "vnf-type", "type");
+ Vertex vnfc = graph.addVertex(T.id, "3", "aai-node-type", "vnfc","vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
+
+ Vertex vipipv4addresslist1 = graph.addVertex(T.label, "vip-ipv4-address-list", T.id, "4", "aai-node-type", "vip-ipv4-address-list", "vip-ipv4-addres", "vip-ipv4-address1");
+ Vertex subnet1 = graph.addVertex(T.label, "subnet", T.id, "5", "aai-node-type", "subnet", "subnet-id", "subnet1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network", "network-id", "network1-id1", "network-name", "network1-name1");
+
+ Vertex vipipv6addresslist1 = graph.addVertex(T.label, "vip-ipv6-address-list", T.id, "7", "aai-node-type", "vip-ipv6-address-list", "vip-ipv6-address", "vip-ipv6-address2");
+ Vertex subnet2 = graph.addVertex(T.label, "subnet", T.id, "8", "aai-node-type", "subnet", "subnet-id", "subnet2");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "network-id", "network1-id2", "network-name", "network2-name2");
+
+ Vertex l3inter1ipv4addresslist1 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address1");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "11", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name3");
+ Vertex subnet3 = graph.addVertex(T.label, "subnet", T.id, "12", "aai-node-type", "subnet", "subnet-id", "subnet3");
+ Vertex l3network3_2 = graph.addVertex(T.label, "l3-network", T.id, "13", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network3_2-name3_2");
+
+ Vertex l3inter1ipv6addresslist1 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "14", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address1");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "15", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name4");
+ Vertex subnet4 = graph.addVertex(T.label, "subnet", T.id, "16", "aai-node-type", "subnet", "subnet-id", "subnet4");
+ Vertex l3network4_2 = graph.addVertex(T.label, "l3-network", T.id, "17", "aai-node-type", "l3-network", "network-id", "network3-id4", "network-name", "network4_2-name4_2");
+
+
+ Vertex vserv1 = graph.addVertex(T.id, "18", "aai-node-type", "vserver", "vserver-id", "vservId1", "vserver-name", "vservName1");
+ Vertex tenant1 = graph.addVertex(T.id, "19", "aai-node-type", "tenant", "tenant-id", "ten1", "tenant-name", "tenName1");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "20", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "21", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address2");
+ Vertex l3network5 = graph.addVertex(T.label, "l3-network", T.id, "22", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name3");
+ Vertex subnet5 = graph.addVertex(T.label, "subnet", T.id, "23", "aai-node-type", "subnet", "subnet-id", "subnet3");
+ Vertex l3network5_2 = graph.addVertex(T.label, "l3-network", T.id, "24", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network3_2-name3_2");
+
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "25", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address1");
+ Vertex l3network6 = graph.addVertex(T.label, "l3-network", T.id, "26", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name4");
+ Vertex subnet6 = graph.addVertex(T.label, "subnet", T.id, "27", "aai-node-type", "subnet", "subnet-id", "subnet4");
+ Vertex l3network6_2 = graph.addVertex(T.label, "l3-network", T.id, "28", "aai-node-type", "l3-network", "network-id", "network3-id4", "network-name", "network4_2-name4_2");
+
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "29", "aai-node-type", "pserver", "hostname", "pservername1");
+
+
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "30", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "31", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "32", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, servinst , gv);
+ rules.addEdge(g,gv,vnfc);
+ rules.addEdge(g,vnfc,vipipv4addresslist1);
+ rules.addEdge(g,vipipv4addresslist1,subnet1);
+ rules.addTreeEdge(g,subnet1,l3network1);
+ rules.addEdge(g,vnfc,vipipv6addresslist1);
+ rules.addEdge(g,vipipv6addresslist1,subnet2);
+ rules.addTreeEdge(g,subnet2,l3network2);
+ rules.addTreeEdge(g,vnfc,l3inter1ipv4addresslist1);
+ rules.addEdge(g,l3inter1ipv4addresslist1,l3network3);
+ rules.addEdge(g,l3inter1ipv4addresslist1,subnet3);
+ rules.addTreeEdge(g,subnet3,l3network3_2);
+ rules.addTreeEdge(g,vnfc,l3inter1ipv6addresslist1);
+ rules.addEdge(g,l3inter1ipv6addresslist1,l3network4);
+ rules.addEdge(g,l3inter1ipv6addresslist1,subnet4);
+ rules.addTreeEdge(g,subnet4,l3network4_2);
+ rules.addEdge(g,gv,vserv1);
+ rules.addTreeEdge(g,vserv1,tenant1);
+ rules.addTreeEdge(g,vserv1,linterface1);
+ rules.addTreeEdge(g,linterface1,l3inter1ipv4addresslist2);
+ rules.addEdge(g,l3inter1ipv4addresslist2,l3network5);
+ rules.addEdge(g,l3inter1ipv4addresslist2,subnet5);
+ rules.addTreeEdge(g,subnet5,l3network5_2);
+ rules.addTreeEdge(g,linterface1,l3inter1ipv6addresslist2);
+ rules.addEdge(g,l3inter1ipv6addresslist2,l3network6);
+ rules.addEdge(g,l3inter1ipv6addresslist2,subnet6);
+ rules.addTreeEdge(g,subnet6,l3network6_2);
+ rules.addEdge(g,vserv1,pserver1);
+ rules.addEdge(g,gv,pserver2);
+ rules.addTreeEdge(g,pserver2,pserverint);
+ rules.addEdge(g,pserverint,plink1);
+
+ expectedResult.add(servinst);
+ expectedResult.add(gv);
+ expectedResult.add(vnfc);
+ expectedResult.add(vipipv4addresslist1);
+ expectedResult.add(subnet1);
+ expectedResult.add(l3network1);
+ expectedResult.add(vipipv6addresslist1);
+ expectedResult.add(subnet2);
+ expectedResult.add(l3network2);
+ expectedResult.add(l3inter1ipv4addresslist1);
+ expectedResult.add(l3network3);
+ expectedResult.add(subnet3);
+ expectedResult.add(l3network3_2);
+ expectedResult.add(l3inter1ipv6addresslist1);
+ expectedResult.add(l3network4);
+ expectedResult.add(subnet4);
+ expectedResult.add(l3network4_2);
+ expectedResult.add(vserv1);
+ expectedResult.add(tenant1);
+ expectedResult.add(linterface1);
+ expectedResult.add(l3inter1ipv4addresslist2);
+ expectedResult.add(l3network5);
+ expectedResult.add(subnet5);
+ expectedResult.add(l3network5_2);
+ expectedResult.add(l3inter1ipv6addresslist2);
+ expectedResult.add(l3network6);
+ expectedResult.add(subnet6);
+ expectedResult.add(l3network6_2);
+ expectedResult.add(pserver1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserverint);
+ expectedResult.add(plink1);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "service-topology";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java
new file mode 100644
index 0000000..2d37d13
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SiteL3NetworkCloudRegionQueryTest extends QueryTest {
+
+ public SiteL3NetworkCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "clli2");
+ Vertex network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region");
+ Vertex network3 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, network);
+ rules.addEdge(g, region, network);
+ rules.addEdge(g, complex, network3);
+ rules.addEdge(g, complex2, network2);
+ rules.addEdge(g, region2, network2);
+
+ expectedResult.add(complex);
+ expectedResult.add(network);
+ expectedResult.add(region);
+ expectedResult.add(network3);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "site-l3network-cloudRegion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("physical-location-id", "clli");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java
new file mode 100644
index 0000000..9ddff8a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCloudRegionIdQueryTest extends QueryTest {
+
+ public SitesByCloudRegionIdQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex");
+ Vertex network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-region-id", "regionuuid");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex");
+ Vertex network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "regionuuid2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, network);
+ rules.addEdge(g, region, network);
+ rules.addEdge(g, complex2, network2);
+ rules.addEdge(g, region2, network2);
+
+ expectedResult.add(complex);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCloudRegionId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("cloud-region-id", "regionuuid");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java
new file mode 100644
index 0000000..3f7d404
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCountryFilterCloudRegionIdQueryTest extends QueryTest {
+
+
+ public SitesByCountryFilterCloudRegionIdQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli-100", "country", "countrycode-100");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network", "network-id", "networkId-100", "network-name", "networkName-100",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-100", "cloud-region-id", "cloudRegionId-100");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-200", "cloud-region-id", "cloudRegionId-200");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network", "network-id", "networkId-200", "network-name", "networkName-200",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex", "physical-location-id", "clli-200", "country", "countrycode-100");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, l3network);
+ rules.addEdge(g, cloudregion, l3network);
+ rules.addEdge(g, complex2, l3network2);
+ rules.addEdge(g, cloudregion2, l3network2);
+
+ expectedResult.add(complex);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCountryFilterCloudRegionId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "complex").has("country", "countrycode-100");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionId", "cloudRegionId-100");
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java
new file mode 100644
index 0000000..5c0e7fc
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCountryFilterCloudRegionVerQueryTest extends QueryTest {
+
+
+ public SitesByCountryFilterCloudRegionVerQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli-100", "country", "countrycode-100");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network", "network-id", "networkId-100", "network-name", "networkName-100",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-100", "cloud-region-id", "cloudRegionId-100",
+ "cloud-region-version", "cloudRegionVer-3.0");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "clli-200", "country", "countrycode-100");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network", "network-id", "networkId-200", "network-name", "networkName-200",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-200", "cloud-region-id", "cloudRegionId-200",
+ "cloud-region-version", "cloudRegionVer-2.5");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, l3network);
+ rules.addEdge(g, cloudregion, l3network);
+ rules.addEdge(g, complex2, l3network2);
+ rules.addEdge(g, cloudregion2, l3network2);
+
+ expectedResult.add(complex);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCountryFilterCloudRegionVer";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "complex").has("country", "countrycode-100");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionVersion", "cloudRegionVer-3.0");
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
index a99fa8f..5e3f7f5 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
@@ -108,8 +108,17 @@ public class TopologyDetailFromVserverQueryTest extends QueryTest {
}
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "cloud-region").has("cloud-region-id", "regionid0").has("cloud-owner", "cloudOwnername0").out("has").has("aai-node-type","tenant").has("tenant-id", "tenantid0").out("owns").has("aai-node-type","vserver").has("vserver-id", "vserverid0");
+ g.has("aai-node-type", "cloud-region")
+ .has("cloud-region-id", "regionid0")
+ .has("cloud-owner", "cloudOwnername0")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","tenant")
+ .has("tenant-id", "tenantid0")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","vserver")
+ .has("vserver-id", "vserverid0");
}
+
@Override
protected void addParam(Map<String, Object> params) {
return;
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
index 1891914..3b70fe1 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
@@ -95,7 +95,7 @@ public class TopologyDetailsQueryTest extends QueryTest {
rules.addEdge(g, owningentity, servinst);
rules.addEdge(g, project, servinst);
rules.addEdge(g, genericvnf, vnfc);
- rules.addEdge(g, vnfc, vserver);
+ rules.addEdge(g, genericvnf,vserver);
rules.addTreeEdge(g, linterface, vserver);
rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
rules.addEdge(g, l3inter1ipv4addresslist, subnet4);
@@ -116,7 +116,7 @@ public class TopologyDetailsQueryTest extends QueryTest {
rules.addEdge(g, owningentity1, servinst1);
rules.addEdge(g, project1, servinst1);
rules.addEdge(g, genericvnf1, vnfc1);
- rules.addEdge(g, vnfc1, vserver1);
+ rules.addEdge(g, genericvnf1,vserver1);
rules.addTreeEdge(g, linterface1, vserver1);
rules.addTreeEdge(g, l3inter1ipv4addresslist1, linterface1);
rules.addEdge(g, l3inter1ipv4addresslist1, subnet41);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
index b10abf3..12a7fd2 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
@@ -240,7 +240,14 @@ public class TopologyFromSubscriberNameAndServiceTypeTest extends QueryTest {
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "customer").has("global-customer-id", "global-customer-id-1").out("subscribesTo").has("aai-node-type","service-subscription").has("service-type", "service-type-1").out("hasInstance").has("aai-node-type","service-instance");
+ g
+ .has("aai-node-type", "customer")
+ .has("global-customer-id", "global-customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","service-subscription")
+ .has("service-type", "service-type-1")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","service-instance");
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java
new file mode 100644
index 0000000..1622f2e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologySummaryQueryTest extends QueryTest {
+
+ public TopologySummaryQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnfuuid");
+ Vertex vnfint = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface", "interface-name", "xe0/0/0");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "1", "aai-node-type", "vnfc");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver");
+ Vertex vserverint = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "xe0/0/0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "3", "aai-node-type", "tenant");
+ Vertex region = graph.addVertex(T.label, "could-region", T.id, "4", "aai-node-type", "cloud-region");
+ Vertex image = graph.addVertex(T.label, "image", T.id, "5", "aai-node-type", "image");
+ Vertex flavor = graph.addVertex(T.label, "flavor", T.id, "6", "aai-node-type", "flavor");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, vnf, vnfc);
+ rules.addEdge(g, vnf, vserver);
+ rules.addEdge(g, vnfc, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, region);
+ rules.addEdge(g, vserver, image);
+ rules.addEdge(g, vserver, flavor);
+ rules.addEdge(g, vserver, pserver);
+ rules.addEdge(g, pserver, complex);
+ rules.addEdge(g, region, complex);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addTreeEdge(g, vnf, vnfint);
+ rules.addTreeEdge(g, vserver, vserverint);
+
+ expectedResult.add(vnf);
+ expectedResult.add(vnfc);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(region);
+ expectedResult.add(image);
+ expectedResult.add(flavor);
+ expectedResult.add(pserver);
+ expectedResult.add(complex);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "topology-summary";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-id", "vnfuuid");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java
new file mode 100644
index 0000000..c434eb0
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class UcpeInstanceQueryTest extends QueryTest {
+
+ public UcpeInstanceQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "11", "aai-node-type", "pnf", "pnf-name", "pnfname");
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnfuuid");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pnfint = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver, complex);
+ rules.addEdge(g, pnf, complex);
+ rules.addEdge(g, vnf, pserver);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addTreeEdge(g, pnf, pnfint);
+
+ expectedResult.add(complex);
+ expectedResult.add(pserver);
+ //expectedResult.add(pnf);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "ucpe-instance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername");
+ //g.has("pnf-name", "pnfname");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
new file mode 100644
index 0000000..59aa3af
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class UcpeTopologyQueryTest extends QueryTest {
+ public UcpeTopologyQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pserverint1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "3", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "4", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "5", "aai-node-type", "tenant", "tenant-id", "tenantuuid", "tenant-name", "tenantname");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "6", "aai-node-type", "cloud-region", "cloud-region-id", "clouduuid", "cloud-region-owner", "cloudOwnername");
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf1uuid");
+ Vertex vnf1image = graph.addVertex(T.label, "vnf-image", T.id, "8", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnf1uuid");
+ Vertex vnf2image = graph.addVertex(T.label, "vnf-image", T.id, "10", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf2imageuuid");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "11", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex pnfint = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "13", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+ Vertex servinst1 = graph.addVertex(T.label, "service-instance", T.id, "14", "aai-node-type", "service-instance", "service-instance-id", "servinst1uuid");
+ Vertex servsub1 = graph.addVertex(T.label, "service-subscription", T.id, "15", "aai-node-type", "service-subscription", "service-type", "servType1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "16", "aai-node-type", "customer", "global-customer-id", "custuuid");
+ Vertex servinst2 = graph.addVertex(T.label, "service-instance", T.id, "17", "aai-node-type", "service-instance", "service-instance-id", "servinst2uuid");
+ Vertex servsub2 = graph.addVertex(T.label, "service-subscription", T.id, "18", "aai-node-type", "service-subscription", "service-type", "servType2");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver, complex);
+ rules.addTreeEdge(g, pserver, pserverint1);
+ rules.addTreeEdge(g, pserver, pserverint2);
+ rules.addEdge(g, pnf, complex);
+ rules.addTreeEdge(g, pnf, pnfint);
+ rules.addEdge(g, pserverint1, plink1);
+ rules.addEdge(g, pnfint, plink1);
+ rules.addEdge(g, vserver, pserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, pserver, vnf1);
+ rules.addEdge(g, vserver, vnf2);
+ rules.addEdge(g, vnf1, vnf1image);
+ rules.addEdge(g, vnf2, vnf2image);
+ rules.addEdge(g, vnf1, servinst1);
+ rules.addTreeEdge(g, servinst1, servsub1);
+ rules.addTreeEdge(g, servsub1, customer);
+ rules.addEdge(g, vnf2, servinst2);
+ rules.addTreeEdge(g, servinst2, servsub2);
+ rules.addTreeEdge(g, servsub2, customer);
+
+ expectedResult.add(pnf);
+ expectedResult.add(complex);
+ expectedResult.add(pnfint);
+ expectedResult.add(pserver);
+ expectedResult.add(pserverint1);
+ expectedResult.add(plink1);
+ expectedResult.add(vnf1);
+ expectedResult.add(vnf1image);
+ expectedResult.add(vnf2);
+ expectedResult.add(vnf2image);
+ expectedResult.add(servinst1);
+ expectedResult.add(servinst2);
+ expectedResult.add(servsub1);
+ expectedResult.add(servsub2);
+ expectedResult.add(customer);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "ucpe-topology";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java
index 003c4e0..9573d1f 100644
--- a/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java
@@ -78,7 +78,7 @@ public class AAIAppServletContextListenerTest {
* Test contextDestroyed.
*/
@Test(expected = NullPointerException.class)
- //@Ignore
+ @Ignore
public void testContextDestroyed(){
listener.contextDestroyed(arg);
assertTrue(logContains(Level.DEBUG, "AAI Server shutdown"));
diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
index 218d9ac..2fdb55e 100644
--- a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
+++ b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
@@ -105,3 +105,13 @@ aai.dmaap.workload.enableEventProcessing=true
aai.realtime.clients=RO,SDNC,MSO
aai.server.rebind=g
+
+#timeout for traversal enabled flag
+aai.traversal.timeoutenabled=true
+
+#timeout app specific
+aai.traversal.timeout.appspecific=JUNITTESTAPP1,-1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1
+
+#default timeout limit added for traversal if not overridden (in ms)
+aai.traversal.timeoutlimit=180000
+
diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties
index 11416ca..ba71275 100644
--- a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties
+++ b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties
@@ -25,8 +25,13 @@ AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of ty
AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s)
AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s)
AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2
-AAI_3008=5:6:ERROR:3008:400:3008:URI is not encoded in UTF-8
-AAI_3009=5:6:ERROR:3009:400:3002:Malformed URL
+AAI_3008=5:6:WARN:3008:400:3008:URI is not encoded in UTF-8
+AAI_3009=5:6:WARN:3009:400:3002:Malformed URL
+AAI_3010=5:6:WARN:3010:400:3002:Cannot write via this URL
+AAI_3011=5:6:WARN:3011:400:3000:Unknown XML namespace used in payload
+AAI_3012=5:6:WARN:3012:400:3012:Unrecognized AAI function
+AAI_3013=5:6:WARN:3013:400:3013:Query payload missing required parameters %1
+AAI_3014=5:6:WARN:3014:400:3014:Query payload is invalid %1
# pol errors
AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1
AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2
@@ -34,7 +39,7 @@ AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2
AAI_3300=5:1:WARN:3300:403:3300:Unauthorized
AAI_3301=5:1:WARN:3301:401:3301:Stale credentials
AAI_3302=5:1:WARN:3302:401:3301:Not authenticated
-AAI_3303=5:1:ERROR:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry
+AAI_3303=5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry
#--- aaigen: 4000-4099
AAI_4000=5:4:ERROR:4000:500:3002:Internal Error
@@ -44,23 +49,18 @@ AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file
AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file
AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter
AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service
-AAI_4007=5:4:ERROR:4007:500:3102:Input parsing error
+AAI_4007=5:4:WARN:4007:500:3102:Input parsing error
AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error
-AAI_4009=4:0:ERROR:4009:400:3000:Invalid X-FromAppId in header
-AAI_4010=4:0:ERROR:4010:400:3000:Invalid X-TransactionId in header
+AAI_4009=4:0:WARN:4009:400:3000:Invalid X-FromAppId in header
+AAI_4010=4:0:WARN:4010:400:3000:Invalid X-TransactionId in header
AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response
-AAI_4012=5:4:ERROR:4012:500:3002:Bad rule data in RestRules
-AAI_4013=5:4:ERROR:4013:500:3002:Error connecting to AAI REST API
-AAI_4014=4:0:ERROR:4014:400:3000:Invalid Accept header
-AAI_4015=4:0:ERROR:4015:400:3000:You must provide at least one indexed property
-AAI_4016=4:0:ERROR:4016:400:3000:The depth parameter must be a number or the string "all"
+AAI_4014=4:0:WARN:4014:400:3000:Invalid Accept header
+AAI_4015=4:0:WARN:4015:400:3000:You must provide at least one indexed property
+AAI_4016=4:0:WARN:4016:400:3000:The depth parameter must be a number or the string "all"
AAI_4017=5:2:INFO:4017:400:3000:Could not set property
-AAI_4018=5:2:ERROR:4018:400:3000:Unable to convert the string to integer
-#--- aaidbmap: 5101-5199
-AAI_5101=5:4:FATAL:5101:500:3002:Could not connect to database
+AAI_4018=5:2:WARN:4018:400:3000:Unable to convert the string to integer
+#--- aaidbmap: 5102-5199
AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open
-AAI_5103=5:4:ERROR:5103:500:3002:Unexpected error during commit
-AAI_5104=5:4:ERROR:5104:500:3002:Unexpected error during rollback
AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database
AAI_5106=5:4:WARN:5106:404:3001:Node not found
AAI_5107=5:2:WARN:5107:400:3000:Required information missing
@@ -77,14 +77,14 @@ AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data
AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data
AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value
AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted
-AAI_6111=5:4:ERROR:6111:400:3000:JSON processing error
+AAI_6111=5:4:WARN:6111:400:3000:JSON processing error
AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode()
AAI_6114=5:4:INFO:6114:404:3001:Node Not Found
AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType
AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property
AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated
-AAI_6118=5:4:ERROR:6118:400:3000:Required Field not passed.
-AAI_6120=5:4:ERROR:6120:400:3000:Bad Parameter Passed
+AAI_6118=5:4:WARN:6118:400:3000:Required Field not passed.
+AAI_6120=5:4:WARN:6120:400:3000:Bad Parameter Passed
AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data
AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request
AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate
@@ -111,6 +111,7 @@ AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found
AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph
AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship
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
#--- aaicsvp: 7101-7199
AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing
@@ -138,7 +139,7 @@ AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl
AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API
AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API
AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate
-AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
+#AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
#--- NotificationEvent, using UEB space
AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed
@@ -148,17 +149,24 @@ AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API
AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error
AAI_7403=5:4:WARN:7403:400:3001:Request error
AAI_7404=5:4:INFO:7404:404:3001:Node not found
+AAI_7405=5:4:WARN:7405:200:0:UUID not formatted correctly, generating UUID
+AAI_7406=5:4:ERROR:7406:400:7406:Request Timed Out
+
+#--- aaicsiovals: 7501-7599
+#AAI_7501=5:4:WARN:7501:500:3002:Error getting connection to CSI-OVALS
+AAI_7502=5:4:WARN:7502:500:3002:Bad parameter when trying to build request for CSI-OVALS
+AAI_7503=5:4:WARN:7503:500:3002:Error returned by CSI-OVALS
#--- aaiauth: 9101-9199
AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function
-AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
-AAI_9103=5:0:WARN:9103:403:3300:User not found
-AAI_9104=5:0:WARN:9104:401:3302:Authentication error
-AAI_9105=5:0:WARN:9105:403:3300:Authorization error
-AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
+#AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
+#AAI_9103=5:0:WARN:9103:403:3300:User not found
+#AAI_9104=5:0:WARN:9104:401:3302:Authentication error
+#AAI_9105=5:0:WARN:9105:403:3300:Authorization error
+#AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request
AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin
#--- aaiinstar: 9201-9299
-AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
+#AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread
diff --git a/aai-traversal/src/test/resources/logback.xml b/aai-traversal/src/test/resources/logback.xml
index cc64017..38499e0 100644
--- a/aai-traversal/src/test/resources/logback.xml
+++ b/aai-traversal/src/test/resources/logback.xml
@@ -22,237 +22,14 @@
-->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
- <contextName>${module.ajsc.namespace.name}</contextName>
- <jmxConfigurator />
- <property name="logDirectory" value="${AJSC_HOME}/logs" />
-
- <!-- Example evaluator filter applied against console appender -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> -->
- <level>ERROR</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n
- </pattern>
- </encoder>
- </appender>
- <appender name="METRIC"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>INFO</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <file>${logDirectory}/rest/metric.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/metric.log.%d{yyyy-MM-dd}</fileNamePattern>
- </rollingPolicy>
- <!-- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy> -->
- <encoder>
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="DEBUG"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>DEBUG</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <file>${logDirectory}/rest/debug.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
- </rollingPolicy>
- <!-- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>-->
- <encoder>
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="ERROR"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>WARN</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <file>${logDirectory}/rest/error.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/error.log.%d{yyyy-MM-dd}</fileNamePattern>
- </rollingPolicy>
- <!-- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>-->
- <encoder>
- <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n"</pattern> -->
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="AUDIT"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
- <evaluator>
- <matcher>
- <Name>audit</Name>
- <!-- filter out odd numbered statements -->
- <regex>co\=aairest</regex>
- </matcher>
- <expression>level == INFO &amp;&amp; audit.matches(formattedMessage)</expression>
- </evaluator>
- <OnMatch>ACCEPT</OnMatch>
- <OnMismatch>DENY</OnMismatch>
- </filter>
- <file>${logDirectory}/rest/audit.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/metric.log.%d{yyyy-MM-dd}</fileNamePattern>
- </rollingPolicy>
- <encoder>
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="auditLogs"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- </filter>
- <file>${logDirectory}/rest/audit.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/audit-${lrmRVer}-${lrmRO}-${Pid}.%d{yyyy-MM-dd}.log.zip
- </fileNamePattern>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern>
- </encoder>
- </appender>
-
- <appender name="perfLogs"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- </filter>
- <file>${logDirectory}/rest/perform.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/perform-${lrmRVer}-${lrmRO}-${Pid}.%d{yyyy-MM-dd}.log.zip
- </fileNamePattern>
- </rollingPolicy>
- <!-- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy> -->
- <encoder>
- <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern>
- </encoder>
- </appender>
-
- <!-- Spring related loggers -->
- <logger name="org.springframework" level="WARN" />
- <logger name="org.springframework.beans" level="WARN" />
- <logger name="org.springframework.web" level="WARN" />
- <logger name="com.blog.spring.jms" level="WARN" />
-
- <!-- AJSC Services (bootstrap services) -->
- <logger name="ajsc" level="WARN" />
- <logger name="ajsc.RouteMgmtService" level="WARN" />
- <logger name="ajsc.ComputeService" level="WARN" />
- <logger name="ajsc.VandelayService" level="WARN" />
- <logger name="ajsc.FilePersistenceService" level="WARN" />
- <logger name="ajsc.UserDefinedJarService" level="WARN" />
- <logger name="ajsc.UserDefinedBeansDefService" level="WARN" />
- <logger name="ajsc.LoggingConfigurationService" level="WARN" />
-
- <!-- AJSC related loggers (DME2 Registration, csi logging, restlet, servlet
- logging) -->
- <logger name="ajsc.utils" level="WARN" />
- <logger name="ajsc.utils.DME2Helper" level="WARN" />
- <logger name="ajsc.filters" level="WARN" />
- <logger name="ajsc.beans.interceptors" level="WARN" />
- <logger name="ajsc.restlet" level="WARN" />
- <logger name="ajsc.servlet" level="WARN" />
- <logger name="com.att.ajsc" level="WARN" />
- <logger name="com.att.ajsc.csi.logging" level="WARN" />
- <logger name="com.att.ajsc.filemonitor" level="WARN" />
-
- <!-- Other Loggers that may help troubleshoot -->
- <logger name="net.sf" level="WARN" />
- <logger name="org.apache.commons.httpclient" level="WARN" />
- <logger name="org.apache.commons" level="WARN" />
- <logger name="org.apache.coyote" level="WARN" />
- <logger name="org.apache.jasper" level="WARN" />
-
- <!-- Camel Related Loggers (including restlet/servlet/jaxrs/cxf logging.
- May aid in troubleshooting) -->
- <logger name="org.apache.camel" level="WARN" />
- <logger name="org.apache.cxf" level="WARN" />
- <logger name="org.apache.camel.processor.interceptor" level="WARN" />
- <logger name="org.apache.cxf.jaxrs.interceptor" level="WARN" />
- <logger name="org.apache.cxf.service" level="WARN" />
- <logger name="org.restlet" level="WARN" />
- <logger name="org.apache.camel.component.restlet" level="WARN" />
-
- <!-- logback internals logging -->
- <logger name="ch.qos.logback.classic" level="INFO" />
- <logger name="ch.qos.logback.core" level="INFO" />
-
- <appender name="ASYNC-audit" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>1000</queueSize>
- <discardingThreshold>0</discardingThreshold>
- <appender-ref ref="Audit-Record-Queue" />
- </appender>
-
- <appender name="ASYNC-perf" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>1000</queueSize>
- <discardingThreshold>0</discardingThreshold>
- <appender-ref ref="Performance-Tracker-Queue" />
- </appender>
-
- <!--
- <logger name="AuditRecord" level="INFO" additivity="FALSE">
- <appender-ref ref="ASYNC-audit" />
- <appender-ref ref="auditLogs" />
- </logger>
- <logger name="AuditRecord_DirectCall" level="INFO" additivity="FALSE">
- <appender-ref ref="ASYNC-audit" />
- <appender-ref ref="auditLogs" />
- </logger>
- <logger name="PerfTrackerRecord" level="INFO" additivity="FALSE">
- <appender-ref ref="ASYNC-perf" />
- <appender-ref ref="perfLogs" />
- </logger>
- -->
-
- <logger name="org.onap.aai" level="INFO" />
-
- <!--
- <logger name="org.onap.aai.util" level="WARN" />
- <logger name="org.onap.aai.rest" level="WARN" />
- <logger name="org.onap.aai.rest.Business" level="WARN" />
- -->
-
- <logger name="org.apache" level="WARN" />
- <logger name="org.zookeeper" level="WARN" />
- <logger name="com.thinkaurelius" level="WARN" />
-
- <root level="WARN">
- <appender-ref ref="DEBUG" />
- <appender-ref ref="ERROR" />
- <appender-ref ref="METRIC" />
- <appender-ref ref="AUDIT" />
- </root>
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n</pattern>
+ </encoder>
+ </appender>
+ <root level="INFO">
+ <appender-ref ref="CONSOLE"/>
+ </root>
</configuration>
diff --git a/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-linterface.json b/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-linterface.json
new file mode 100644
index 0000000..54fc44d
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-linterface.json
@@ -0,0 +1,57 @@
+{
+ "cloud-owner": "${cloud-owner}",
+ "cloud-region-id": "${cloud-region-id}",
+ "tenants": {
+ "tenant": [
+ {
+ "tenant-id": "${tenant-id}",
+ "tenant-name": "${tenant-name}",
+ "vservers": {
+ "vserver": [
+ {
+ "vserver-id": "${vserver-id}",
+ "vserver-name": "${vserver-name}",
+ "vserver-name2": "vserver-name-2",
+ "vserver-selflink": "vserver-selflink-1",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "volumes": {},
+ "l-interfaces": {
+ "l-interface": [
+ {
+ "interface-name": "${interface-name}",
+ "interface-role": "role",
+ "v6-wan-link-ip": "test-v6-wan-link-ip",
+ "selflink": "example-selflink-val-10559",
+ "interface-id": "example-interface-id-val",
+ "l3-interface-ipv4-address-list" : [ {
+ "l3-interface-ipv4-address" : "${ipv4-address}",
+ "l3-interface-ipv4-prefix-length" : 849,
+ "vlan-id-inner" : 174,
+ "vlan-id-outer" : 120,
+ "is-floating" : true
+ }],
+ "l3-interface-ipv6-address-list" : [ {
+ "l3-interface-ipv6-address" : "${ipv6-address}",
+ "l3-interface-ipv6-prefix-length" : 509,
+ "vlan-id-inner" : 890,
+ "vlan-id-outer" : 192,
+ "is-floating" : false
+ }],
+ "vlans" : {
+ "vlan" : [ {
+ "vlan-interface" : "${vlan-interface}",
+ "vlan-id-inner" : 948,
+ "vlan-id-outer" : 722,
+ "speed-value" : "oR8Zpuk5",
+ "speed-units" : "lZsf2I"
+ }]}
+ }]}
+
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/aai-traversal/src/test/resources/payloads/templates/custom-query.json b/aai-traversal/src/test/resources/payloads/templates/custom-query.json
new file mode 100644
index 0000000..6875a99
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/custom-query.json
@@ -0,0 +1,4 @@
+{
+ "start": [ "${start}" ],
+ "query": "query/${query}"
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/templates/gremlin-query.json b/aai-traversal/src/test/resources/payloads/templates/gremlin-query.json
new file mode 100644
index 0000000..b163261
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/gremlin-query.json
@@ -0,0 +1,4 @@
+{
+ "gremlin": "${gremlin-query}"
+}
+
diff --git a/pom.xml b/pom.xml
index 74d4e60..25687fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,8 @@
<cxf.version>3.0.4</cxf.version>
<swmpkgversion>0.0.1</swmpkgversion>
<snapshot.file>int1-data.graphson</snapshot.file>
+ <aai.core.version>1.2.1-SNAPSHOT</aai.core.version>
+ <aai.schema.version>1.2.1-SNAPSHOT</aai.schema.version>
</properties>
<repositories>