summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aai-traversal/bundleconfig-local/etc/query/stored-queries.properties155
-rw-r--r--aai-traversal/pom.xml18
-rw-r--r--aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java6
-rw-r--r--aai-traversal/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java4
-rw-r--r--aai-traversal/src/main/java/org/openecomp/aai/rest/search/SearchProvider.java4
-rw-r--r--aai-traversal/src/main/resources/docker/Dockerfile93
-rw-r--r--aai-traversal/src/main/resources/docker/docker-entrypoint.sh110
-rw-r--r--aai-traversal/src/main/resources/docker/init-chef.sh30
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java983
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java608
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java148
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptorTest.java203
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptorTest.java110
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java73
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptorTest.java62
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java155
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java63
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/ModelAndNamedQueryRestProviderTest.java185
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/MsoRequestVfModuleTest.java96
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java68
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java75
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/PendingTopologyDetailTest.java159
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java103
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java101
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java82
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/SearchProviderTest.java266
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailFromVserverQueryTest.java116
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailsQueryTest.java167
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java67
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java135
-rw-r--r--aai-traversal/src/test/resources/payloads/named-queries/named-query.json18
-rw-r--r--pom.xml10
32 files changed, 4262 insertions, 211 deletions
diff --git a/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties b/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
index bf4753a..6a7c344 100644
--- a/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
+++ b/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
@@ -207,7 +207,7 @@ vserverlogicallink-frompServer=builder.createEdgeTraversal(EdgeType.COUSIN, 'pse
.createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface')\
.createEdgeTraversal(EdgeType.COUSIN, 'l-interface', 'logical-link')\
.store('x').cap('x').unfold().dedup()
-
+
service-fromPserverandSubsName=builder.createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'vserver')\
.createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf')\
.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').where(\
@@ -238,15 +238,7 @@ spaas-topology-fromServiceInstance=builder.createEdgeTraversal(EdgeType.COUSIN,
vnfs-fromServiceInstance=builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf')\
.store('x').cap('x').unfold().dedup()
-
-
-vnfs-fromPserver=builder.where(\
- builder.newInstance().union(\
- builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pserver').getVerticesByProperty('hostname', hostname),\
- builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').getVerticesByProperty('hostname', hostname)\
- )\
- ).store('x').cap('x').unfold().dedup()
-
+
linked-devices=builder.store('x').union(\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface'),\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'lag-interface'),\
@@ -272,3 +264,146 @@ linked-devices=builder.store('x').union(\
builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver')\
).dedup().simplePath()\
).store('x').cap('x').unfold().dedup()
+vnfs-fromPserver=builder.where(\
+ builder.newInstance().union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pserver').getVerticesByProperty('hostname', hostname),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').getVerticesByProperty('hostname', hostname)\
+ )\
+ ).store('x').cap('x').unfold().dedup()
+
+network-name-fromNetwork-role=builder.createEdgeTraversal(EdgeType.COUSIN, 'cloud-region', 'l3-network')\
+ .getVerticesByProperty('network-role', networkRole).store('x')\
+ .createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'network-policy').store('x')\
+ .cap('x').unfold().dedup()
+
+vserver-fromVnf=builder.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc')\
+ .getVerticesByProperty('nfc-function', nfcFunction).store('x')\
+ .createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x')\
+ .createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x')\
+ .union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x')\
+ ).cap('x').unfold().dedup()
+
+cloud-region-fromVnf=builder.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()
+
+topology-detail-fromVserver=builder.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'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf').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')\
+ )\
+).cap('x').unfold().dedup()
+
+topology-detail=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()
+
+pending-topology-detail=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')\
+ .union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', '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, 'vnfc', '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.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')\
+ ).dedup()\
+ ).cap('x').unfold().dedup()
+
+pserver-fromConfiguration=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()
+
+pserver-fromConfigurationFilterInterfaceId=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()
+
+fn-topology=builder.union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'line-of-business', 'generic-vnf').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').store('x')\
+ ).dedup()\
+ .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()
+so-request-vfModule=builder.store('x').union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vf-module', 'generic-vnf').store('x')\
+ .createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vf-module', 'vserver')\
+ .createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vf-module', 'volume-group').store('x')\
+ ).cap('x').unfold().dedup()
+
+owning-entity-fromService-instance=builder.createEdgeTraversal(EdgeType.COUSIN,'service-instance', 'owning-entity').store('x').cap('x').unfold().dedup()
+
+queryvnfFromModelbyRegion=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() \ No newline at end of file
diff --git a/aai-traversal/pom.xml b/aai-traversal/pom.xml
index 3822a3f..724b2db 100644
--- a/aai-traversal/pom.xml
+++ b/aai-traversal/pom.xml
@@ -11,10 +11,10 @@
<artifactId>aai-traversal</artifactId>
<name>aai-traversal</name>
<url>http://maven.apache.org</url>
+ <version>1.1.0-SNAPSHOT</version>
<properties>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
- <sitePath>/content/sites/site/${project.groupId}/${project.artifactId}/${project.version}</sitePath>
<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>
@@ -29,22 +29,6 @@
<sonar.jacoco.reportMissing.force.zero>false</sonar.jacoco.reportMissing.force.zero>
<sonar.projectVersion>${project.version}</sonar.projectVersion>
</properties>
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>ECOMP Release Repository</name>
- <url>${nexusproxy}/content/repositories/releases/</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>ECOMP Snapshot Repository</name>
- <url>${nexusproxy}/content/repositories/snapshots/</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
<dependencies>
<dependency>
<groupId>org.onap.aai.aai-common</groupId>
diff --git a/aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java b/aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java
index 32e8cbe..4b0f24d 100644
--- a/aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java
+++ b/aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java
@@ -942,10 +942,8 @@ public class SearchGraph {
invItemList.add(invItem);
}
}
- if (invItemList != null) {
- inventoryItems.set("inventoryResponseItem", invItemList);
- inventoryItem.set("inventoryResponseItems", inventoryItems);
- }
+ inventoryItems.set("inventoryResponseItem", invItemList);
+ inventoryItem.set("inventoryResponseItems", inventoryItems);
}
}
return inventoryItem;
diff --git a/aai-traversal/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java b/aai-traversal/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java
index 958639f..8a9362e 100644
--- a/aai-traversal/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java
+++ b/aai-traversal/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java
@@ -95,7 +95,7 @@ public class AAILogJAXRSInInterceptor extends JAXRSInInterceptor {
ErrorLogHelper.logException(e1);
}
- if (uri.contains(EchoResponse.echoPath)) {
+ if ((uri != null) && (uri.contains(EchoResponse.echoPath))) {
// if it's a health check, we don't want to log ANYTHING if it's a lightweight one
if (query == null) {
if (message.getExchange().containsKey("AAI_LOGGING_HBASE_ENABLED")) {
@@ -107,7 +107,7 @@ public class AAILogJAXRSInInterceptor extends JAXRSInInterceptor {
go = false;
}
}
- else if (uri.contains("/translog/")) {
+ else if ((uri != null) && (uri.contains("/translog/"))) {
// if it's a translog query, we don't want to log the responses
if (message.getExchange().containsKey("AAI_LOGGING_HBASE_LOGRESPONSE")) {
message.getExchange().remove("AAI_LOGGING_HBASE_LOGRESPONSE");
diff --git a/aai-traversal/src/main/java/org/openecomp/aai/rest/search/SearchProvider.java b/aai-traversal/src/main/java/org/openecomp/aai/rest/search/SearchProvider.java
index ee6b1ab..4330db1 100644
--- a/aai-traversal/src/main/java/org/openecomp/aai/rest/search/SearchProvider.java
+++ b/aai-traversal/src/main/java/org/openecomp/aai/rest/search/SearchProvider.java
@@ -105,7 +105,7 @@ public class SearchProvider extends RESTAPI {
//only consider header value for search
DBConnectionType type = this.determineConnectionType("force-cache", realTime);
final Version version;
- if (versionParam.equals("latest")) {
+ if ("latest".equals(versionParam)) {
version = AAIProperties.LATEST;
} else {
version = Version.valueOf(versionParam);
@@ -197,7 +197,7 @@ public class SearchProvider extends RESTAPI {
DBConnectionType type = this.determineConnectionType("force-cache", realTime);
final Version version;
- if (versionParam.equals("latest")) {
+ if ("latest".equals(versionParam)) {
version = AAIProperties.LATEST;
} else {
version = Version.valueOf(versionParam);
diff --git a/aai-traversal/src/main/resources/docker/Dockerfile b/aai-traversal/src/main/resources/docker/Dockerfile
index 596c71d..dc28e15 100644
--- a/aai-traversal/src/main/resources/docker/Dockerfile
+++ b/aai-traversal/src/main/resources/docker/Dockerfile
@@ -1,88 +1,31 @@
-FROM ubuntu:14.04
+FROM aaionap/aai-common:1.1.0
-ENV DEBIAN_FRONTEND noninteractive
-
-ARG HTTP_PROXY
-ARG HTTPS_PROXY
-
-ENV HTTP_PROXY ${HTTP_PROXY}
-ENV HTTPS_PROXY ${HTTPS_PROXY}
-ENV https_proxy ${HTTPS_PROXY}
-ENV http_proxy ${HTTP_PROXY}
-
-# Setup JAVA_HOME, this is useful for docker commandline
-ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
-
-# Install all the application requirements such as curl ksh and git
-# Also install the chef and then remove it in one RUN command
-# Because the docker files work like git commits and each command is committed
-# So removing the chef in a different command will still have its in its build image
-# Its good to be optimizing and removing any files that are not needed for docker images
-# for the best possible performance out of your image
-
-RUN if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf; fi && \
- if [ ! -z ${HTTPS_PROXY} ]; then echo "Acquire::https::proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf; fi && \
- apt-get update && \
- apt-get install -y software-properties-common uuid-runtime && \
- apt-get install --reinstall ca-certificates && \
- sudo -E add-apt-repository ppa:openjdk-r/ppa && \
- apt-get update && \
- apt-get -qq install -y openjdk-8-jre-headless git curl ksh && \
- curl -k -LO https://packages.chef.io/stable/ubuntu/14.04/chefdk_0.17.17-1_amd64.deb || \
- curl --tlsv1 -LO https://packages.chef.io/stable/ubuntu/14.04/chefdk_0.17.17-1_amd64.deb && \
- dpkg -i chefdk_0.17.17-1_amd64.deb && \
- rm chefdk_0.17.17-1_amd64.deb && \
- rm -rf /var/lib/apt/lists/*
+RUN mkdir -p /opt/aaihome/aaiadmin /opt/aai/logroot/AAI-RES /opt/app/aai-traversal/bin /opt/app/aai-traversal/extApps;
# Add the proper files into the docker image from your build
-ADD ./opt/app /opt/app
-ADD ./commonLibs/ /opt/app/commonLibs/
-ADD init-chef.sh /init-chef.sh
-ADD docker-entrypoint.sh /docker-entrypoint.sh
-ADD aai.sh /etc/profile.d/aai.sh
-
-# Expose the ports for outside linux to use
-# 8446 is the important one to be used
-
-EXPOSE 8446
-
-# Create the /var/chef if it doesn't exist
-WORKDIR /var/chef
-
-# Create the directory structure of aai application resembling the development server
-# hard-coding path to match ajsc version
+ADD ./opt/app/aai-traversal /opt/app/aai-traversal
+ADD ./commonLibs/ /opt/app/commonLibs/
+ADD init-chef.sh /opt/app/aai-traversal/init-chef.sh
+ADD docker-entrypoint.sh /opt/app/aai-traversal/docker-entrypoint.sh
+ADD aai.sh /etc/profile.d/aai.sh
-RUN chmod 755 /init-chef.sh /docker-entrypoint.sh && chmod 644 /etc/profile.d/aai.sh && \
- mkdir /opt/aaihome && \
- useradd -r -ms /bin/bash -d /opt/aaihome/aaiadmin aaiadmin && \
- mkdir -p /opt/app/${project.artifactId} && \
- chown aaiadmin:aaiadmin /opt/app/${project.artifactId} && \
- chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId} && \
- mkdir -p /opt/aai/logroot && \
- chown -R aaiadmin:aaiadmin /opt/aai/logroot && \
- ln -s /opt/app/${project.artifactId}/bin scripts && \
- mkdir -p /opt/app/${project.artifactId}/extApps && chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId}/extApps && \
- find /opt/app/${project.artifactId}/bin -name "*.sh" -exec chmod 755 {} + && \
- chown aaiadmin:aaiadmin /docker-entrypoint.sh && \
- chown -R aaiadmin:aaiadmin /var/chef && \
- mkdir -p /opt/aai/logroot/AAI-GQ && \
- chown aaiadmin:aaiadmin /opt/aai/logroot/AAI-GQ && \
- ln -s /opt/aai/logroot/AAI-GQ /opt/app/${project.artifactId}/logs && \
- chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId}/logs
+# Change the permissions of aai shell script and all scripts in the microservice to be executable
+RUN chmod 644 /etc/profile.d/aai.sh && \
+ find /opt/app/aai-traversal -name "*.sh" -exec chmod 755 {} +
+# Set the log directory to be mountable so the logs will be persisted
VOLUME /opt/aai/logroot/AAI-GQ
-WORKDIR /
+# Expose the ports that needs to be available from the container
+EXPOSE 8447
-USER aaiadmin
+# During the startup of the container, this will be the starting directory
+WORKDIR /opt/app/aai-traversal
# When the container is started this is the entrypoint script
# that docker will run. Make sure this script doesn't end abruptly
-# If you want the container running even if the main application stops
-# You can run a ever lasting process like tail -f /dev/null
-# Or something like that at the end of the docker-entrypoint script
-# So if the main application you are planning on running fails
-# the docker container keeps on running forever
+# Docker entrypoint will run exec command to make that main process
+# Using the exec form here will ensure the java process is main
-ENTRYPOINT ./docker-entrypoint.sh
+ENTRYPOINT ["/bin/bash", "/opt/app/aai-traversal/docker-entrypoint.sh"]
diff --git a/aai-traversal/src/main/resources/docker/docker-entrypoint.sh b/aai-traversal/src/main/resources/docker/docker-entrypoint.sh
index 0f14860..5823105 100644
--- a/aai-traversal/src/main/resources/docker/docker-entrypoint.sh
+++ b/aai-traversal/src/main/resources/docker/docker-entrypoint.sh
@@ -18,39 +18,99 @@
# ============LICENSE_END=========================================================
###
-cd /var/chef;
+# Set the current path to be the application home and common libs home
+export APP_HOME=$(pwd);
+COMMONLIBS_HOME="/opt/app/commonLibs";
-CHEF_CONFIG_REPO=${CHEF_CONFIG_REPO:-aai-config};
+export CHEF_CONFIG_REPO=${CHEF_CONFIG_REPO:-aai-config};
+export CHEF_GIT_URL=${CHEF_GIT_URL:-http://gerrit.onap.org/r/aai};
+export CHEF_CONFIG_GIT_URL=${CHEF_CONFIG_GIT_URL:-$CHEF_GIT_URL};
+export CHEF_DATA_GIT_URL=${CHEF_DATA_GIT_URL:-$CHEF_GIT_URL};
-CHEF_GIT_URL=${CHEF_GIT_URL:-http://nexus.onap.org/r/aai};
+export RESOURCES_HOSTNAME=${RESOURCES_HOSTNAME:-aai-resources.api.simpledemo.openecomp.org};
+export RESOURCES_PORT=${RESOURCES_PORT:-8447};
-CHEF_CONFIG_GIT_URL=${CHEF_CONFIG_GIT_URL:-$CHEF_GIT_URL};
-CHEF_DATA_GIT_URL=${CHEF_DATA_GIT_URL:-$CHEF_GIT_URL};
+USER_ID=${LOCAL_USER_ID:-9001}
-if [ ! -d "aai-config" ]; then
+if [ $(cat /etc/passwd | grep aaiadmin | wc -l) -eq 0 ]; then
+ useradd --shell=/bin/bash -u ${USER_ID} -o -c "" -m aaiadmin || {
+ echo "Unable to create the user id for ${USER_ID}";
+ exit 1;
+ }
+fi;
- git clone --depth 1 -b ${CHEF_BRANCH} --single-branch ${CHEF_CONFIG_GIT_URL}/${CHEF_CONFIG_REPO}.git aai-config || {
- echo "Error: Unable to clone the aai-config repo with url: ${CHEF_GIT_URL}/${CHEF_CONFIG_REPO}.git";
- exit;
- }
-
- (cd aai-config/cookbooks/${project.artifactId}/ && \
- for f in $(ls); do mv $f ../; done && \
- cd ../ && rmdir ${project.artifactId});
-fi
+chown -R aaiadmin:aaiadmin /opt/app /var/chef /opt/aai/logroot
+
+gosu aaiadmin ./init-chef.sh
+
+httpPort=8086;
+httpsPort=8446;
+
+cd ${APP_HOME};
+
+# If the variable DISABLE_UPDATE_QUERY is empty
+# then the update query date shell script will be ran
+# This makes it configurable to run update query or not
-if [ ! -d "aai-data" ]; then
+if [ -z ${DISABLE_UPDATE_QUERY} ]; then
- git clone --depth 1 -b ${CHEF_BRANCH} --single-branch ${CHEF_DATA_GIT_URL}/aai-data.git aai-data || {
- echo "Error: Unable to clone the aai-data repo with url: ${CHEF_GIT_URL}";
- exit;
- }
+ while ! nc -z ${RESOURCES_HOSTNAME} ${RESOURCES_PORT} ;
+ do
+ echo "Waiting for resources to be up";
+ sleep 5;
+ done
+ UPDATE_QUERY_RAN_FILE="updateQueryRan.txt";
+
+ if [ ! -f ${UPDATE_QUERY_RAN_FILE} ]; then
+ gosu aaiadmin /opt/app/aai-traversal/bin/install/updateQueryData.sh
+ touch ${UPDATE_QUERY_RAN_FILE};
+ fi
fi
-chef-solo \
- -c /var/chef/aai-data/chef-config/dev/.knife/solo.rb \
- -j /var/chef/aai-config/cookbooks/runlist-${project.artifactId}.json \
- -E ${AAI_CHEF_ENV};
+CP=${COMMONLIBS_HOME}/*;
+CP="$CP":${APP_HOME}/etc;
+CP="$CP":${APP_HOME}/lib/*;
+CP="$CP":${APP_HOME}/extJars/logback-access-1.1.7.jar;
+CP="$CP":${APP_HOME}/extJars/logback-core-1.1.7.jar;
+CP="$CP":${APP_HOME}/extJars/aai-core-${AAI_CORE_VERSION}.jar;
+
+# You can add additional jvm options by adding environment variable JVM_PRE_OPTS
+# If you need to add more jvm options at the end then you can use JVM_POST_OPTS
+JVM_OPTS="${JVM_PRE_OPTS} ${JVM_OPTS}";
+JVM_OPTS="${JVM_OPTS} -server -XX:NewSize=512m -XX:MaxNewSize=512m";
+JVM_OPTS="${JVM_OPTS} -XX:SurvivorRatio=8";
+JVM_OPTS="${JVM_OPTS} -XX:+DisableExplicitGC -verbose:gc -XX:+UseParNewGC";
+JVM_OPTS="${JVM_OPTS} -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled";
+JVM_OPTS="${JVM_OPTS} -XX:+UseConcMarkSweepGC -XX:-UseBiasedLocking";
+JVM_OPTS="${JVM_OPTS} -XX:ParallelGCThreads=4";
+JVM_OPTS="${JVM_OPTS} -XX:LargePageSizeInBytes=128m ";
+JVM_OPTS="${JVM_OPTS} -XX:+PrintGCDetails -XX:+PrintGCTimeStamps";
+JVM_OPTS="${JVM_OPTS} -Xloggc:${APP_HOME}/logs/gc/graph-query_gc.log";
+JVM_OPTS="${JVM_OPTS} -XX:+HeapDumpOnOutOfMemoryError";
+JVM_OPTS="${JVM_OPTS} ${JVM_POST_OPTS}";
+
+# You can add additional java options by adding environment variable JAVA_PRE_OPTS
+# If you need to add more jvm options at the end then you can use JAVA_POST_OPTS
+JAVA_OPTS="${JAVA_PRE_OPTS} ${JAVA_OPTS}";
+JAVA_OPTS="${JAVA_OPTS} -Dsun.net.inetaddr.ttl=180";
+JAVA_OPTS="${JAVA_OPTS} -Dhttps.protocols=TLSv1.1,TLSv1.2";
+JAVA_OPTS="${JAVA_OPTS} -DSOACLOUD_SERVICE_VERSION=1.0.1";
+JAVA_OPTS="${JAVA_OPTS} -DAJSC_HOME=${APP_HOME}";
+JAVA_OPTS="${JAVA_OPTS} -DAJSC_CONF_HOME=${APP_HOME}/bundleconfig";
+JAVA_OPTS="${JAVA_OPTS} -DAJSC_SHARED_CONFIG=${APP_HOME}/bundleconfig";
+JAVA_OPTS="${JAVA_OPTS} -DAFT_HOME=${APP_HOME}";
+JAVA_OPTS="${JAVA_OPTS} -DAAI_CORE_VERSION=${AAI_CORE_VERSION}";
+JAVA_OPTS="${JAVA_OPTS} -Daai-core.version=${AAI_CORE_VERSION}";
+JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=${APP_HOME}/bundleconfig/etc/logback.xml";
+JAVA_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}";
+
+JAVA_ARGS="${JAVA_PRE_ARGS} ${JAVA_ARGS}";
+JAVA_ARGS="${JAVA_ARGS} context=/";
+JAVA_ARGS="${JAVA_ARGS} port=$httpPort";
+JAVA_ARGS="${JAVA_ARGS} sslport=$httpsPort";
+JAVA_ARGS="${JAVA_ARGS} ${JAVA_POST_ARGS}";
-java -cp ${CLASSPATH}:/opt/app/commonLibs/*:/opt/app/aai-traversal/etc:/opt/app/aai-traversal/lib/*:/opt/app/aai-traversal/extJars/logback-access-1.1.7.jar:/opt/app/aai-traversal/extJars/logback-core-1.1.7.jar:/opt/app/aai-traversal/extJars/aai-core-${AAI_CORE_VERSION}.jar -server -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8 -XX:+DisableExplicitGC -verbose:gc -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:-UseBiasedLocking -XX:ParallelGCThreads=4 -XX:LargePageSizeInBytes=128m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Dsun.net.inetaddr.ttl=180 -XX:+HeapDumpOnOutOfMemoryError -Dhttps.protocols=TLSv1.1,TLSv1.2 -DSOACLOUD_SERVICE_VERSION=1.0.1 -DAJSC_HOME=/opt/app/aai-traversal/ -DAJSC_CONF_HOME=/opt/app/aai-traversal/bundleconfig -DAJSC_SHARED_CONFIG=/opt/app/aai-traversal/bundleconfig -DAFT_HOME=/opt/app/aai-traversal -DAAI_CORE_VERSION=${AAI_CORE_VERSION} -Daai-core.version=${AAI_CORE_VERSION} -Dlogback.configurationFile=/opt/app/aai-traversal/bundleconfig/etc/logback.xml -Xloggc:/opt/app/aai-traversal/logs/ajsc-jetty/gc/graph-query_gc.log com.att.ajsc.runner.Runner context=/ port=8086 sslport=8446
+JAVA_CMD="exec gosu aaiadmin java";
+# Run the following command as aai-admin using gosu and make that process main
+${JAVA_CMD} -cp ${CLASSPATH}:${CP} ${JVM_OPTS} ${JAVA_OPTS} com.att.ajsc.runner.Runner ${JAVA_ARGS} "$@"
diff --git a/aai-traversal/src/main/resources/docker/init-chef.sh b/aai-traversal/src/main/resources/docker/init-chef.sh
index 112b0b3..0e10055 100644
--- a/aai-traversal/src/main/resources/docker/init-chef.sh
+++ b/aai-traversal/src/main/resources/docker/init-chef.sh
@@ -25,8 +25,30 @@
#
##############################################################################
-#echo "AAI_CHEF_ENV=${AAI_CHEF_ENV}" >> /etc/environment
-#echo "AAI_CHEF_LOC=${AAI_CHEF_LOC}" >> /etc/environment
-#touch /root/.bash_profile
-chef-solo -c /var/chef/aai-data/chef-config/dev/.knife/solo.rb -j /var/chef/aai-config/cookbooks/runlist-app-server.json -E ${AAI_CHEF_ENV}
+cd /var/chef;
+if [ ! -d "aai-config" ]; then
+
+ git clone --depth 1 -b ${CHEF_BRANCH} --single-branch ${CHEF_CONFIG_GIT_URL}/${CHEF_CONFIG_REPO}.git aai-config || {
+ echo "Error: Unable to clone the aai-config repo with url: ${CHEF_GIT_URL}/${CHEF_CONFIG_REPO}.git";
+ exit;
+ }
+
+ (cd aai-config/cookbooks/aai-traversal/ && \
+ for f in $(ls); do mv $f ../; done && \
+ cd ../ && rmdir aai-traversal);
+fi
+
+if [ ! -d "aai-data" ]; then
+
+ git clone --depth 1 -b ${CHEF_BRANCH} --single-branch ${CHEF_DATA_GIT_URL}/aai-data.git aai-data || {
+ echo "Error: Unable to clone the aai-data repo with url: ${CHEF_GIT_URL}";
+ exit;
+ }
+
+ chef-solo \
+ -c /var/chef/aai-data/chef-config/dev/.knife/solo.rb \
+ -j /var/chef/aai-config/cookbooks/runlist-aai-traversal.json \
+ -E ${AAI_CHEF_ENV};
+
+fi
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
new file mode 100644
index 0000000..b255916
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
@@ -0,0 +1,983 @@
+/*-
+ * ============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.openecomp.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.openecomp.aai.db.DbMethHelper;
+import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.openecomp.aai.serialization.db.DBSerializer;
+import org.openecomp.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/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
index 7579218..64e723b 100644
--- a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
+++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
@@ -1,67 +1,541 @@
-/*-
- * ============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.openecomp.aai.dbgraphgen;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-
-public class ModelBasedProcessingTest {
-
- @Mock private static TransactionalGraphEngine dbEngine;
- private static Loader loader;
- @Mock private static DBSerializer serializer;
- @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);
- }
-
- @Test
- public void testPropNameChange() 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);
- }
-}
+/*-
+ * ============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.openecomp.aai.dbgraphgen;
+
+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.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.internal.exceptions.MockitoLimitations;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.openecomp.aai.db.DbMethHelper;
+import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.Introspector;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.openecomp.aai.parsers.exceptions.AAIIdentityMapParseException;
+import org.openecomp.aai.query.builder.GraphTraversalBuilder;
+import org.openecomp.aai.query.builder.QueryBuilder;
+import org.openecomp.aai.query.builder.TraversalQuery;
+import org.openecomp.aai.schema.enums.PropertyMetadata;
+import org.openecomp.aai.serialization.db.DBSerializer;
+import org.openecomp.aai.serialization.db.EdgeType;
+import org.openecomp.aai.serialization.engines.QueryStyle;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ModelBasedProcessingTest {
+
+ @Mock private static TransactionalGraphEngine dbEngine;
+ private static Loader loader;
+ @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() {
+ mockProcessor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ 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);
+ }
+
+ @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<>();
+
+ 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 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<>();
+
+ Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
+ "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
+ }
+
+ @Test
+ 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 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 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);
+ }
+
+ //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","");
+
+
+ }
+
+ //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");
+
+
+ }
+
+ //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(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);
+ }
+
+ //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);
+ }
+
+ //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(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(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 = 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(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 = 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 = 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 = 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 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 = 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 getNamedQueryExtraDataLookupTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",null,vertex,
+ "");
+ }
+
+ @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(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/openecomp/aai/dbgraphmap/SearchGraphTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java
new file mode 100644
index 0000000..11804e5
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java
@@ -0,0 +1,148 @@
+/*-
+ * ============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.openecomp.aai.dbgraphmap;
+
+import com.thinkaurelius.titan.core.TitanGraph;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.dbmap.DBConnectionType;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.serialization.db.DBSerializer;
+import org.openecomp.aai.serialization.engines.QueryStyle;
+import org.openecomp.aai.serialization.engines.TitanDBEngine;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
+
+import javax.ws.rs.core.*;
+import java.util.*;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class SearchGraphTest {
+
+ private SearchGraph searchGraph;
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ private final static Version version = Version.getLatest();
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private Loader loader;
+ private TitanGraph graph;
+
+ private Graph tx;
+
+ private GraphTraversalSource g;
+ private TransactionalGraphEngine dbEngine;
+
+ @Before
+ public void setup(){
+
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+
+ searchGraph = new SearchGraph();
+
+ httpHeaders = mock(HttpHeaders.class);
+ uriInfo = mock(UriInfo.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);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new TitanDBEngine(
+ queryStyle,
+ type,
+ loader);
+ }
+
+ @Test(expected = AAIException.class)
+ public void testRunGenericQueryFailWhenInvalidRelationshipList() throws AAIException {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ Response response = searchGraph.runGenericQuery(httpHeaders, "cloud-region", keys, includeStrings, 1, dbEngine, loader, urlBuilder);
+ System.out.println(response);
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptorTest.java b/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptorTest.java
new file mode 100644
index 0000000..d265299
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptorTest.java
@@ -0,0 +1,203 @@
+/*-
+ * ============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.openecomp.aai.interceptors;
+
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.*;
+
+public class AAILogJAXRSInInterceptorTest {
+
+ private AAILogJAXRSInInterceptor aaiLogJAXRSInInterceptor;
+
+ private Message message;
+ private Exchange exchange;
+ private InputStream is;
+ private Map<String, List<String>> headers;
+
+
+ @Before
+ public void setup(){
+
+ aaiLogJAXRSInInterceptor = new AAILogJAXRSInInterceptor();
+
+ message = mock(Message.class);
+ exchange = spy(new ExchangeImpl());
+
+ is = getClass().getClassLoader().getResourceAsStream("logback.xml");
+
+ headers = new HashMap<>();
+ headers.put("X-FromAppId", Arrays.asList("JUNIT"));
+ headers.put("X-TransactionId", Arrays.asList("JUNIT"));
+ headers.put("Content-Type", Arrays.asList("application/json"));
+ headers.put("Accept", Arrays.asList("application/json"));
+ }
+
+ @Test
+ public void testHandleMessageWhenNotCamelRequest() throws IOException {
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(InputStream.class)).thenReturn(is);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+
+ when(message.get("CamelHttpUrl")).thenReturn("/somestring");
+ aaiLogJAXRSInInterceptor.handleMessage(message);
+ }
+
+ @Test
+ public void testHandleMessageWhenUUIDHasMultiple() throws IOException {
+
+ Map<String, List<String>> headers = new HashMap<>();
+
+ headers.put("X-FromAppId", Arrays.asList("JUNIT"));
+ headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja"));
+ headers.put("Content-Type", Arrays.asList("application/json"));
+ headers.put("Accept", Arrays.asList("application/json"));
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(InputStream.class)).thenReturn(is);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+
+ when(message.get("CamelHttpUrl")).thenReturn("/somestring");
+ aaiLogJAXRSInInterceptor.handleMessage(message);
+ }
+
+ @Test
+ public void testHandleMessageWhenMissingTransactionId() throws IOException {
+
+ Map<String, List<String>> headers = new HashMap<>();
+
+ headers.put("X-FromAppId", Arrays.asList("JUNIT"));
+ headers.put("Content-Type", Arrays.asList("application/json"));
+ headers.put("Accept", Arrays.asList("application/json"));
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(InputStream.class)).thenReturn(is);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+
+ when(message.get("CamelHttpUrl")).thenReturn("/somestring");
+ aaiLogJAXRSInInterceptor.handleMessage(message);
+ }
+
+ @Test
+ public void testHandleMessageWhenMissingContentType() throws IOException {
+
+ Map<String, List<String>> headers = new HashMap<>();
+
+ headers.put("X-FromAppId", Arrays.asList("JUNIT"));
+ headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja"));
+ headers.put("Accept", Arrays.asList("application/json"));
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(InputStream.class)).thenReturn(is);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+
+ when(message.get("CamelHttpUrl")).thenReturn("/somestring");
+ aaiLogJAXRSInInterceptor.handleMessage(message);
+ }
+
+ @Test
+ public void testHandleMessageWhenQueryExistsAndUriEcho() throws IOException {
+
+ Map<String, List<String>> headers = new HashMap<>();
+
+ headers.put("X-FromAppId", Arrays.asList("JUNIT"));
+ headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja"));
+ headers.put("Content-Type", Arrays.asList("application/json"));
+ headers.put("Accept", Arrays.asList("application/json"));
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(InputStream.class)).thenReturn(is);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+ when(message.get(Message.QUERY_STRING)).thenReturn(null);
+ when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true);
+ when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn("");
+ when(exchange.containsKey("AAI_LOGGING_TRACE_ENABLED")).thenReturn(true);
+ when(exchange.remove("AAI_LOGGING_TRACE_ENABLED")).thenReturn("");
+ when(message.get("CamelHttpUrl")).thenReturn("/util/echo");
+ aaiLogJAXRSInInterceptor.handleMessage(message);
+ }
+
+ @Test
+ public void testHandleMessageWhenQueryExistsAndUriTranslog() throws IOException {
+
+ Map<String, List<String>> headers = new HashMap<>();
+
+ headers.put("X-FromAppId", Arrays.asList("JUNIT"));
+ headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja"));
+ headers.put("Content-Type", Arrays.asList("application/json"));
+ headers.put("Accept", Arrays.asList("application/json"));
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(InputStream.class)).thenReturn(is);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+ when(message.get(Message.QUERY_STRING)).thenReturn(null);
+ when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true);
+ when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn("");
+ when(exchange.containsKey("AAI_LOGGING_TRACE_ENABLED")).thenReturn(true);
+ when(exchange.remove("AAI_LOGGING_TRACE_ENABLED")).thenReturn("");
+ when(message.get("CamelHttpUrl")).thenReturn("/translog/");
+ aaiLogJAXRSInInterceptor.handleMessage(message);
+ }
+
+ @Test
+ public void testHandleMessageWhenPutMessageKeyReturnsException() throws IOException {
+
+ Map<String, List<String>> headers = new HashMap<>();
+
+ headers.put("X-FromAppId", Arrays.asList("JUNIT"));
+ headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja"));
+ headers.put("Content-Type", Arrays.asList("application/json"));
+ headers.put("Accept", Arrays.asList("application/json"));
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(InputStream.class)).thenReturn(is);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+ when(message.get(Message.QUERY_STRING)).thenReturn(null);
+ when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true);
+ when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn("");
+ when(exchange.containsKey("AAI_LOGGING_TRACE_ENABLED")).thenReturn(true);
+ when(exchange.remove("AAI_LOGGING_TRACE_ENABLED")).thenReturn("");
+ when(message.get("CamelHttpUrl")).thenReturn("/translog/");
+ when(message.get(Message.ENCODING)).thenReturn("http");
+ when(message.get(Message.RESPONSE_CODE)).thenReturn(200);
+
+ aaiLogJAXRSInInterceptor.handleMessage(message);
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptorTest.java b/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptorTest.java
new file mode 100644
index 0000000..df2feec
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptorTest.java
@@ -0,0 +1,110 @@
+/*-
+ * ============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.openecomp.aai.interceptors;
+
+import org.apache.cxf.io.CacheAndWriteOutputStream;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.*;
+
+public class AAILogJAXRSOutInterceptorTest {
+
+ private AAILogJAXRSOutInterceptor aaiLogJAXRSOutInterceptor;
+
+ private Message message;
+ private Exchange exchange;
+ private OutputStream out;
+ private Map<String, List<String>> headers;
+ private Message outMessage;
+ private Message inMessage;
+
+
+ @Before
+ public void setup(){
+
+ aaiLogJAXRSOutInterceptor = new AAILogJAXRSOutInterceptor();
+
+ message = mock(Message.class);
+ exchange = spy(new ExchangeImpl());
+ out = mock(OutputStream.class);
+ outMessage = mock(Message.class);
+ inMessage = mock(Message.class);
+
+
+ headers = new HashMap<>();
+ headers.put("X-FromAppId", Arrays.asList("JUNIT"));
+ headers.put("X-TransactionId", Arrays.asList("JUNIT"));
+ headers.put("Content-Type", Arrays.asList("application/json"));
+ headers.put("Accept", Arrays.asList("application/json"));
+ }
+
+ @Test
+ public void testHandleMessageWhenNotCamelRequest() throws IOException {
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(OutputStream.class)).thenReturn(out);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+ when(exchange.getOutMessage()).thenReturn(outMessage);
+ when(outMessage.getContent(OutputStream.class)).thenReturn(out);
+ when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true);
+ when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn("");
+
+ when(message.get("CamelHttpUrl")).thenReturn("/somestring");
+ aaiLogJAXRSOutInterceptor.handleMessage(message);
+ }
+
+ @Test
+ public void testLogCallBack(){
+
+ when(message.getExchange()).thenReturn(exchange);
+ when(message.getContent(OutputStream.class)).thenReturn(out);
+ when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+ when(exchange.getOutMessage()).thenReturn(outMessage);
+
+ when(outMessage.getContent(OutputStream.class)).thenReturn(out);
+ when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true);
+ when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn("");
+ when(exchange.getInMessage()).thenReturn(inMessage);
+
+ when(inMessage.getExchange()).thenReturn(exchange);
+ when(inMessage.getContent(OutputStream.class)).thenReturn(out);
+ when(inMessage.get(Message.PROTOCOL_HEADERS)).thenReturn(headers);
+ when(inMessage.get(Message.CONTENT_TYPE)).thenReturn("*/*");
+
+ AAILogJAXRSOutInterceptor.LoggingCallback loggingCallback = new AAILogJAXRSOutInterceptor().new LoggingCallback(message, out);
+ final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(out);
+ loggingCallback.onClose(newOut);
+ }
+
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java
new file mode 100644
index 0000000..3aa2aa9
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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.openecomp.aai.interceptors;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.logging.LoggingContext;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class PostAaiAjscInterceptorTest {
+
+ private PostAaiAjscInterceptor postAaiAjscInterceptor;
+
+ @Before
+ public void setup(){
+ postAaiAjscInterceptor = new PostAaiAjscInterceptor();
+ }
+
+ @Test
+ public void getInstance() throws Exception {
+ PostAaiAjscInterceptor interceptor = PostAaiAjscInterceptor.getInstance();
+ assertNotNull(interceptor);
+ }
+
+ @Test
+ public void testAllowOrRejectIfSuccess() throws Exception {
+
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+
+ LoggingContext.put(LoggingContext.LoggingField.RESPONSE_CODE.toString(), "SUCCESS");
+ Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj"));
+
+ boolean success = postAaiAjscInterceptor.allowOrReject(request, null, null);
+
+ assertTrue("Expecting the post interceptor to return success regardless", success);
+ }
+
+ @Test
+ public void testAllowOrRejectIfFailure() throws Exception {
+
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+
+ LoggingContext.put(LoggingContext.LoggingField.RESPONSE_CODE.toString(), "ERR.");
+ Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj"));
+
+ boolean success = postAaiAjscInterceptor.allowOrReject(request, null, null);
+
+ assertTrue("Expecting the post interceptor to return success regardless", success);
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptorTest.java
new file mode 100644
index 0000000..9162019
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptorTest.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.openecomp.aai.interceptors;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyString;
+
+public class PreAaiAjscInterceptorTest {
+
+ private PreAaiAjscInterceptor preAaiAjscInterceptor;
+
+ @Before
+ public void setup(){
+ preAaiAjscInterceptor = new PreAaiAjscInterceptor();
+ }
+
+ @Test
+ public void getInstance() throws Exception {
+ PreAaiAjscInterceptor interceptor = PreAaiAjscInterceptor.getInstance();
+ assertNotNull(interceptor);
+ }
+
+ @Test
+ public void testAllowOrRejectIfSuccess() throws Exception {
+
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+
+ Mockito.when(request.getRequestURI()).thenReturn("/fadsjoifj");
+ Mockito.when(request.getHeader(anyString())).thenReturn("JUNIT-Test");
+ Mockito.when(request.getMethod()).thenReturn("GET");
+
+ boolean success = preAaiAjscInterceptor.allowOrReject(request, null, null);
+
+ assertTrue("Expecting the post interceptor to return success regardless", success);
+ }
+
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java
new file mode 100644
index 0000000..8e2bb94
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java
@@ -0,0 +1,155 @@
+/*-
+ * ============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.openecomp.aai.rest;
+
+import com.fasterxml.jackson.core.JsonLocation;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.sun.istack.SAXParseException2;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ExceptionHandlerTest {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ @Mock
+ private HttpHeaders httpHeaders;
+
+ @Mock
+ private HttpServletRequest request;
+
+ @InjectMocks
+ private ExceptionHandler handler = new ExceptionHandler();
+
+ @Before
+ public void setup(){
+ MockitoAnnotations.initMocks(this);
+
+ MultivaluedHashMap headersMultiMap = 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", "");
+
+ List<MediaType> outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ }
+
+ @Test
+ public void testConversionOfWebApplicationResponse() throws Exception {
+
+ Exception exception = new WebApplicationException();
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNull(response.getEntity());
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testConversionOfWebApplicationResponseWhenUmarshalExceptionResultBadRequest() throws Exception {
+
+ SAXParseException2 mockSaxParseException = mock(SAXParseException2.class);
+ Exception exception = new WebApplicationException(mockSaxParseException);
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testConversionWhenJsonParseExceptionResultBadRequest() throws Exception {
+
+ JsonLocation jsonLocation = mock(JsonLocation.class);
+ Exception exception = new JsonParseException("", jsonLocation);
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testConversionWhenJsonMappingExceptionResultBadRequest() throws Exception {
+
+ JsonLocation jsonLocation = mock(JsonLocation.class);
+ Exception exception = new JsonMappingException("", jsonLocation);
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testConversionWhenUnknownExceptionResultBadRequest() throws Exception {
+
+ Exception exception = mock(Exception.class);
+ Response response = handler.toResponse(exception);
+
+ when(request.getMethod()).thenReturn("GET");
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+
+
+ }
+
+ @Test
+ public void testConversionWhenUnknownExceptionResultBadRequestForXmlResponseType() throws Exception {
+
+ List<MediaType> outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(MediaType.valueOf("application/xml"));
+ when(request.getMethod()).thenReturn("GET");
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ Exception exception = mock(Exception.class);
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java
new file mode 100644
index 0000000..5e0ecd5
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java
@@ -0,0 +1,63 @@
+package org.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionFromVnfTest extends QueryTest {
+
+ public CloudRegionFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gv = graph.addVertex(T.id, "00", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "name", "vnf-type", "type");
+ Vertex vnfc = graph.addVertex(T.id, "10", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
+ Vertex vserv = graph.addVertex(T.id, "20", "aai-node-type", "vserver",
+ "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
+ Vertex cr = graph.addVertex(T.id, "30", "aai-node-type", "cloud-region", "cloud-owner", "some guy", "cloud-region-id", "crId");
+ Vertex tenant = graph.addVertex(T.id, "40", "aai-node-type", "tenant", "tenant-id", "ten1", "tenant-name", "tenName");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gv, vnfc);
+ rules.addEdge(g, vnfc, vserv);
+ rules.addTreeEdge(g, cr, tenant);
+ rules.addTreeEdge(g, tenant, vserv);
+
+ expectedResult.add(cr);
+ expectedResult.add(tenant);
+ expectedResult.add(vnfc);
+ expectedResult.add(vserv);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloud-region-fromVnf";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvId");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ // N/A for this query
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
new file mode 100644
index 0000000..5813ef1
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
@@ -0,0 +1,185 @@
+/*-
+ * ============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.openecomp.aai.rest.search;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.io.IOUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.dbmap.DBConnectionType;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.serialization.db.DBSerializer;
+import org.openecomp.aai.serialization.engines.QueryStyle;
+import org.openecomp.aai.serialization.engines.TitanDBEngine;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
+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 ModelAndNamedQueryRestProviderTest {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ 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 Loader loader;
+ private TransactionalGraphEngine dbEngine;
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private ModelAndNamedQueryRestProvider modelAndNamedQueryRestProvider;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelAndNamedQueryRestProviderTest.class.getName());
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+
+ modelAndNamedQueryRestProvider = new ModelAndNamedQueryRestProvider();
+ httpHeaders = mock(HttpHeaders.class);
+ uriInfo = mock(UriInfo.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);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new TitanDBEngine(
+ queryStyle,
+ type,
+ loader);
+ }
+
+ @Test
+ public void testNamedQueryWhenNoDataToBeFoundReturnHttpNotFound() throws Exception {
+
+ String queryParameters = getPayload("payloads/named-queries/named-query.json");
+ HttpServletRequest request = mock(HttpServletRequest.class);
+
+ when(request.getContentType()).thenReturn("application/json");
+
+ Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
+ httpHeaders,
+ request,
+ queryParameters
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testNamedQueryInvalidHeaders() throws Exception {
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenThrow(IllegalArgumentException.class);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region"
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
+ }
+
+ public String getPayload(String filename) throws IOException {
+
+ InputStream inputStream = getClass()
+ .getClassLoader()
+ .getResourceAsStream(filename);
+
+ String message = String.format("Unable to find the %s in src/test/resources", filename);
+ assertNotNull(message, inputStream);
+
+ String resource = IOUtils.toString(inputStream);
+ return resource;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/MsoRequestVfModuleTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/MsoRequestVfModuleTest.java
new file mode 100644
index 0000000..1038eb3
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/MsoRequestVfModuleTest.java
@@ -0,0 +1,96 @@
+/*-
+ * ============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.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class MsoRequestVfModuleTest extends QueryTest {
+ public MsoRequestVfModuleTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "0", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+ 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 serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "2", "aai-node-type","service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name","service-instance-name-1");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "4", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex volumegroup = graph.addVertex(T.label, "volume-group", T.id, "6", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-1", "volume-group-name", "volume-group-name1");
+
+
+ Vertex vfmodule1 = graph.addVertex(T.label, "vf-module", T.id, "10", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-10", "vf-module-name", "vf-module-name10");
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "11", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0","vnf-name", "vnf-name-10", "nf-type", "sample-nf-type1");
+ Vertex serviceInstance1 = graph.addVertex(T.label, "service-instance", T.id, "12", "aai-node-type","service-instance", "service-instance-id", "service-instance-id-10", "service-instance-name","service-instance-name-10");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "13", "aai-node-type", "vserver", "vserver-id", "vserverid10");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "14", "aai-node-type", "tenant", "tenant-id", "tenantid10", "tenant-name", "tenantName10");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "15", "aai-node-type", "cloud-region", "cloud-region-id", "regionid10", "cloud-owner", "cloudOwnername10");
+ Vertex volumegroup1 = graph.addVertex(T.label, "volume-group", T.id, "16", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-10", "volume-group-name", "volume-group-name10");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, genericvnf,vfmodule);
+ rules.addEdge(g, genericvnf, serviceInstance);
+ rules.addEdge(g, vserver,vfmodule);
+ rules.addTreeEdge(g, vserver,tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, vfmodule, volumegroup);
+
+ //false
+ rules.addTreeEdge(g, genericvnf1, vfmodule1);
+ rules.addEdge(g, genericvnf1, serviceInstance1);
+ rules.addEdge(g, vserver1,vfmodule1);
+ rules.addTreeEdge(g, vserver1, tenant1);
+ rules.addTreeEdge(g, tenant1, cloudregion1);
+ rules.addEdge(g, vfmodule1, volumegroup1);
+
+ expectedResult.add(vfmodule);
+ expectedResult.add(genericvnf);
+ expectedResult.add(serviceInstance);
+ expectedResult.add(cloudregion);
+ expectedResult.add(volumegroup);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "so-request-vfModule";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vf-module").has("vf-module-id", "vf-module-id-1").has("vf-module-name", "vf-module-name1");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java
new file mode 100644
index 0000000..ce88b01
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java
@@ -0,0 +1,68 @@
+package org.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class NetworkNameFromNetworkRoleQueryTest extends QueryTest {
+
+ public NetworkNameFromNetworkRoleQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex cr1 = graph.addVertex(T.id, "00", "aai-node-type", "cloud-region", "cloud-owner", "foo", "cloud-region-id", "cr1");
+ Vertex cr2 = graph.addVertex(T.id, "01", "aai-node-type", "cloud-region", "cloud-owner", "bar", "cloud-region-id", "cr2");
+
+ Vertex l3net1 = graph.addVertex(T.id, "10", "aai-node-type", "l3-network",
+ "network-id", "net1", "network-name", "netname1", "network-role", "correct-role");
+ Vertex l3net2 = graph.addVertex(T.id, "11", "aai-node-type", "l3-network",
+ "network-id", "net2", "network-name", "netname2", "network-role", "wrong-role");
+ Vertex l3net3 = graph.addVertex(T.id, "12", "aai-node-type", "l3-network",
+ "network-id", "net3", "network-name", "netname3", "network-role", "correct-role");
+
+ Vertex np1 = graph.addVertex(T.id, "20", "aai-node-type", "network-policy", "network-policy-id", "npId1");
+ Vertex np2 = graph.addVertex(T.id, "21", "aai-node-type", "network-policy", "network-policy-id", "npId2");
+ Vertex np3 = graph.addVertex(T.id, "22", "aai-node-type", "network-policy", "network-policy-id", "npId3");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, cr1, l3net1);
+ rules.addEdge(g, l3net1, np1);
+ rules.addEdge(g, cr1, l3net2);
+ rules.addEdge(g, l3net2, np2);
+ rules.addEdge(g, cr2, l3net3);
+ rules.addEdge(g, l3net3, np3);
+
+ expectedResult.add(l3net1);
+ expectedResult.add(np1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "network-name-fromNetwork-role";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "cloud-region").has("cloud-owner", "foo").has("cloud-region-id", "cr1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("networkRole", "correct-role");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java
new file mode 100644
index 0000000..d6704fa
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class OwningEntityfromServiceInstance extends QueryTest {
+ public OwningEntityfromServiceInstance () throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex service_instance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-1");
+ Vertex owning_entity = graph.addVertex(T.label, "owning-entity", T.id, "2", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-1", "owning-entity-name", "owning-entity-name1");
+
+ // adding extra vertices and edges which shouldn't be picked.
+ Vertex service_instance2 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id", "service-instance-2");
+ Vertex owning_entity2 = graph.addVertex(T.label, "owning-entity", T.id, "4", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-2", "owning-entity-name", "owning-entity-name2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, owning_entity, service_instance);
+ rules.addEdge(g, owning_entity2, service_instance2);
+
+ expectedResult.add(owning_entity);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "owning-entity-fromService-instance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("service-instance-id", "service-instance-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PendingTopologyDetailTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PendingTopologyDetailTest.java
new file mode 100644
index 0000000..22a60ce
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PendingTopologyDetailTest.java
@@ -0,0 +1,159 @@
+/*-
+ * ============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.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PendingTopologyDetailTest extends QueryTest {
+ public PendingTopologyDetailTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-0", "vnf-name", "vnf-name-0");
+ Vertex platform = graph.addVertex(T.label, "platform", T.id, "2", "aai-node-type", "platform", "platform-name", "platform0");
+ Vertex lineofbusiness = graph.addVertex(T.label, "line-of-business", T.id, "3", "aai-node-type", "line-of-business", "line-of-business-name", "business0");
+ Vertex servinst = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance", "service-instance-id", "servInstId0", "service-type", "servType0");
+ Vertex owningentity = graph.addVertex(T.label, "owning-entity", T.id, "5", "aai-node-type", "owning-entity", "owning-entity-id", "entityId0", "owning-entity-name", "entityName0");
+ Vertex project = graph.addVertex(T.label, "project", T.id, "6", "aai-node-type", "project", "project-name", "project0");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "7", "aai-node-type", "vnfc", "vnfc-name", "vnfc0", "nfc-naming-code", "namingCode0", "nfc-function", "function0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "8", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "9", "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, "10", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address0");
+ Vertex subnet4 = graph.addVertex(T.label, "subnet", T.id, "11", "aai-node-type", "subnet", "subnet-id", "subnet4-id0");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "12", "aai-node-type", "l3-network", "network-id", "network4-id0", "network-name", "network4-name0");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "13", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address0");
+ Vertex subnet6 = graph.addVertex(T.label, "subnet", T.id, "14", "aai-node-type", "subnet", "subnet-id", "subnet6-id0");
+ Vertex l3network6 = graph.addVertex(T.label, "l3-network", T.id, "15", "aai-node-type", "l3-network", "network-id", "network6-id0", "network-name", "network6-name0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "16", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "17", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "18", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex complex = graph.addVertex(T.label, "pserver", T.id, "19", "aai-node-type", "complex", "physical-location-id", "locationId", "physical-location-type", "locationType", "physical-location-id", "locationId",
+ "city", "cityName", "state", "stateName", "postal-code", "zip", "country", "countryName");
+ Vertex vipipv4addresslist = graph.addVertex(T.label, "vip-ipv4-address-list", T.id, "20", "aai-node-type", "vip-ipv4-address-list", "vip-ipv4-address", "vip-ipv4-address0");
+ Vertex vipipv6addresslist = graph.addVertex(T.label, "vip-ipv6-address-list", T.id, "21", "aai-node-type", "vip-ipv6-address-list", "vip-ipv6-address", "vip-ipv6-address0");
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "40", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex platform1 = graph.addVertex(T.label, "platform", T.id, "41", "aai-node-type", "platform", "platform-name", "platform1");
+
+ Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "30", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name2");
+ Vertex vnfc2 = graph.addVertex(T.label, "vnfc", T.id, "31", "aai-node-type", "vnfc", "vnfc-name", "vnfc2", "nfc-naming-code", "namingCode2", "nfc-function", "function2");
+ Vertex vipipv4addresslist2 = graph.addVertex(T.label, "vip-ipv4-address-list", T.id, "32", "aai-node-type", "vip-ipv4-address-list", "vip-ipv4-addres", "vip-ipv4-address2");
+ Vertex vipipv6addresslist2 = graph.addVertex(T.label, "vip-ipv6-address-list", T.id, "33", "aai-node-type", "vip-ipv6-address-list", "vip-ipv6-address", "vip-ipv6-address2");
+ Vertex subnet42 = graph.addVertex(T.label, "subnet", T.id, "34", "aai-node-type", "subnet", "subnet-id", "subnet4-id-0");
+ Vertex l3network42 = graph.addVertex(T.label, "l3-network", T.id, "35", "aai-node-type", "l3-network", "network-id", "network4-id2", "network-name", "network4-name2");
+ Vertex subnet62 = graph.addVertex(T.label, "subnet", T.id, "36", "aai-node-type", "subnet", "subnet-id", "subnet6-id2");
+ Vertex l3network62 = graph.addVertex(T.label, "l3-network", T.id, "37", "aai-node-type", "l3-network", "network-id", "network6-id2", "network-name", "network6-name2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, genericvnf, platform);
+ rules.addEdge(g, genericvnf, lineofbusiness);
+ rules.addEdge(g, genericvnf, servinst);
+ rules.addEdge(g, owningentity, servinst);
+ rules.addEdge(g, project, servinst);
+ rules.addEdge(g, genericvnf, vnfc);
+ rules.addEdge(g, vnfc, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, pserver, vserver);
+ rules.addEdge(g, complex, pserver);
+ rules.addTreeEdge(g, linterface, vserver);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addEdge(g, l3inter1ipv4addresslist, subnet4);
+ rules.addTreeEdge(g, l3network4, subnet4);
+ rules.addTreeEdge(g, vnfc, l3inter1ipv4addresslist);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addEdge(g, l3inter1ipv6addresslist, subnet6);
+ rules.addTreeEdge(g, l3network6, subnet6);
+ rules.addTreeEdge(g, vnfc, l3inter1ipv6addresslist);
+ rules.addTreeEdge(g, vipipv4addresslist, cloudregion);
+ rules.addEdge(g, vipipv4addresslist, subnet4);
+ rules.addEdge(g, vnfc, vipipv4addresslist);
+ rules.addTreeEdge(g, vipipv6addresslist, cloudregion);
+ rules.addEdge(g, vipipv6addresslist, subnet6);
+ rules.addEdge(g, vnfc, vipipv6addresslist);
+
+ rules.addEdge(g, genericvnf, platform1);
+
+
+ // false
+ rules.addEdge(g, genericvnf2, vnfc2);
+ rules.addTreeEdge(g, vipipv4addresslist2, cloudregion);
+ rules.addTreeEdge(g, vipipv6addresslist2, cloudregion);
+ rules.addEdge(g, vnfc2, vipipv4addresslist2);
+ rules.addEdge(g, vnfc2, vipipv6addresslist2);
+ rules.addEdge(g, vipipv4addresslist2, subnet42);
+ rules.addEdge(g, vipipv6addresslist2, subnet62);
+ rules.addTreeEdge(g, l3network42, subnet42);
+ rules.addTreeEdge(g, l3network62, subnet62);
+
+ rules.addEdge(g, genericvnf1, lineofbusiness);
+
+
+ expectedResult.add(genericvnf);
+ expectedResult.add(platform);
+ expectedResult.add(lineofbusiness);
+ expectedResult.add(owningentity);
+ expectedResult.add(project);
+ expectedResult.add(vnfc);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(subnet4);
+ expectedResult.add(l3network4);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(subnet6);
+ expectedResult.add(l3network6);
+ expectedResult.add(vipipv4addresslist);
+ expectedResult.add(vipipv6addresslist);
+
+ expectedResult.add(platform1);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pending-topology-detail";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "vnf-id-0");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
new file mode 100644
index 0000000..2dc023b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============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.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
+ public PserverfromConfigurationFilterInterfaceIdTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex config1 = graph.addVertex(T.label, "configuration", T.id, "1", "aai-node-type", "configuration", "configuration-id", "configuration1");
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "loglink1", "in-maint", "false",
+ "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");
+
+ // Following are extra nodes that should not be picked up in
+ // expectedResults
+ Vertex config2 = graph.addVertex(T.label, "configuration", T.id, "11", "aai-node-type", "configuration", "configuration-id", "configuration2");
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "12", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "13", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "14", "aai-node-type", "logical-link", "link-name", "loglink2", "in-maint", "false",
+ "link-type", "link-type2");
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored",
+ "true", "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, config1, loglink1);
+ rules.addEdge(g, config1, loglink2);
+ rules.addEdge(g, lint1, loglink1);
+ rules.addEdge(g, lint2, loglink1);
+ rules.addEdge(g, loglink1, pserver1);
+ rules.addEdge(g, loglink1, gvnf1);
+
+ // 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);
+
+ // Note lint2 is not in expectedResults as the filter is based on
+ // interface-id1
+ expectedResult.add(config1);
+ expectedResult.add(lint1);
+ expectedResult.add(pserver1);
+ expectedResult.add(gvnf1);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pserver-fromConfigurationFilterInterfaceId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("configuration-id", "configuration1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("interfaceId", "interface-id1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java
new file mode 100644
index 0000000..fd23bc4
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java
@@ -0,0 +1,101 @@
+/*-
+ * ============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.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserverfromConfigurationTest extends QueryTest {
+ public PserverfromConfigurationTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex config1 = graph.addVertex(T.label, "configuration", T.id, "1", "aai-node-type", "configuration", "configuration-id", "configuration1");
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "loglink1", "in-maint", "false",
+ "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");
+
+ // Following are extra nodes that should not be picked up in
+ // expectedResults
+ Vertex config2 = graph.addVertex(T.label, "configuration", T.id, "11", "aai-node-type", "configuration", "configuration-id", "configuration2");
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "12", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "13", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "14", "aai-node-type", "logical-link", "link-name", "loglink2", "in-maint", "false",
+ "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");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, config1, loglink1);
+ rules.addEdge(g, lint1, loglink1);
+ rules.addEdge(g, lint2, loglink1);
+ rules.addEdge(g, loglink1, pserver1);
+ rules.addEdge(g, loglink1, gvnf1);
+
+ // 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);
+
+ expectedResult.add(config1);
+ expectedResult.add(lint1);
+ expectedResult.add(lint2);
+ expectedResult.add(pserver1);
+ expectedResult.add(gvnf1);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pserver-fromConfiguration";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("configuration-id", "configuration1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java
new file mode 100644
index 0000000..6fe7872
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java
@@ -0,0 +1,82 @@
+package org.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class QueryVnfFromModelByRegionTest extends QueryTest {
+ public QueryVnfFromModelByRegionTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ 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, "12", "aai-node-type", "service-instance",
+ "service-instance-id", "service-instance2", "model-invariant-id", "miid2", "model-version-id", "mvid2");
+
+ Vertex genericVnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "generic-vnf-id", "generic-vnf1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserver1");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "4", "aai-node-type", "tenant", "tenant-id", "tenant1");
+ Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region1");
+
+ // Right invariant and version IDs, wrong cloud region
+ Vertex genericVnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf",
+ "generic-vnf-id", "generic-vnf2");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserver2");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant", T.id, "8", "aai-node-type", "tenant", "tenant-id", "tenant2");
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "9", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region2");
+
+ // On both the right and the wrong service-instance, with the right cloud-region
+ Vertex genericVnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "10", "aai-node-type", "generic-vnf",
+ "generic-vnf-id", "generic-vnf3");
+ Vertex vserver3 = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-id", "vserver3");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, serviceInst1, genericVnf1);
+ rules.addEdge(g, genericVnf1, vserver1);
+ rules.addTreeEdge(g, tenant1, vserver1);
+ rules.addTreeEdge(g, cloudRegion1, tenant1);
+
+ rules.addEdge(g, serviceInst1, genericVnf2);
+ rules.addEdge(g, genericVnf2, vserver2);
+ rules.addTreeEdge(g, tenant2, vserver2);
+ rules.addTreeEdge(g, cloudRegion2, tenant2);
+
+ rules.addEdge(g, serviceInst2, genericVnf3);
+ rules.addEdge(g, genericVnf3, vserver3);
+ rules.addTreeEdge(g, tenant1, vserver3);
+
+ rules.addEdge(g, serviceInst1, genericVnf3);
+
+ expectedResult.add(genericVnf1);
+ expectedResult.add(genericVnf3);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "queryvnfFromModelbyRegion";
+ }
+
+ @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");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/SearchProviderTest.java
new file mode 100644
index 0000000..6b922bf
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/SearchProviderTest.java
@@ -0,0 +1,266 @@
+/*-
+ * ============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.openecomp.aai.rest.search;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.dbmap.DBConnectionType;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.serialization.db.DBSerializer;
+import org.openecomp.aai.serialization.engines.QueryStyle;
+import org.openecomp.aai.serialization.engines.TitanDBEngine;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
+
+import javax.ws.rs.core.*;
+import java.util.*;
+
+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 SearchProviderTest {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ 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 Loader loader;
+ private TransactionalGraphEngine dbEngine;
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private SearchProvider searchProvider;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(SearchProviderTest.class.getName());
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+
+ searchProvider = new SearchProvider();
+ httpHeaders = mock(HttpHeaders.class);
+ uriInfo = mock(UriInfo.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);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new TitanDBEngine(
+ queryStyle,
+ type,
+ loader);
+ }
+
+ @Test
+ public void testNodesQueryInvalidData() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ 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()
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+
+ response = searchProvider.getNodesQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ "latest"
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testNodesQueryInvalidHeaders() 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);
+
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenThrow(IllegalArgumentException.class);
+ 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()
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testGenericQueryInvalidData() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ 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()
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+
+ response = searchProvider.getNodesQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ "latest"
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testGenericQueryInvalidHeaders() 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);
+
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenThrow(IllegalArgumentException.class);
+ 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()
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailFromVserverQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailFromVserverQueryTest.java
new file mode 100644
index 0000000..758b113
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailFromVserverQueryTest.java
@@ -0,0 +1,116 @@
+/*-
+ * ============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.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologyDetailFromVserverQueryTest extends QueryTest {
+ public TopologyDetailFromVserverQueryTest() 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 subnet4 = graph.addVertex(T.label, "subnet", T.id, "6", "aai-node-type", "subnet", "subnet-id", "subnet4-id-0");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "7", "aai-node-type", "l3-network", "network-id", "network4-id-0", "network-name", "network4-name0");
+ 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 subnet6 = graph.addVertex(T.label, "subnet", T.id, "9", "aai-node-type", "subnet", "subnet-id", "subnet6-id-0");
+ Vertex l3network6 = graph.addVertex(T.label, "l3-network", T.id, "10", "aai-node-type", "l3-network", "network-id", "network6-id-0", "network-name", "network6-name0");
+ Vertex platform = graph.addVertex(T.label, "platform", T.id, "11", "aai-node-type", "platform", "platform-name", "platform0");
+ Vertex lineofbusiness = graph.addVertex(T.label, "line-of-business", T.id, "12", "aai-node-type", "line-of-business", "line-of-business-name", "business0");
+ Vertex servinst = graph.addVertex(T.label, "service-instance", T.id, "13", "aai-node-type", "service-instance", "service-instance-id", "servInstId0", "service-type", "servType0");
+ Vertex owningentity = graph.addVertex(T.label, "owning-entity", T.id, "14", "aai-node-type", "owning-entity", "owning-entity-id", "entityId0", "owning-entity-name", "entityName0");
+ Vertex project = graph.addVertex(T.label, "project", T.id, "15", "aai-node-type", "project", "project-name", "project0");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "16", "aai-node-type", "vnfc", "vnfc-name", "vnfc0", "nfc-naming-code", "namingCode0", "nfc-function", "function0");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "17", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex complex = graph.addVertex(T.label, "pserver", T.id, "18", "aai-node-type", "complex", "physical-location-id", "locationId", "physical-location-type", "locationType", "physical-location-id", "locationId",
+ "city", "cityName", "state", "stateName", "postal-code", "zip", "country", "countryName");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addEdge(g, pserver, vserver);
+ rules.addEdge(g, complex, pserver);
+ rules.addEdge(g, genericvnf, vserver);
+ rules.addEdge(g, genericvnf, platform);
+ rules.addEdge(g, genericvnf, lineofbusiness);
+ rules.addEdge(g, genericvnf, vnfc);
+ rules.addEdge(g, genericvnf, servinst);
+ rules.addEdge(g, owningentity, servinst);
+ rules.addEdge(g, project, servinst);
+ rules.addTreeEdge(g, linterface, vserver);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addEdge(g, l3inter1ipv4addresslist, subnet4);
+ rules.addTreeEdge(g, l3network4, subnet4);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addEdge(g, l3inter1ipv6addresslist, subnet6);
+ rules.addTreeEdge(g, l3network6, subnet6);
+
+ expectedResult.add(vserver);
+ expectedResult.add(linterface);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(subnet4);
+ expectedResult.add(l3network4);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(subnet6);
+ expectedResult.add(l3network6);
+ expectedResult.add(cloudregion);
+ expectedResult.add(complex);
+ expectedResult.add(genericvnf);
+ expectedResult.add(platform);
+ expectedResult.add(lineofbusiness);
+ expectedResult.add(owningentity);
+ expectedResult.add(project);
+ expectedResult.add(vnfc);
+ }
+ @Override
+ protected String getQueryName() {
+ return "topology-detail-fromVserver";
+ }
+ @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");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailsQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailsQueryTest.java
new file mode 100644
index 0000000..1dd4db2
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailsQueryTest.java
@@ -0,0 +1,167 @@
+/*-
+ * ============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.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologyDetailsQueryTest extends QueryTest {
+ public TopologyDetailsQueryTest() 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","vnf-name", "vnf-name-1", "nf-type", "sample-nf-type");
+ Vertex platform = graph.addVertex(T.label, "platform", T.id, "1", "aai-node-type", "platform", "platform-name", "platform0");
+ Vertex lineofbusiness = graph.addVertex(T.label, "line-of-business", T.id, "2", "aai-node-type", "line-of-business", "line-of-business-name", "business0");
+ Vertex servinst = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id", "servInstId0", "service-type", "servType0");
+ Vertex owningentity = graph.addVertex(T.label, "owning-entity", T.id, "4", "aai-node-type", "owning-entity", "owning-entity-id", "entityId0", "owning-entity-name", "entityName0");
+ Vertex project = graph.addVertex(T.label, "project", T.id, "5", "aai-node-type", "project", "project-name", "project0");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "6", "aai-node-type", "vnfc", "vnfc-name", "vnfc0", "nfc-naming-code", "namingCode0", "nfc-function", "function0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "8", "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, "9", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-0");
+ Vertex subnet4 = graph.addVertex(T.label, "subnet", T.id, "10", "aai-node-type", "subnet", "subnet-id", "subnet4-id-0");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "11", "aai-node-type", "l3-network", "network-id", "network4-id-0", "network-name", "network4-name0");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "12", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-0");
+ Vertex subnet6 = graph.addVertex(T.label, "subnet", T.id, "13", "aai-node-type", "subnet", "subnet-id", "subnet6-id-0");
+ Vertex l3network6 = graph.addVertex(T.label, "l3-network", T.id, "14", "aai-node-type", "l3-network", "network-id", "network6-id-0", "network-name", "network6-name0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "15", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "16", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "17", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex complex = graph.addVertex(T.label, "pserver", T.id, "18", "aai-node-type", "complex", "physical-location-id", "locationId", "physical-location-type", "locationType", "physical-location-id", "locationId",
+ "city", "cityName", "state", "stateName", "postal-code", "zip", "country", "countryName");
+
+
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "20", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1","vnf-name", "vnf-name-2", "nf-type", "sample-nf-type1");
+ Vertex platform1 = graph.addVertex(T.label, "platform", T.id, "21", "aai-node-type", "platform", "platform-name", "platform1");
+ Vertex lineofbusiness1 = graph.addVertex(T.label, "line-of-business", T.id, "22", "aai-node-type", "line-of-business", "line-of-business-name", "business1");
+ Vertex servinst1 = graph.addVertex(T.label, "service-instance", T.id, "23", "aai-node-type", "service-instance", "service-instance-id", "servInstId1", "service-type", "servType1");
+ Vertex owningentity1 = graph.addVertex(T.label, "owning-entity", T.id, "24", "aai-node-type", "owning-entity", "owning-entity-id", "entityId1", "owning-entity-name", "entityName1");
+ Vertex project1 = graph.addVertex(T.label, "project", T.id, "25", "aai-node-type", "project", "project-name", "project1");
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc", T.id, "26", "aai-node-type", "vnfc", "vnfc-name", "vnfc1", "nfc-naming-code", "namingCode1", "nfc-function", "function1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "27", "aai-node-type", "vserver", "vserver-id", "vserverid1");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "28", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist1 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "29", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-1");
+ Vertex subnet41 = graph.addVertex(T.label, "subnet", T.id, "30", "aai-node-type", "subnet", "subnet-id", "subnet4-id-1");
+ Vertex l3network41 = graph.addVertex(T.label, "l3-network", T.id, "31", "aai-node-type", "l3-network", "network-id", "network4-id-1", "network-name", "network4-name1");
+ Vertex l3inter1ipv6addresslist1 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "32", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-1");
+ Vertex subnet61 = graph.addVertex(T.label, "subnet", T.id, "33", "aai-node-type", "subnet", "subnet-id", "subnet6-id-1");
+ Vertex l3network61 = graph.addVertex(T.label, "l3-network", T.id, "34", "aai-node-type", "l3-network", "network-id", "network6-id-1", "network-name", "network6-name1");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "35", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName1");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "36", "aai-node-type", "cloud-region", "cloud-region-id", "regionid1", "cloud-owner", "cloudOwnername1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "37", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex complex1 = graph.addVertex(T.label, "pserver", T.id, "38", "aai-node-type", "complex", "physical-location-id", "locationId1", "physical-location-type", "locationType1", "physical-location-id", "locationId1",
+ "city", "cityName1", "state", "stateName1", "postal-code", "zip1", "country", "countryName1");
+
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, genericvnf, platform);
+ rules.addEdge(g, genericvnf, lineofbusiness);
+ rules.addEdge(g, genericvnf, servinst);
+ rules.addEdge(g, owningentity, servinst);
+ rules.addEdge(g, project, servinst);
+ rules.addEdge(g, genericvnf, vnfc);
+ rules.addEdge(g, vnfc, vserver);
+ rules.addTreeEdge(g, linterface, vserver);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addEdge(g, l3inter1ipv4addresslist, subnet4);
+ rules.addTreeEdge(g, l3network4, subnet4);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addEdge(g, l3inter1ipv6addresslist, subnet6);
+ rules.addTreeEdge(g, l3network6, subnet6);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, pserver, vserver);
+ rules.addEdge(g, complex, pserver);
+
+
+ //false
+ rules.addEdge(g, genericvnf1, platform1);
+ rules.addEdge(g, genericvnf1, lineofbusiness1);
+ rules.addEdge(g, genericvnf1, servinst1);
+ rules.addEdge(g, owningentity1, servinst1);
+ rules.addEdge(g, project1, servinst1);
+ rules.addEdge(g, genericvnf1, vnfc1);
+ rules.addEdge(g, vnfc1, vserver1);
+ rules.addTreeEdge(g, linterface1, vserver1);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist1, linterface1);
+ rules.addEdge(g, l3inter1ipv4addresslist1, subnet41);
+ rules.addTreeEdge(g, l3network41, subnet41);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist1, linterface1);
+ rules.addEdge(g, l3inter1ipv6addresslist1, subnet61);
+ rules.addTreeEdge(g, l3network61, subnet61);
+ rules.addTreeEdge(g, vserver1, tenant1);
+ rules.addTreeEdge(g, tenant1, cloudregion1);
+ rules.addEdge(g, pserver1, vserver1);
+ rules.addEdge(g, complex1, pserver1);
+
+
+
+
+ expectedResult.add(genericvnf);
+ expectedResult.add(platform);
+ expectedResult.add(lineofbusiness);
+ expectedResult.add(owningentity);
+ expectedResult.add(project);
+ expectedResult.add(vnfc);
+ expectedResult.add(vserver);
+ expectedResult.add(linterface);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(subnet4);
+ expectedResult.add(l3network4);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(subnet6);
+ expectedResult.add(l3network6);
+ expectedResult.add(cloudregion);
+ expectedResult.add(complex);
+
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "topology-detail";
+ }
+ @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/openecomp/aai/rest/search/VserverFromVnfQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java
new file mode 100644
index 0000000..9d6ad2e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java
@@ -0,0 +1,67 @@
+package org.openecomp.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.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VserverFromVnfQueryTest extends QueryTest {
+
+ public VserverFromVnfQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gv = graph.addVertex(T.id, "00", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "gvName", "vnf-type", "some-type");
+ Vertex vnfc = graph.addVertex(T.id, "10", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
+ Vertex vserv = graph.addVertex(T.id, "20", "aai-node-type", "vserver",
+ "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
+ Vertex lint = graph.addVertex(T.id, "30", "aai-node-type", "l-interface", "interface-name", "lintName");
+ Vertex ipv4 = graph.addVertex(T.id, "40", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "0.0.0.0");
+ Vertex ipv6 = graph.addVertex(T.id, "50", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "0.0.0.0");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gv, vnfc);
+ rules.addEdge(g, vserv, vnfc);
+ rules.addTreeEdge(g, vserv, lint);
+ rules.addTreeEdge(g, lint, ipv4);
+ rules.addTreeEdge(g, lint, ipv6);
+
+ expectedResult.add(vserv);
+ expectedResult.add(lint);
+ expectedResult.add(ipv4);
+ expectedResult.add(ipv6);
+ expectedResult.add(vnfc);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vserver-fromVnf";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvId");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("nfcFunction", "correct-function");
+ }
+
+
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java
new file mode 100644
index 0000000..44d38be
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java
@@ -0,0 +1,135 @@
+/*-
+ * ============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.openecomp.aai.rest.util;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import javax.ws.rs.core.*;
+import java.util.*;
+
+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 EchoResponseTest {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private EchoResponse echoResponse;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(EchoResponseTest.class.getName());
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ echoResponse = new EchoResponse();
+ httpHeaders = mock(HttpHeaders.class);
+ uriInfo = mock(UriInfo.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);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void testEchoResultWhenValidHeaders() throws Exception {
+
+ Response response = echoResponse.echoResult(httpHeaders, null, "");
+
+ assertNotNull(response);
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testEchoResultWhenInValidHeadersThrowsBadRequest() throws Exception {
+
+ httpHeaders = mock(HttpHeaders.class);
+ Response response = echoResponse.echoResult(httpHeaders, null, "");
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testEchoResultWhenValidHeadersButMediaTypeWrong() throws Exception {
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenThrow(new IllegalStateException())
+ .thenReturn(outputMediaTypes);
+
+ Response response = echoResponse.echoResult(httpHeaders, null, "");
+
+ assertNotNull(response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/named-queries/named-query.json b/aai-traversal/src/test/resources/payloads/named-queries/named-query.json
new file mode 100644
index 0000000..f27823f
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/named-queries/named-query.json
@@ -0,0 +1,18 @@
+{
+ "query-parameters": {
+ "named-query": {
+ "named-query-name": "wan-connector",
+ "named-query-version": "1",
+ "named-query-uuid": "afsjdiofjsia-afiojadfio-dsjfoisajfid"
+ }
+ },
+ "instance-filters": {
+ "instance-filter": [
+ {
+ "connector": {
+ "resource-instance-id": "123456-16102016"
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index d923ec5..b179c3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
<properties>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
- <sitePath>/content/sites/site/org/onap/aai/traversal/${project.artifactId}/${project.version}</sitePath>
+ <sitePath>/content/sites/site/org/onap/aai/traversal/${project.artifactId}/${project.version}</sitePath>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
@@ -74,16 +74,16 @@
<repository>
<id>ecomp-releases</id>
<name>ECOMP Release Repository</name>
- <url>${nexusproxy}/content/repositories/releases/</url>
+ <url>${onap.nexus.url}/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>ecomp-snapshots</id>
<name>ECOMP Snapshot Repository</name>
- <url>${nexusproxy}/content/repositories/snapshots/</url>
+ <url>${onap.nexus.url}/content/repositories/snapshots/</url>
</snapshotRepository>
<site>
<id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
+ <url>dav:${onap.nexus.url}${sitePath}</url>
</site>
</distributionManagement>
<profiles>
@@ -288,7 +288,7 @@
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
+ <nexusUrl>${onap.nexus.url}</nexusUrl>
<stagingProfileId>176c31dfe190a</stagingProfileId>
<serverId>ecomp-staging</serverId>
</configuration>