summaryrefslogtreecommitdiffstats
path: root/aai-traversal
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal')
-rw-r--r--aai-traversal/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java5
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java524
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/GremlinServerImplTest.java163
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/GroovyShellImplTest.java157
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java35
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/JaxrsUserServiceTest.java110
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/RetiredConsumerTest.java128
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V3ThroughV7ConsumerTest.java33
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V7V8NamedQueriesTest.java33
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java177
10 files changed, 1218 insertions, 147 deletions
diff --git a/aai-traversal/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java b/aai-traversal/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java
index 8c5a4aa..9edf857 100644
--- a/aai-traversal/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java
+++ b/aai-traversal/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java
@@ -100,5 +100,10 @@ public class AAIAppServletContextListener implements ServletContextListener {
LOGGER.error("Unknown failure while initializing AAI Server", e);
throw new RuntimeException("Unknown failure while initializing AAI server", e);
}
+
+ LOGGER.info("Graph-Query MicroService Started");
+ LOGGER.error("Graph-Query MicroService Started");
+ LOGGER.debug("Graph-Query MicroService Started");
+
}
}
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
index 11804e5..49ad810 100644
--- a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java
+++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java
@@ -1,148 +1,378 @@
-/*-
- * ============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);
- }
+/*-
+ * ============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 com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.velocity.util.ArrayListWrapper;
+import org.eclipse.persistence.dynamic.DynamicEntity;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.openecomp.aai.dbgraphgen.ModelBasedProcessing;
+import org.openecomp.aai.dbmap.DBConnectionType;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.extensions.AAIExtensionMap;
+import org.openecomp.aai.introspection.*;
+import org.openecomp.aai.parsers.relationship.RelationshipToURI;
+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.net.URI;
+import java.sql.ResultSet;
+import java.util.*;
+import java.util.stream.Stream;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.*;
+
+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 runNodesQuery() throws AAIException{
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ searchGraph.runNodesQuery(httpHeaders,"",null,
+ null,dbEngine,loader,urlBuilder);
+ }
+ @Test(expected = AAIException.class)
+ public void runNodesQueryNull() throws AAIException{
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ searchGraph.runNodesQuery(httpHeaders,"nnn",null,
+ null,dbEngine,loader,urlBuilder);
+ }
+ @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, "service-instance", keys, includeStrings, 1, dbEngine, loader, urlBuilder);
+ System.out.println(response);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void testRunGenericQueryFailWhenInvalidRelationshipList1() 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, null, keys, includeStrings, 1, dbEngine, loader, urlBuilder);
+ System.out.println(response);
+ }
+
+ @Test(expected = AAIException.class)
+ public void testRunGenericQueryFailWhenInvalidRelationshipList2() 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, "", null, includeStrings, 1, dbEngine, loader, urlBuilder);
+ System.out.println(response);
+ }
+
+ @Test(expected = AAIException.class)
+ public void testRunGenericQueryFailWhenInvalidRelationshipList3() 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, "", keys, null, 1, dbEngine, loader, urlBuilder);
+ System.out.println(response);
+ }
+
+
+ /*@Test(expected = NullPointerException.class)
+ public void createSearchResults() throws AAIException {
+
+ List<Vertex> keys = new ArrayList<>();
+ Vertex vertex=new EmptyVertex();
+ keys.add(vertex);
+
+
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ Introspector response = searchGraph.createSearchResults(loader, urlBuilder, keys);
+ System.out.println(response);
+ }*/
+ @Test
+ public void createSearchResults1() throws Exception {
+
+ List<Vertex> keys = new ArrayList<>();
+ Vertex vertex=new EmptyVertex();
+ keys.add(vertex);
+ DBSerializer ds=mock(DBSerializer.class);
+ UrlBuilder urlBuilder=mock(UrlBuilder.class);
+ when(urlBuilder.pathed(vertex)).thenReturn("cloud-region");
+ Stream<Vertex> stream=mock(Stream.class);
+ when(stream.isParallel()).thenReturn(true);
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+ RelationshipToURI relationshipToURI=mock(RelationshipToURI.class);
+ URI uri =new URI("");
+ when(relationshipToURI.getUri()).thenReturn(uri);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ // UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ Introspector response = searchGraph.createSearchResults(loader, urlBuilder, keys);
+ System.out.println(response);
+ }
+ @Test(expected = AAIException.class)
+ public void executeModelOperationTest() throws Exception{
+ Vertex vertex=new EmptyVertex();
+ vertex.property("model-name");
+ Map<String,Object> mapObj=new HashMap<String,Object>();
+ mapObj.put("modle-version",vertex);
+ List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
+ startNodeFilterArrayOfHashes.add(mapObj);
+ List<org.openecomp.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.openecomp.aai.dbgraphgen.ResultSet>();
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ // ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ AAIExtensionMap map=mock(AAIExtensionMap.class);
+ HttpServletRequest servletRequest=mock(HttpServletRequest.class);
+
+ when(map.getHttpServletRequest()).thenReturn(servletRequest);
+ when(servletRequest.getContentType()).thenReturn("application/json");
+ DynamicEntity modelAndNamedQuerySearch=mock(DynamicEntity.class);
+ when(modelAndNamedQuerySearch.isSet("topNodeType")).thenReturn(true);
+
+
+/* when(processor.queryByModel("9999","model-ver","model-version-id",
+ "model-inv-id","modelname","aai",
+ startNodeFilterArrayOfHashes,"aai-ver")).thenReturn(resultSet);*/
+
+ searchGraph.executeModelOperation("","","",type,true,
+ map);
+ }
+
+ @Test(expected = AAIException.class)
+ public void executeModelOperationXMLTest() throws Exception{
+ Vertex vertex=new EmptyVertex();
+ vertex.property("model-name");
+ Map<String,Object> mapObj=new HashMap<String,Object>();
+ mapObj.put("modle-version",vertex);
+ List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
+ startNodeFilterArrayOfHashes.add(mapObj);
+ List<org.openecomp.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.openecomp.aai.dbgraphgen.ResultSet>();
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ // ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ AAIExtensionMap map=mock(AAIExtensionMap.class);
+ HttpServletRequest servletRequest=mock(HttpServletRequest.class);
+
+ when(map.getHttpServletRequest()).thenReturn(servletRequest);
+ when(servletRequest.getContentType()).thenReturn("application/xml");
+
+ DynamicEntity modelAndNamedQuerySearch=mock(DynamicEntity.class);
+ when(modelAndNamedQuerySearch.isSet("queryParameters")).thenReturn(true);
+/* when(processor.queryByModel("9999","model-ver","model-version-id",
+ "model-inv-id","modelname","aai",
+ startNodeFilterArrayOfHashes,"aai-ver")).thenReturn(resultSet);*/
+
+ searchGraph.executeModelOperation("","","",type,true,
+ map);
+ }
+ @Test
+ public void runNodesQueryTest() throws AAIException{
+ UrlBuilder urlBuilder=mock(UrlBuilder.class);
+ List<String> filter=new ArrayList<String>();
+ filter.add("model:EQUALS:DOES-NOT-EXIST:AAI");
+ List<String> edgeFilter=new ArrayList<String>();
+ edgeFilter.add("model:DOES-NOT-EXIST:DOES-NOT-EXIST:AAI");
+ Response response= searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
+ filter,dbEngine,loader,urlBuilder);
+ Assert.assertNotNull(response);
+ }
+
+ @Test
+ public void runNodesQueryExistsTest() throws AAIException{
+ UrlBuilder urlBuilder=mock(UrlBuilder.class);
+ List<String> filter=new ArrayList<String>();
+ filter.add("model:EQUALS:DOES-NOT-EXIST:AAI");
+ List<String> edgeFilter=new ArrayList<String>();
+ edgeFilter.add("model:EXISTS:DOES-NOT-EXIST:AAI");
+ Response response= searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
+ filter,dbEngine,loader,urlBuilder);
+ Assert.assertNotNull(response);
+ }
+
+ @Test
+ public void runNodesQueryTestDOESNOTEQUAL() throws AAIException{
+ UrlBuilder urlBuilder=mock(UrlBuilder.class);
+ List<String> filter=new ArrayList<String>();
+ filter.add("model:DOES-NOT-EQUAL:DOES-NOT-EXIST");
+ List<String> edgeFilter=new ArrayList<String>();
+ searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
+ filter,dbEngine,loader,urlBuilder);
+ }
+
+ @Test
+ public void runNodesQueryTestGreaterThan3() throws AAIException{
+ UrlBuilder urlBuilder=mock(UrlBuilder.class);
+ List<String> filter=new ArrayList<String>();
+ filter.add("model:DOES-NOT-EQUAL:DOES-NOT-EXIST:AAI");
+ List<String> edgeFilter=new ArrayList<String>();
+ searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
+ filter,dbEngine,loader,urlBuilder);
+ }
+
+ @Test
+ public void runNodesQueryTestGreaterThanExists() throws AAIException{
+ UrlBuilder urlBuilder=mock(UrlBuilder.class);
+ List<String> filter=new ArrayList<String>();
+ filter.add("model:EXISTS:DOES-NOT-EXIST:AAI");
+ List<String> edgeFilter=new ArrayList<String>();
+ searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
+ filter,dbEngine,loader,urlBuilder);
+ }
+
+ @Test(expected = AAIException.class)
+ public void runNodesQueryTestGreaterThanDoesNotExists() throws AAIException{
+ UrlBuilder urlBuilder=mock(UrlBuilder.class);
+ List<String> filter=new ArrayList<String>();
+ filter.add("model:DOES_NOT_EXIST:DOES-NOT-EXIST:AAI");
+ List<String> edgeFilter=new ArrayList<String>();
+ searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
+ filter,dbEngine,loader,urlBuilder);
+ }
} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GremlinServerImplTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GremlinServerImplTest.java
new file mode 100644
index 0000000..deea903
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GremlinServerImplTest.java
@@ -0,0 +1,163 @@
+/*-
+ * ============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.thinkaurelius.titan.core.TitanGraph;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Assert;
+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.engines.QueryStyle;
+import org.openecomp.aai.serialization.engines.TitanDBEngine;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import org.openecomp.aai.serialization.queryformats.SubGraphStyle;
+
+import javax.ws.rs.core.*;
+import java.net.URI;
+import java.util.*;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class GremlinServerImplTest {
+
+ GremlinServerImpl gremlinServerImpl;
+
+ 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 GenericQueryProcessor genericQueryProcessor;
+ 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()throws AAIException{
+
+ 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);
+ GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
+builder.queryFrom(URI.create("te"));
+builder.queryFrom("te");
+builder.create();
+builder.processWith(QueryProcessorType.GREMLIN_SERVER);
+ builder.processWith(QueryProcessorType.LOCAL_GROOVY);
+
+ gremlinServerImpl= new GremlinServerImpl(builder);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void processSubGraphTest() throws Exception{
+ GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
+ g.has("cloud-region-id", "cloud-region-id-1");
+ gremlinServerImpl.processSubGraph(SubGraphStyle.prune,g);
+}
+
+ @Test(expected = RuntimeException.class)
+ public void executeTest() throws Exception{
+ GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
+ g.has("cloud-region-id", "cloud-region-id-1");
+ //Mockito.when(etPath()).thenReturn("testpath");
+ List<Object> re= gremlinServerImpl.execute(SubGraphStyle.prune);
+ Assert.assertNotNull(re);
+ }
+
+
+
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GroovyShellImplTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GroovyShellImplTest.java
new file mode 100644
index 0000000..723e30d
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GroovyShellImplTest.java
@@ -0,0 +1,157 @@
+/*-
+ * ============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.thinkaurelius.titan.core.TitanGraph;
+import groovy.lang.MissingPropertyException;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Assert;
+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.engines.QueryStyle;
+import org.openecomp.aai.serialization.engines.TitanDBEngine;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import org.openecomp.aai.serialization.queryformats.SubGraphStyle;
+
+import javax.ws.rs.core.*;
+import java.net.URI;
+import java.util.*;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class GroovyShellImplTest {
+
+ GroovyShellImpl groovyShellImpl ;
+
+ 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 GenericQueryProcessor genericQueryProcessor;
+ 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()throws AAIException{
+
+ 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);
+ GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
+builder.queryFrom(URI.create("te"));
+builder.queryFrom("te");
+builder.create();
+builder.processWith(QueryProcessorType.GREMLIN_SERVER);
+ builder.processWith(QueryProcessorType.LOCAL_GROOVY);
+
+ groovyShellImpl= new GroovyShellImpl(builder);
+ }
+
+ @Test(expected = MissingPropertyException.class)
+ public void processSubGraphTest() throws Exception{
+ GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
+ g.has("cloud-region-id", "cloud-region-id-1");
+ Map<String, Object> params = new HashMap<>();
+ groovyShellImpl.runQuery("vnfs-fromServiceInstance",params);
+}
+
+
+
+
+
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java
new file mode 100644
index 0000000..3a1ddc1
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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 org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+
+public class LogFormatToolsTest {
+
+ @Test
+ public void testLogFormatTools(){
+
+ String dateTime = new LogFormatTools().getCurrentDateTime();
+ assertNotNull(dateTime);
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/JaxrsUserServiceTest.java b/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/JaxrsUserServiceTest.java
new file mode 100644
index 0000000..9a9ae8d
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/JaxrsUserServiceTest.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.retiredcustomer;
+
+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.ajsc_aai.JaxrsUserService;
+import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.rest.retired.RetiredConsumer;
+
+import javax.ws.rs.core.*;
+import java.util.*;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public class JaxrsUserServiceTest {
+
+
+ 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);
+ }
+
+ protected JaxrsUserService jaxrsUserService;
+ protected HttpHeaders httpHeaders;
+ protected 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(RetiredConsumer.class.getName());
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ jaxrsUserService = new JaxrsUserService();
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.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("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 lookUpUserTest(){
+ when(uriInfo.getPath()).thenReturn("/user?userID1");
+ String response = jaxrsUserService.lookupUser("userID1");
+ assertNotNull(response);
+
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/RetiredConsumerTest.java b/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/RetiredConsumerTest.java
new file mode 100644
index 0000000..4a8a051
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/RetiredConsumerTest.java
@@ -0,0 +1,128 @@
+/*-
+ * ============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.retiredcustomer;
+
+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.introspection.Version;
+import org.openecomp.aai.rest.retired.RetiredConsumer;
+
+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.when;
+
+public abstract class RetiredConsumerTest {
+
+ 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);
+ }
+
+ protected RetiredConsumer retiredConsumer;
+ protected HttpHeaders httpHeaders;
+ protected 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(RetiredConsumer.class.getName());
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ retiredConsumer = getRetiredConsumer();
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.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("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 testRetiredForAllEndPoints(){
+ when(uriInfo.getPath()).thenReturn("/aai/v3/cloud-infrastructure/pservers/pserver/test-pserver1");
+
+ Response response = retiredConsumer.createMessageGet(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+
+ response = retiredConsumer.createMessagePost(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+
+ response = retiredConsumer.createMessagePatch(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+
+ response = retiredConsumer.createMessagePut(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+
+ response = retiredConsumer.createMessageDelete(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+ }
+
+ public abstract RetiredConsumer getRetiredConsumer();
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V3ThroughV7ConsumerTest.java b/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V3ThroughV7ConsumerTest.java
new file mode 100644
index 0000000..ea8ea9c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V3ThroughV7ConsumerTest.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.retiredcustomer;
+
+import org.openecomp.aai.rest.retired.RetiredConsumer;
+import org.openecomp.aai.rest.retired.V3ThroughV7Consumer;
+
+
+public class V3ThroughV7ConsumerTest extends RetiredConsumerTest {
+
+ @Override
+ public RetiredConsumer getRetiredConsumer() {
+ return new V3ThroughV7Consumer();
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V7V8NamedQueriesTest.java b/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V7V8NamedQueriesTest.java
new file mode 100644
index 0000000..9968ee8
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V7V8NamedQueriesTest.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.retiredcustomer;
+
+import org.openecomp.aai.rest.retired.RetiredConsumer;
+import org.openecomp.aai.rest.retired.V7V8NamedQueries;
+
+public class V7V8NamedQueriesTest extends RetiredConsumerTest {
+
+ @Override
+ public RetiredConsumer getRetiredConsumer() {
+ return new V7V8NamedQueries();
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java b/aai-traversal/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java
new file mode 100644
index 0000000..d8e4928
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java
@@ -0,0 +1,177 @@
+/*-
+ * ============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.util;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.PatternLayout;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.AppenderBase;
+import org.apache.commons.lang.ObjectUtils;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.openecomp.aai.dbmap.AAIGraph;
+import org.openecomp.aai.logging.ErrorLogHelper;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.agent.PowerMockAgent;
+import org.powermock.modules.junit4.rule.PowerMockRule;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletContextEvent;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class})
+public class AAIAppServletContextListenerTest {
+
+ @Rule
+ public PowerMockRule rule = new PowerMockRule();
+
+ static {
+ PowerMockAgent.initializeIfNeeded();
+ }
+
+ private ServletContextEvent arg;
+ private AAIAppServletContextListener listener;
+
+ /**
+ * Initialize.
+ */
+ @Before
+ @PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class})
+ public void initialize(){
+ arg = PowerMockito.mock(ServletContextEvent.class);
+ PowerMockito.mockStatic(AAIGraph.class);
+ PowerMockito.mockStatic(AAIConfig.class);
+ PowerMockito.mockStatic(ErrorLogHelper.class);
+
+ listener = new AAIAppServletContextListener();
+ configureLog();
+ }
+
+ /**
+ * Test contextDestroyed.
+ */
+ @Test(expected = NullPointerException.class)
+ //@Ignore
+ public void testContextDestroyed(){
+ listener.contextDestroyed(arg);
+ assertTrue(logContains(Level.DEBUG, "AAI Server shutdown"));
+ assertTrue(logContains(Level.INFO, "AAI graph shutdown"));
+ }
+
+ /**
+ * Test contextInitialized.
+ */
+ @Test
+ //@Ignore
+ public void testContextInitialized(){
+ listener.contextInitialized(arg);
+ assertFalse(logContains(Level.DEBUG, "Loading aaiconfig.properties"));
+ assertFalse(logContains(Level.DEBUG, "Loading error.properties"));
+ assertFalse(logContains(Level.DEBUG, "Loading graph database"));
+ assertFalse(logContains(Level.INFO, "AAI Server initialization"));
+ }
+
+
+ /**
+ * Helper method to check if a String appears in the desired log level.
+ *
+ * @param level Log level to use
+ * @param expected String to search for
+ * @return True if search String is found, false otherwise
+ */
+ private boolean logContains(Level level, String expected) {
+ String actual[] = RecordingAppender.messages();
+ for (String log : actual) {
+ if (log.contains(level.toString()) && log.contains(expected))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Set logging level, and initialize log-appender.
+ */
+ private void configureLog() {
+ org.slf4j.Logger rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+ rootLogger.debug("debug");
+ // rootLogger.();
+ // rootLogger.addAppender(RecordingAppender.appender(new PatternLayout()));
+ }
+
+}
+
+
+/**
+ * Appender class that appends log messages to a String List when some logging event occurs
+ */
+class RecordingAppender extends AppenderBase<ILoggingEvent> {
+ private static List<String> messages = new ArrayList<String>();
+ private static RecordingAppender appender = new RecordingAppender();
+ private PatternLayout patternLayout;
+
+ private RecordingAppender() {
+ super();
+ }
+
+ /**
+ * @param patternLayout Pattern to format log message
+ * @return Current appender
+ */
+ public static RecordingAppender appender(PatternLayout patternLayout) {
+ appender.patternLayout = patternLayout;
+ appender.clear();
+ return appender;
+ }
+
+ @Override
+ protected void append(ILoggingEvent event) {
+ messages.add(patternLayout.doLayout(event));
+ }
+
+ public void close() {}
+
+ public boolean requiresLayout() {
+ return false;
+ }
+
+ /**
+ * @return Return logs as a String array
+ */
+ public static String[] messages() {
+ return (String[]) messages.toArray(new String[messages.size()]);
+ }
+
+ /**
+ * Clear the message container
+ */
+ private void clear() {
+ messages.clear();
+ }
+
+}