aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test/java/org/onap/aai
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal/src/test/java/org/onap/aai')
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java984
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java542
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java379
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java204
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java111
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java74
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java63
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java156
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeQueryTest.java80
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java100
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java104
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java77
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryQueryTest.java77
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java99
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java106
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java164
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java158
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ImageFromCloudRegionNfTypeTest.java110
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java99
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java112
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java87
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java83
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java186
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/MsoRequestVfModuleTest.java97
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java89
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/NfTypefromCloudRegionQueryTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/OwningEntityfromServiceInstance.java76
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java160
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java104
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java102
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserversFromVnfQueryTest.java91
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java99
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java267
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java112
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java127
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java117
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java168
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java160
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java251
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java85
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java128
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVfModuleTest.java134
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java130
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromPserverQueryTest.java91
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromServiceInstanceTest.java80
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java88
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLogicallinkFromPServerTest.java88
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java136
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java36
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java102
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java111
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java129
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java34
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java34
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/transforms/JoltTestUtil.java62
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java74
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/transforms/MapTraverserTest.java57
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java178
60 files changed, 8223 insertions, 0 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
new file mode 100644
index 0000000..bd3705e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
@@ -0,0 +1,984 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.dbgraphgen;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyMap;
+import static org.mockito.Matchers.anyMapOf;
+import static org.mockito.Mockito.*;
+
+import com.bazaarvoice.jolt.modifier.DataType;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.Multimap;
+import com.thinkaurelius.titan.graphdb.olap.computer.VertexMapJob;
+import com.thinkaurelius.titan.graphdb.types.VertexLabelVertex;
+import com.thinkaurelius.titan.graphdb.types.system.BaseVertexLabel;
+import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
+import com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex;
+import com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.openjpa.kernel.exps.Exp;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.aai.db.DbMethHelper;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import javax.inject.Inject;
+import java.util.*;
+@RunWith(MockitoJUnitRunner.class)
+public class ModelBasedProcessingInvalidDataTest {
+
+ @Mock
+ private static TransactionalGraphEngine dbEngine;
+ private static Loader loader;
+ @Mock
+ private static DBSerializer serializer;
+ ModelBasedProcessing processor;
+
+ @Mock
+ private ModelBasedProcessing mockProcessor;
+
+
+ @Mock
+ private DbMethHelper dbMethHelper;
+
+ @BeforeClass
+ public static void configure() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+
+
+ }
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ dbMethHelper = new DbMethHelper(loader, dbEngine);
+
+ }
+
+ @Test
+ public void getStartNodesAndModVersionIdsTest() throws AAIException {
+
+
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result=new HashMap<>();
+
+ Map<String, String> result1 = mockProcessor.getStartNodesAndModVersionIds("test", "test",
+ "test", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsTest2() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsTest3() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsTest4() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsTest5() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsNullTest() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+
+ assertNotNull(result);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest1() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "Test", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+
+ assertNotNull(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest2() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "test", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest3() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "test",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerTopWidgetTypeTest() throws AAIException {
+ Vertex vertex = new EmptyVertex();
+ //Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(Vertex.class), Mockito.any(String.class))).thenReturn("Sucess");
+ String result = processor.getModelVerTopWidgetType(vertex, "test");
+ assertEquals("result has -local tacked on the end as it should", "Sucess", result
+ );
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerTopWidgetType() throws AAIException {
+ /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class))
+ ).thenReturn("Sucess");*/
+ String result = processor.getModelVerTopWidgetType("test", "test", "test", "Test", "test");
+ assertEquals("result has -local tacked on the end as it should", "Sucess", result
+ );
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByModel() throws AAIException {
+ /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class))
+ ).thenReturn("Sucess");*/
+ List<ResultSet> result = processor.queryByModel("test", "test",
+ "test", "test", "test",
+ "generic-vnf", null,
+ "test");
+ assertEquals("result has -local tacked on the end as it should", 0, result.size());
+
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void queryByModel_Timed() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ List<ResultSet> result = processor.queryByModel_Timed("test", "test",
+ "test", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertEquals("result has -local tacked on the end as it should", 0, result.size());
+
+
+ }
+
+ @Mock
+ Map<String, Object> startNodeFilterHash;
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModel() throws AAIException {
+ Map<String, String> resultMock = new HashMap<String, String>();
+
+ // when(mockProcessor.getNodeUsingUniqueId(any(String.class),any(String.class),any(String.class),any(String.class),any(String.class))).thenReturn(vertex);
+ when(mockProcessor.runDeleteByModel(any(String.class),
+ any(String.class), any(String.class),
+ any(String.class), anyMapOf(String.class, Object.class), any(String.class), any(String.class))
+ ).thenReturn(resultMock);
+ Map<String, String> result = processor.runDeleteByModel("test", "test",
+ "test", "test", startNodeFilterHash,
+ "test",
+ "test");
+ assertEquals("result has -local tacked on the end as it should", result.size(), resultMock.size());
+
+
+ }
+
+ Optional<Vertex> vertext = Optional.empty();
+
+ @Test(expected = AAIException.class)
+ public void runDeleteByModelWithNullParams() throws AAIException {
+ Map<String, String> resultMock = new HashMap<String, String>();
+
+
+ Map<String, String> result = processor.runDeleteByModel("test", "test",
+ null, null, null,
+ "test",
+ "test");
+
+ assertNotNull(result);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModelWithNullParams1() throws AAIException {
+
+ Map<String, String> result1 = processor.runDeleteByModel("test", "test",
+ null, "unknown", null,
+ "test",
+ "test");
+ assertNotNull(result1);
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModelWithNullParams2() throws AAIException {
+
+ Map<String, String> result1 = processor.runDeleteByModel("test", "test",
+ null, "unknown", null,
+ "test",
+ "test");
+ assertNotNull(result1);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery() throws AAIException{
+ String transId="test";
+ String fromAppId="test";
+ String namedQueryUuid="test";
+ ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
+ String apiVer="test";
+ List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer);
+ assertNotNull(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery1() throws AAIException{
+ String transId="teet";
+ String fromAppId="test";
+ String namedQueryUuid="test";
+ String secondaryFilterCutPoint="test";
+ List <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
+ String apiVer="test";
+ Map<String,Object> secondaryFilterHash=new HashMap<String,Object>();
+ List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer,secondaryFilterCutPoint,secondaryFilterHash);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void deleteAsNeededFromResultSet() throws AAIException {
+ Vertex vert = new BaseVertexLabel("Test");
+ Map<String, String> resultMock = new HashMap<String, String>();
+ ResultSet resultSet = new ResultSet();
+ resultSet.setVert(null);
+
+ Map<String, String> result = processor.deleteAsNeededFromResultSet("test", "test",
+ resultSet, "test", "test",
+ "test",
+ resultMock);
+
+ assertEquals(result.size(), 0);
+
+ resultSet.setVert(vert);
+
+ Map<String, String> result1 = processor.deleteAsNeededFromResultSet("test", "test",
+ resultSet, "test", "test",
+ "test",
+ resultMock);
+
+ assertEquals(result.size(), 0);
+
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void pruneResultSetTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ ResultSet resultSet = processor.pruneResultSet(rs, "testr", map);
+ assertNotNull(resultSet);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void satisfiesFiltersTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ rs.getVert().property(AAIProperties.NODE_TYPE);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+
+ map.put("modern.vertex-id", new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, true);
+ }
+
+ @Test
+ public void satisfiesFiltersTest1() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ //map.put("test.filter",new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, false);
+ }
+
+ @Test(expected = AAIException.class)
+ public void satisfiesFiltersTest2() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("testfilter", new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, false);
+ }
+
+ @Test
+ public void collapseForDoNotOutputTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ rs.setDoNotOutputFlag("true");
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ List<ResultSet> result = processor.collapseForDoNotOutput(rs);
+ assertEquals(result.size(), 1);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectInstanceDataTest() throws AAIException {
+
+ BaseVertexLabel bs = new BaseVertexLabel("test");
+ //bs.setId(80);
+ EmptyVertex ev = new EmptyVertex();
+ //ev.setId(50l);
+ Vertex thisLevelElemVtx = ev;
+
+
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ List<String> vidsTraversed = new ArrayList<String>();
+ // only applies when collecting data using the default model for delete
+ Multimap<String, String> validNextStepMap = ArrayListMultimap.create();
+ Map<String, String> namedQueryElementHash = new HashMap<String, String>();
+ namedQueryElementHash.put("test", "test");
+ Map<String, String> delKeyHash = new HashMap<String, String>();
+
+ ResultSet rs = processor.collectInstanceData("test", "test", thisLevelElemVtx, "test", validNextStepMap, vidsTraversed, 1, delKeyHash, namedQueryElementHash, "test");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void genTopoMap4ModelVerTest() throws
+ AAIException {
+ Vertex vertext = new EmptyVertex();
+ Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
+ assertNotEquals(map, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4ModelVerTestNull() throws
+ AAIException {
+ Vertex vertext = null;
+ Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
+ assertNotEquals(map, null);
+ }
+
+ @Test
+ public void makeSureItsAnArrayListTest() {
+ String input = "model-versionId,modelTestID,modelTestid2;";
+ List<String> result = processor.makeSureItsAnArrayList(input);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModConstraintHashTest() throws AAIException {
+ Vertex modelElementVtx = new EmptyVertex();
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = new EmptyVertex();
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModConstraintHashTestNull() throws AAIException {
+ Vertex modelElementVtx = null;
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 =null;
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getTopElementForSvcOrResModelVerTest() throws AAIException {
+ Vertex modelElementVtx = new EmptyVertex();
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = new EmptyVertex();
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Vertex result = processor.getTopElementForSvcOrResModelVer(modelElementVtx, "test");
+ assertNotEquals(result, null);
+ }
+
+ @Test
+ public void getNamedQueryPropOverRideTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNamedQueryPropOverRideTestNull() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void namedQueryConstraintSaysStopTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void namedQueryConstraintSaysStopTestNull() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void namedQuerynamedQueryElementVertexNullTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = null;
+ String apiVer = "test";
+
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+
+ public void getNamedQueryExtraDataLookupTest() throws Exception {
+
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryExtraDataLookup(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectNQElementHash() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, String> currentHash = new HashMap<String, String>();
+ ArrayList<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Map<String, String> result = processor.collectNQElementHash(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, currentHash,
+ vidsTraversed, levelCounter);
+
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectDeleteKeyHash() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, String> currentHash = new HashMap<String, String>();
+ ArrayList<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+ Map<String, Vertex> modConstraintHash = new HashMap<String, Vertex>();
+ String overRideModelId = "test";
+ String overRideModelVersionId = "test";
+
+ Map<String, String> result = processor.collectDeleteKeyHash(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, currentHash,
+ vidsTraversed, levelCounter, modConstraintHash, overRideModelId, overRideModelVersionId);
+
+ assertNotEquals(result, null);
+ }
+
+ @Test
+ public void getLinkageConnectNodeTypesTest() throws AAIException {
+ List<String> linkagePtList = new ArrayList<String>();
+ linkagePtList.add("modern\\|testdata\\|");
+ Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
+ assertNotEquals(result, null);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getLinkageConnectNodeTypesTest1() throws AAIException {
+
+ Set<String> result1 = processor.getLinkageConnectNodeTypes(null);
+ assertNotEquals(result1, null);
+
+ List<String> linkagePtList = new ArrayList<String>();
+ linkagePtList.add("moderntestdata");
+ Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectTopology4ModelVerTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ List<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Multimap<String, String> result = processor.collectTopology4ModelVer(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter, currentHash
+ , "test", "test");
+
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void check4EdgeRuleTest() throws AAIException {
+ processor.check4EdgeRule("test", "test");
+ }
+
+ @Test(expected = AAIException.class)
+ public void collectTopology4LinkagePointTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ String linkagePointStrVal = "test";
+ String incomingTrail = "test";
+ Multimap<String, String> currentMap = ArrayListMultimap.create();
+
+ Multimap<String, String> result = processor.collectTopology4LinkagePoint(transId, fromAppId, linkagePointStrVal, incomingTrail, currentMap);
+ assertNotEquals(result, null);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getNextStepElementsFromSet() throws AAIException {
+ Vertex constrElemSetVtx = new EmptyVertex();
+ constrElemSetVtx.<String>property(AAIProperties.NODE_TYPE);
+ Map<String, Object> result = processor.getNextStepElementsFromSet(constrElemSetVtx);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void genTopoMap4NamedQTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex queryVertex = new EmptyVertex();
+ String namedQueryUuid = "E44533334343";
+ Multimap<String, String> result = processor.genTopoMap4NamedQ(transId, fromAppId, queryVertex, namedQueryUuid);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectTopology4NamedQTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ List<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Multimap<String, String> result = processor.collectTopology4NamedQ(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelThatNqElementRepresentsTest() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Vertex vertex = processor.getModelThatNqElementRepresents(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelGivenModelVer() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Vertex vertex = processor.getModelGivenModelVer(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelTypeFromModel() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelTypeFromModel(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelTypeFromModelVer() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelTypeFromModelVer(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelElementStepName() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelElementStepName(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void nodeTypeSupportsPersona() throws AAIException {
+ String incomingTrail = "";
+ boolean vertex = processor.nodeTypeSupportsPersona(incomingTrail);
+ assertFalse(vertex);
+
+
+ incomingTrail = "test";
+ boolean vertex1 = processor.nodeTypeSupportsPersona(incomingTrail);
+ assertTrue(vertex1);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNqElementWidgetType() throws AAIException{
+ String appId="test";
+ String transID="test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex1 = processor.getNqElementWidgetType(appId,transID,thisLevelElemVtx,incomingTrail);
+ assertNotEquals(vertex1,null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getModElementWidgetType() throws AAIException{
+ String appId="test";
+ String transID="test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex1 = processor.getModElementWidgetType(thisLevelElemVtx,incomingTrail);
+ assertNotEquals(vertex1,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNodeUsingUniqueId() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "test";
+ String uniqueIdVal="test";
+ Vertex vertex1 = processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "test";
+ String uniqueIdVal="";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull1() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName="";
+ String uniqueIdVal="test";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull2() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "";
+ String idPropertyName="test";
+ String uniqueIdVal="test";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVersUsingName() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+
+ List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getModelVersUsingNameNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "";
+
+ List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModelInvId() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+
+ Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModVersUsingModelInvIdNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "";
+
+ Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModel() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModVersUsingModel1() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ Vertex thisLevelElemVtx = null;
+ List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerIdsUsingName() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelName= "test";
+ List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelVerIdsUsingName1() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelName= "";
+ List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected =NullPointerException.class)
+ public void validateModel() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelVersionId= "test";
+ String modelInvId= "test";
+ String modelName= "test";
+ processor.validateModel(transID,appId,modelName,modelVersionId);
+
+
+ }
+
+
+
+}
+
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
new file mode 100644
index 0000000..406d122
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
@@ -0,0 +1,542 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.dbgraphgen;
+
+import static org.junit.Assert.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.onap.aai.db.DbMethHelper;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.parsers.exceptions.AAIIdentityMapParseException;
+import org.onap.aai.query.builder.GraphTraversalBuilder;
+import org.onap.aai.query.builder.QueryBuilder;
+import org.onap.aai.query.builder.TraversalQuery;
+import org.onap.aai.schema.enums.PropertyMetadata;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.db.EdgeType;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.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/onap/aai/dbgraphmap/SearchGraphTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java
new file mode 100644
index 0000000..f624828
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java
@@ -0,0 +1,379 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.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.onap.aai.dbgraphgen.ModelBasedProcessing;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.extensions.AAIExtensionMap;
+import org.onap.aai.introspection.*;
+import org.onap.aai.parsers.relationship.RelationshipToURI;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+
+
+import 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.onap.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.onap.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.onap.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.onap.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/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java
new file mode 100644
index 0000000..40de5a9
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java
@@ -0,0 +1,204 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.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/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java
new file mode 100644
index 0000000..52c6a42
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java
@@ -0,0 +1,111 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.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/onap/aai/interceptors/PostAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java
new file mode 100644
index 0000000..6efb0d1
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java
@@ -0,0 +1,74 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.interceptors;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.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/onap/aai/interceptors/PreAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java
new file mode 100644
index 0000000..35651c3
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java
@@ -0,0 +1,63 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.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/onap/aai/rest/ExceptionHandlerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
new file mode 100644
index 0000000..eaf9e55
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
@@ -0,0 +1,156 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest;
+
+import com.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/onap/aai/rest/search/CloudRegionFromNfTypeQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeQueryTest.java
new file mode 100644
index 0000000..1c93230
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeQueryTest.java
@@ -0,0 +1,80 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionFromNfTypeQueryTest extends QueryTest {
+ public CloudRegionFromNfTypeQueryTest() 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", "vnfid01", "nf-type", "sample-nf-type");
+ Vertex cloudregion0 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "regionid00", "cloud-region-owner", "cloudOwnername00");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "4", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "5", "aai-node-type", "vserver", "vserver-id", "vserverid01");
+
+ Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "8", "aai-node-type", "generic-vnf", "vnf-id", "vnfid02", "nf-type", "ex-nf-type");
+ Vertex cloudregion3 = graph.addVertex(T.label, "cloud-region", T.id, "9", "aai-node-type", "cloud-region", "cloud-region-id", "regionid03", "cloud-region-owner", "cloudOwnername03");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant", T.id, "10", "aai-node-type", "tenant", "tenant-id", "tenantid02", "tenant-name", "tenantName02");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-id", "vserverid02");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, tenant, cloudregion0);
+ rules.addTreeEdge(g, vserver1, tenant);
+ rules.addEdge(g, genericvnf, vserver1);
+
+ rules.addTreeEdge(g, tenant2, cloudregion3);
+ rules.addTreeEdge(g, vserver2, tenant2);
+ rules.addEdge(g, genericvnf2, vserver2);
+
+ expectedResult.add(cloudregion0);
+ }
+ @Override
+ protected String getQueryName() {
+ return "cloudRegion-fromNfType";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("nf-type", "sample-nf-type");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java
new file mode 100644
index 0000000..ae04734
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java
@@ -0,0 +1,100 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionFromNfTypeVendorVersionTest extends QueryTest {
+
+ public CloudRegionFromNfTypeVendorVersionTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex image1 = graph.addVertex(T.label, "image", T.id, "10", "aai-node-type", "image",
+ "image-id", "image1", "image-name", "imageName1", "image-os-distro", "boopOS", "image-os-version", "1.0", "image-selflink", "self/link",
+ "application-vendor","vendor1");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "20", "aai-node-type", "vserver", "vserver-id", "vserverid01");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "21", "aai-node-type", "vserver", "vserver-id", "vserverid02");
+ Vertex vserver3 = graph.addVertex(T.label, "vserver", T.id, "22", "aai-node-type", "vserver", "vserver-id", "vserverid03");
+
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "30", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant", T.id, "31", "aai-node-type", "tenant", "tenant-id", "tenantid02", "tenant-name", "tenantName02");
+ Vertex tenant3 = graph.addVertex(T.label, "tenant", T.id, "32", "aai-node-type", "tenant", "tenant-id", "tenantid03", "tenant-name", "tenantName03");
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "40", "aai-node-type", "generic-vnf", "vnf-id", "genvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+ Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "41", "aai-node-type", "generic-vnf", "vnf-id", "genvnf2", "vnf-name", "genvnfname2", "nf-type", "wrong-nf-type");
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region", "cloud-region-id", "cloudreg1", "cloud-region-owner", "cloudOwnername00");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "51", "aai-node-type", "cloud-region", "cloud-region-id", "cloudreg2", "cloud-region-owner", "cloudOwnername01");
+ Vertex cloudregion3 = graph.addVertex(T.label, "cloud-region", T.id, "52", "aai-node-type", "cloud-region", "cloud-region-id", "cloudreg3", "cloud-region-owner", "cloudOwnername02");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, cloudregion1, tenant1);
+ rules.addTreeEdge(g, cloudregion2, tenant2);
+ rules.addTreeEdge(g, cloudregion3, tenant3);
+ rules.addTreeEdge(g, tenant1, vserver1);
+ rules.addTreeEdge(g, tenant2, vserver2);
+ rules.addTreeEdge(g, tenant3, vserver3);
+ rules.addEdge(g, genericvnf1, vserver1);
+ rules.addEdge(g, genericvnf2, vserver2);
+ rules.addEdge(g, genericvnf1, vserver3);
+ rules.addEdge(g, vserver1, image1);
+ rules.addEdge(g, vserver2, image1);
+ rules.addEdge(g, vserver3, image1);
+
+ expectedResult.add(cloudregion1);
+ expectedResult.add(cloudregion3);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloudRegion-fromNfTypeVendorVersion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","image").has("application-vendor","vendor1"); //TODO another test w the optional param too
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("nfType", "sample-nf-type");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java
new file mode 100644
index 0000000..59b0d0a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java
@@ -0,0 +1,104 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionFromNfTypeVendorVersion_withOptionalTest extends QueryTest {
+
+ public CloudRegionFromNfTypeVendorVersion_withOptionalTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex image1 = graph.addVertex(T.label, "image", T.id, "10", "aai-node-type", "image",
+ "image-id", "image1", "image-name", "imageName1", "image-os-distro", "boopOS", "image-os-version", "1.0", "image-selflink", "self/link",
+ "application-vendor","vendor1","application-version","1.0");
+ Vertex image2 = graph.addVertex(T.label, "image", T.id, "11", "aai-node-type", "image",
+ "image-id", "image2", "image-name", "imageName2", "image-os-distro", "boopOS", "image-os-version", "1.0", "image-selflink", "self/link",
+ "application-vendor","vendor1","application-version","2.1");
+ Vertex image3 = graph.addVertex(T.label, "image", T.id, "12", "aai-node-type", "image",
+ "image-id", "image3", "image-name", "imageName3", "image-os-distro", "boopOS", "image-os-version", "1.0", "image-selflink", "self/link",
+ "application-vendor","wrongVendor","application-version","1.0");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "20", "aai-node-type", "vserver", "vserver-id", "vserverid01");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "21", "aai-node-type", "vserver", "vserver-id", "vserverid02");
+ Vertex vserver3 = graph.addVertex(T.label, "vserver", T.id, "22", "aai-node-type", "vserver", "vserver-id", "vserverid03");
+
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "30", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant", T.id, "31", "aai-node-type", "tenant", "tenant-id", "tenantid02", "tenant-name", "tenantName02");
+ Vertex tenant3 = graph.addVertex(T.label, "tenant", T.id, "32", "aai-node-type", "tenant", "tenant-id", "tenantid03", "tenant-name", "tenantName03");
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "40", "aai-node-type", "generic-vnf", "vnf-id", "genvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region", "cloud-region-id", "cloudreg1", "cloud-region-owner", "cloudOwnername00");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "51", "aai-node-type", "cloud-region", "cloud-region-id", "cloudreg2", "cloud-region-owner", "cloudOwnername01");
+ Vertex cloudregion3 = graph.addVertex(T.label, "cloud-region", T.id, "52", "aai-node-type", "cloud-region", "cloud-region-id", "cloudreg3", "cloud-region-owner", "cloudOwnername02");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, cloudregion1, tenant1);
+ rules.addTreeEdge(g, cloudregion2, tenant2);
+ rules.addTreeEdge(g, cloudregion3, tenant3);
+ rules.addTreeEdge(g, tenant1, vserver1);
+ rules.addTreeEdge(g, tenant2, vserver2);
+ rules.addTreeEdge(g, tenant3, vserver3);
+ rules.addEdge(g, genericvnf1, vserver1);
+ rules.addEdge(g, genericvnf1, vserver2);
+ rules.addEdge(g, genericvnf1, vserver3);
+ rules.addEdge(g, vserver1, image1);
+ rules.addEdge(g, vserver2, image2);
+ rules.addEdge(g, vserver3, image3);
+
+ expectedResult.add(cloudregion1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloudRegion-fromNfTypeVendorVersion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","image").has("application-vendor","vendor1").has("application-version","1.0");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("nfType", "sample-nf-type");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java
new file mode 100644
index 0000000..f828558
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java
@@ -0,0 +1,84 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java
new file mode 100644
index 0000000..08c62af
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java
@@ -0,0 +1,77 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionfromCountryCloudRegionVersionQueryTest extends QueryTest {
+ public CloudRegionfromCountryCloudRegionVersionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1","country","country1");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1","cloud-region-version","cloud-region-version-1");
+
+
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "2", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2","country","country2");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-2","cloud-region-version","cloud-region-version-2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex,cloudregion);
+
+ rules.addEdge(g, complex1,cloudregion1);
+
+ expectedResult.add(cloudregion);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloudRegion-fromCountryCloudRegionVersion";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "complex").has("country", "country1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionVersion", "cloud-region-version-1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryQueryTest.java
new file mode 100644
index 0000000..4106939
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryQueryTest.java
@@ -0,0 +1,77 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionfromCountryQueryTest extends QueryTest {
+ public CloudRegionfromCountryQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1");
+
+
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "2", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex,cloudregion);
+
+ rules.addEdge(g, complex1,cloudregion1);
+
+ expectedResult.add(cloudregion);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloudRegion-fromCountry";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("physical-location-id", "physical-location-id-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java
new file mode 100644
index 0000000..88831bd
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java
@@ -0,0 +1,99 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class FirstNetTopology_LineOfBusinessTest extends QueryTest {
+ public FirstNetTopology_LineOfBusinessTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex lineofbusiness = graph.addVertex(T.label, "line-of-business", T.id, "0", "aai-node-type", "line-of-business", "line-of-business-name", "business0");
+ 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 vnfc = graph.addVertex(T.label, "vnfc", T.id, "2", "aai-node-type", "vnfc", "vnfc-name", "vnfc0", "nfc-naming-code", "namingCode0", "nfc-function", "function0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid0","vserver-name", "vserver-name-1");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "5", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+
+
+ Vertex lineofbusiness1 = graph.addVertex(T.label, "line-of-business", T.id, "10", "aai-node-type", "line-of-business", "line-of-business-name", "business1");
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "11", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1","vnf-name", "vnf-name-2", "nf-type", "sample-nf-type1");
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc", T.id, "12", "aai-node-type", "vnfc", "vnfc-name", "vnfc1", "nfc-naming-code", "namingCode1", "nfc-function", "function1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "13", "aai-node-type", "vserver", "vserver-id", "vserverid1","vserver-name", "vserver-name-2");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "15", "aai-node-type", "pnf", "pnf-name", "pnf1name1");
+
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, genericvnf,lineofbusiness);
+ rules.addEdge(g, genericvnf, vnfc);
+ rules.addEdge(g, genericvnf, vserver);
+ rules.addEdge(g, genericvnf,pserver);
+ rules.addEdge(g, genericvnf, pnf);
+
+ //false
+ rules.addEdge(g, genericvnf1,lineofbusiness1);
+ rules.addEdge(g, genericvnf1, vnfc1);
+ rules.addEdge(g, genericvnf1, vserver1);
+ rules.addEdge(g, genericvnf1,pserver1);
+ rules.addEdge(g, genericvnf1, pnf1);
+
+ expectedResult.add(genericvnf);
+ expectedResult.add(vnfc);
+ expectedResult.add(vserver);
+ expectedResult.add(pserver);
+ expectedResult.add(pnf);
+
+
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "fn-topology";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "line-of-business").has("line-of-business-name", "business0");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java
new file mode 100644
index 0000000..a53ca0c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java
@@ -0,0 +1,106 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class FirstNetTopology_ServiceInstanceTest extends QueryTest {
+ public FirstNetTopology_ServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "0", "aai-node-type", "customer","global-customer-id", "global-customer-id-1", "subscriber-name", "subscriber-name-1");
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "1", "aai-node-type","service-subscription", "service-type", "service-type-1");
+ 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 genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0","vnf-name", "vnf-name-1", "nf-type", "sample-nf-type");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "4", "aai-node-type", "vnfc", "vnfc-name", "vnfc0", "nfc-naming-code", "namingCode0", "nfc-function", "function0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "5", "aai-node-type", "vserver", "vserver-id", "vserverid0","vserver-name", "vserver-name-1");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "6", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "7", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "10", "aai-node-type", "customer","global-customer-id", "global-customer-id-2", "subscriber-name", "subscriber-name-2");
+ Vertex serviceSubscription1 = graph.addVertex(T.label, "service-subscription", T.id, "11", "aai-node-type","service-subscription", "service-type", "service-type-2");
+ Vertex serviceInstance1 = graph.addVertex(T.label, "service-instance", T.id, "12", "aai-node-type","service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name","service-instance-name-2");
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "13", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1","vnf-name", "vnf-name-2", "nf-type", "sample-nf-type1");
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc", T.id, "14", "aai-node-type", "vnfc", "vnfc-name", "vnfc1", "nfc-naming-code", "namingCode1", "nfc-function", "function1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "15", "aai-node-type", "vserver", "vserver-id", "vserverid1","vserver-name", "vserver-name-2");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "16", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name1");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, genericvnf, serviceInstance);
+ rules.addTreeEdge(g, serviceInstance, serviceSubscription);
+ rules.addTreeEdge(g, serviceSubscription, customer);
+ rules.addEdge(g, genericvnf, vnfc);
+ rules.addEdge(g, genericvnf, vserver);
+ rules.addEdge(g, genericvnf,pserver);
+ rules.addEdge(g, genericvnf, pnf);
+
+
+ //false
+ rules.addEdge(g, genericvnf1, serviceInstance1);
+ rules.addTreeEdge(g, serviceInstance1, serviceSubscription1);
+ rules.addTreeEdge(g, serviceSubscription1, customer1);
+ rules.addEdge(g, genericvnf1, vnfc1);
+ rules.addEdge(g, genericvnf1, vserver1);
+ rules.addEdge(g, genericvnf1,pserver1);
+ rules.addEdge(g, genericvnf1, pnf1);
+
+ expectedResult.add(genericvnf);
+ expectedResult.add(vnfc);
+ expectedResult.add(vserver);
+ expectedResult.add(pserver);
+ expectedResult.add(pnf);
+
+
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "fn-topology";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("service-instance-name", "service-instance-name-1");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
new file mode 100644
index 0000000..5c6a45f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
@@ -0,0 +1,164 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.rest.search;
+
+import 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.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.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/onap/aai/rest/search/GroovyShellImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
new file mode 100644
index 0000000..3735e97
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
@@ -0,0 +1,158 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.rest.search;
+
+import 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.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.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/onap/aai/rest/search/ImageFromCloudRegionNfTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ImageFromCloudRegionNfTypeTest.java
new file mode 100644
index 0000000..02f7162
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ImageFromCloudRegionNfTypeTest.java
@@ -0,0 +1,110 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ImageFromCloudRegionNfTypeTest extends QueryTest {
+
+ public ImageFromCloudRegionNfTypeTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region", "cloud-region-id", "cloudreg1", "cloud-region-owner", "cloudOwnername00");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "11", "aai-node-type", "cloud-region", "cloud-region-id", "cloudregWrong", "cloud-region-owner", "cloudOwnername01");
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "20", "aai-node-type", "generic-vnf", "vnf-id", "genvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+ Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "21", "aai-node-type", "generic-vnf", "vnf-id", "genvnf2", "vnf-name", "genvnfname2", "nf-type", "wrong-nf-type");
+ Vertex genericvnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "22", "aai-node-type", "generic-vnf", "vnf-id", "genvnf3", "vnf-name", "genvnfname3", "nf-type", "sample-nf-type");
+
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "30", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant", T.id, "31", "aai-node-type", "tenant", "tenant-id", "tenantid02", "tenant-name", "tenantName02");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "40", "aai-node-type", "vserver", "vserver-id", "vserverid01");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "41", "aai-node-type", "vserver", "vserver-id", "vserverid02");
+ Vertex vserver3 = graph.addVertex(T.label, "vserver", T.id, "42", "aai-node-type", "vserver", "vserver-id", "vserverid03");
+ Vertex vserver4 = graph.addVertex(T.label, "vserver", T.id, "43", "aai-node-type", "vserver", "vserver-id", "vserverid04");
+ Vertex vserver5 = graph.addVertex(T.label, "vserver", T.id, "44", "aai-node-type", "vserver", "vserver-id", "vserverid05");
+
+ Vertex image1 = graph.addVertex(T.label, "image", T.id, "50", "aai-node-type", "image",
+ "image-id", "image1", "image-name", "imageName1", "image-os-distro", "boopOS", "image-os-version", "1.0", "image-selflink", "self/link");
+ Vertex image2 = graph.addVertex(T.label, "image", T.id, "51", "aai-node-type", "image",
+ "image-id", "image2", "image-name", "imageName2", "image-os-distro", "beepOS", "image-os-version", "1.0", "image-selflink", "self/link");
+ Vertex image3 = graph.addVertex(T.label, "image", T.id, "52", "aai-node-type", "image",
+ "image-id", "image3", "image-name", "imageName3", "image-os-distro", "beepOS", "image-os-version", "1.1", "image-selflink", "self/link");
+ Vertex image4 = graph.addVertex(T.label, "image", T.id, "53", "aai-node-type", "image",
+ "image-id", "image4", "image-name", "imageName4", "image-os-distro", "beepOS", "image-os-version", "1.1", "image-selflink", "self/link");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, cloudregion1, tenant1);
+ rules.addTreeEdge(g, cloudregion2, tenant2);
+ rules.addTreeEdge(g, tenant1, vserver1);
+ rules.addTreeEdge(g, tenant1, vserver2);
+ rules.addTreeEdge(g, tenant2, vserver3);
+ rules.addTreeEdge(g, tenant1, vserver4);
+ rules.addTreeEdge(g, tenant1, vserver5);
+ rules.addEdge(g, vserver1, image1);
+ rules.addEdge(g, vserver2, image2);
+ rules.addEdge(g, vserver3, image3);
+ rules.addEdge(g, vserver4, image4);
+ rules.addEdge(g, vserver5, image1);
+ rules.addEdge(g, genericvnf1, vserver1);
+ rules.addEdge(g, genericvnf2, vserver2);
+ rules.addEdge(g, genericvnf1, vserver3);
+ rules.addEdge(g, genericvnf3, vserver4);
+
+ expectedResult.add(image1);
+ expectedResult.add(image4);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "images-fromCloudRegionNfType";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","cloud-region").has("cloud-region-id","cloudreg1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("nfType", "sample-nf-type");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java
new file mode 100644
index 0000000..c4b90bf
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java
@@ -0,0 +1,99 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class LinkedDevices_ComplicatedGVtoGV extends QueryTest {
+
+ public LinkedDevices_ComplicatedGVtoGV() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
+ "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
+ "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
+
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
+ "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "30", "aai-node-type", "vlan",
+ "vlan-interface", "vlan1");
+
+ Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "21", "aai-node-type", "logical-link",
+ "link-name", "loglink2", "in-maint", "false", "link-type", "sausage");
+
+ Vertex lagint = graph.addVertex(T.label, "lag-interface", T.id, "40", "aai-node-type", "lag-interface",
+ "interface-name", "lagint1");
+
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, gvnf1, lint1);
+ rules.addEdge(g, lint1, loglink1);
+ rules.addEdge(g, lint2, loglink1);
+ rules.addTreeEdge(g, lint2, vlan);
+ rules.addEdge(g, vlan, loglink2);
+ rules.addEdge(g, loglink2, lagint);
+ rules.addTreeEdge(g, gvnf2, lagint);
+
+ expectedResult.add(gvnf1);
+ expectedResult.add(gvnf2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "linked-devices";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvnf1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ // n/a for this query
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
new file mode 100644
index 0000000..dcc3d32
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
@@ -0,0 +1,112 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class LinkedDevices_NewvceVserverTest extends QueryTest {
+
+ public LinkedDevices_NewvceVserverTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Note: I don't know if this topology is realistic, but it doesn't really matter bc we're just testing functionality
+ Vertex newvce1 = graph.addVertex(T.label, "newvce", T.id, "00", "aai-node-type", "newvce",
+ "vnf-id2", "newvce1", "vnf-name", "bob", "vnf-type", "new");
+
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
+ "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
+ "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
+ "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "40", "aai-node-type", "vlan",
+ "vlan-interface", "vlan1");
+
+ Vertex newvce2 = graph.addVertex(T.label, "newvce", T.id, "01", "aai-node-type", "newvce",
+ "vnf-id2", "newvce2", "vnf-name", "bob", "vnf-type", "new");
+
+ Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "21", "aai-node-type", "logical-link",
+ "link-name", "loglink2", "in-maint", "false", "link-type", "sausage");
+ Vertex lint3 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface",
+ "interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region",
+ "cloud-owner", "att", "cloud-region-id", "crId");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "60", "aai-node-type", "tenant",
+ "tenant-id", "tenId", "tenant-name", "verity");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "30", "aai-node-type", "vserver",
+ "vserver-id", "vserv1", "vserver-name", "frank");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, newvce1, lint1);
+ rules.addTreeEdge(g, lint1, vlan);
+ rules.addEdge(g, lint1, loglink1);
+ rules.addEdge(g, lint2, loglink1);
+
+ rules.addTreeEdge(g, cloudregion, tenant);
+ rules.addTreeEdge(g, tenant, vserver);
+ rules.addTreeEdge(g, vserver, lint2);
+
+ rules.addEdge(g, vlan, loglink2);
+ rules.addTreeEdge(g, newvce2, lint3);
+ rules.addEdge(g, loglink2, lint3);
+
+ expectedResult.add(newvce1);
+ expectedResult.add(newvce2);
+ expectedResult.add(vserver);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "linked-devices";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "newvce").has("vnf-id2", "newvce1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ // n/a for this query
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java
new file mode 100644
index 0000000..399b60a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java
@@ -0,0 +1,87 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class LinkedDevices_SimpleGVtoGVQueryTest extends QueryTest {
+
+ public LinkedDevices_SimpleGVtoGVQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
+ "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex loglink = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
+ "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
+
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
+ "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, gvnf1, lint1);
+ rules.addTreeEdge(g, gvnf2, lint2);
+ rules.addEdge(g, lint1, loglink);
+ rules.addEdge(g, lint2, loglink);
+
+ expectedResult.add(gvnf1);
+ expectedResult.add(gvnf2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "linked-devices";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","generic-vnf").has("vnf-id","gvnf1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ // n/a for this test
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java
new file mode 100644
index 0000000..6dcb071
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java
@@ -0,0 +1,83 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class LocationNetTypeNetRolefromCloudRegionQueryTest extends QueryTest {
+ public LocationNetTypeNetRolefromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "1", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "2", "aai-node-type", "l3-network", "network-id", "network-id-1");
+
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-2");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "4", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "5", "aai-node-type", "l3-network", "network-id", "network-id-2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, cloudregion,complex);
+ rules.addEdge(g, complex,l3network);
+
+ rules.addEdge(g, cloudregion1,complex1);
+ rules.addEdge(g, complex1,l3network1);
+
+ expectedResult.add(cloudregion);
+ expectedResult.add(complex);
+ expectedResult.add(l3network);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "locationNetTypeNetRole-fromCloudRegion";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("cloud-region-id", "cloud-region-id-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
new file mode 100644
index 0000000..ea5bc85
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
@@ -0,0 +1,186 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import 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.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+
+import 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/onap/aai/rest/search/MsoRequestVfModuleTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/MsoRequestVfModuleTest.java
new file mode 100644
index 0000000..225d45f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/MsoRequestVfModuleTest.java
@@ -0,0 +1,97 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java
new file mode 100644
index 0000000..83b6d2f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java
@@ -0,0 +1,89 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/NfTypefromCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/NfTypefromCloudRegionQueryTest.java
new file mode 100644
index 0000000..4b667d0
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/NfTypefromCloudRegionQueryTest.java
@@ -0,0 +1,84 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class NfTypefromCloudRegionQueryTest extends QueryTest {
+ public NfTypefromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "1", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver", "vserver-id", "vserver-id-1","vserver-name","vserver-name-1");
+ Vertex gnvf = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1");
+
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "4", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-2");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "5", "aai-node-type", "tenant", "tenant-id", "tenantid2", "tenant-name", "tenantName-2");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver", "vserver-id", "vserver-id-1","vserver-name","vserver-name-1");
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, tenant,cloudregion);
+ rules.addTreeEdge(g, vserver,tenant);
+ rules.addEdge(g, vserver, gnvf);
+
+ rules.addTreeEdge(g, tenant1,cloudregion1);
+ rules.addTreeEdge(g, vserver1,tenant1);
+ rules.addEdge(g, vserver1, gnvf1);
+
+ expectedResult.add(gnvf);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "nfType-fromCloudRegion";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("cloud-region-id", "cloud-region-id-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/OwningEntityfromServiceInstance.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/OwningEntityfromServiceInstance.java
new file mode 100644
index 0000000..d0fd1b1
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/OwningEntityfromServiceInstance.java
@@ -0,0 +1,76 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class 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/onap/aai/rest/search/PendingTopologyDetailTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java
new file mode 100644
index 0000000..d282164
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java
@@ -0,0 +1,160 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
new file mode 100644
index 0000000..9a427ca
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
@@ -0,0 +1,104 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/PserverfromConfigurationTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
new file mode 100644
index 0000000..9638cfd
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
@@ -0,0 +1,102 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/PserversFromVnfQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversFromVnfQueryTest.java
new file mode 100644
index 0000000..e6abee6
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversFromVnfQueryTest.java
@@ -0,0 +1,91 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserversFromVnfQueryTest extends QueryTest {
+ public PserversFromVnfQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername1");
+
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "7", "aai-node-type", "tenant", "tenant-id", "tenantuuid", "tenant-name", "tenantname");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "8", "aai-node-type", "cloud-region", "cloud-region-id", "clouduuid", "cloud-region-owner", "cloudOwnername");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver1, complex);
+ rules.addEdge(g, pserver2, complex);
+
+ rules.addEdge(g, pserver1, vnf1);
+ rules.addEdge(g, pserver2, vnf2);
+
+ rules.addEdge(g, pserver3, complex);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addEdge(g, vserver, pserver3);
+ rules.addEdge(g, vserver, vnf2);
+
+ expectedResult.add(pserver2);
+ expectedResult.add(pserver3);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "pservers-fromVnf";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-id", "vnfid2");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
new file mode 100644
index 0000000..5457937
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
@@ -0,0 +1,99 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.query.builder.GremlinTraversal;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+public abstract class QueryTest {
+
+ protected Graph graph;
+ private GremlinServerSingleton gremlinServerSingleton;
+ private GremlinGroovyShellSingleton shell;
+ @Mock private TransactionalGraphEngine dbEngine;
+ protected final List<Vertex> expectedResult = new ArrayList<>();
+ protected final EdgeRules rules = EdgeRules.getInstance();
+ protected Loader loader;
+
+ public QueryTest() throws AAIException, NoEdgeRuleFoundException {
+ setUp();
+ }
+ public void setUp() throws AAIException, NoEdgeRuleFoundException {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ MockitoAnnotations.initMocks(this);
+ graph = TinkerGraph.open();
+ createGraph();
+ gremlinServerSingleton = GremlinServerSingleton.getInstance();
+ shell = GremlinGroovyShellSingleton.getInstance();
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
+ }
+
+ public void run() {
+
+ String query = gremlinServerSingleton.getStoredQuery(getQueryName());
+ Map<String, Object> params = new HashMap<>();
+ addParam(params);
+ when(dbEngine.getQueryBuilder(any(QueryStyle.class))).thenReturn(new GremlinTraversal<>(loader, graph.traversal()));
+ query = GroovyQueryBuilderSingleton.getInstance().executeTraversal(dbEngine, query, params);
+ query = "g" + query;
+ GraphTraversal<Vertex, Vertex> g = graph.traversal().V();
+ addStartNode(g);
+ params.put("g", g);
+ GraphTraversal<Vertex, Vertex> result = (GraphTraversal<Vertex, Vertex>)shell.executeTraversal(query, params);
+
+ List<Vertex> vertices = result.toList();
+ assertTrue("all vertices found", vertices.containsAll(expectedResult) && expectedResult.containsAll(vertices));
+
+ }
+
+ protected abstract void createGraph() throws AAIException, NoEdgeRuleFoundException;
+
+ protected abstract String getQueryName();
+
+ protected abstract void addStartNode(GraphTraversal<Vertex, Vertex> g);
+
+ protected abstract void addParam(Map<String, Object> params);
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
new file mode 100644
index 0000000..67f7d11
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
@@ -0,0 +1,103 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class 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/onap/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
new file mode 100644
index 0000000..8633cb4
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
@@ -0,0 +1,267 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import 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.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+
+import 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/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
new file mode 100644
index 0000000..3be5b34
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
@@ -0,0 +1,112 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ServiceFromPserverAndSubsNameTest extends QueryTest {
+ public ServiceFromPserverAndSubsNameTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername01");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername02-wrong");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid01");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "4", "aai-node-type", "vserver", "vserver-id", "vserverid02");
+ Vertex vserver3 = graph.addVertex(T.label, "vserver", T.id, "5", "aai-node-type", "vserver", "vserver-id", "vserverid03");
+
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "8", "aai-node-type", "generic-vnf", "vnf-id", "vnfid01");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnfid02");
+ Vertex vnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "10", "aai-node-type", "generic-vnf", "vnf-id", "vnfid03");
+
+ Vertex servinst1 = graph.addVertex(T.label, "service-instance", T.id, "61", "aai-node-type", "service-instance", "service-instance-id", "servInstId01", "service-type", "servType01");
+ Vertex servinst2 = graph.addVertex(T.label, "service-instance", T.id, "12", "aai-node-type", "service-instance", "service-instance-id", "servInstId02", "service-type", "servType02", "service-role", "servRole02");
+ Vertex servinst3 = graph.addVertex(T.label, "service-instance", T.id, "13", "aai-node-type", "service-instance", "service-instance-id", "servInstId03-wrong", "service-type", "servType03", "service-role", "servRole03");
+
+ Vertex servsub1 = graph.addVertex(T.label, "service-subscription", T.id, "14", "aai-node-type", "service-subscription", "service-type", "servType01");
+ Vertex servsub2 = graph.addVertex(T.label, "service-subscription", T.id, "15", "aai-node-type", "service-subscription", "service-type", "servType02");
+ Vertex servsub3 = graph.addVertex(T.label, "service-subscription", T.id, "16", "aai-node-type", "service-subscription", "service-type", "servType03-wrong");
+
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "17", "aai-node-type", "customer", "global-customer-id", "custid01", "subscriber-name", "subscriberName01");
+ Vertex customer2 = graph.addVertex(T.label, "customer", T.id, "18", "aai-node-type", "customer", "global-customer-id", "custid02-wrong", "subscriber-name", "subscriberName-wrong");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, vserver1, pserver1); //true
+ rules.addEdge(g, vnf1, vserver1); //true
+ rules.addEdge(g, vnf1, servinst1); //true
+ rules.addTreeEdge(g, servinst1, servsub1); //true
+ rules.addTreeEdge(g, servsub1, customer1); //true
+
+ rules.addEdge(g, vserver2, pserver1); //true
+ rules.addEdge(g, vnf2, vserver2); //true
+ rules.addEdge(g, vnf2, servinst2); //true
+ rules.addEdge(g, vnf2, servinst3); //false
+ rules.addTreeEdge(g, servinst2, servsub2); //true
+ rules.addTreeEdge(g, servsub2, customer1); //true
+
+ rules.addEdge(g, vserver3, pserver2); //false
+ rules.addEdge(g, vnf3, vserver3); //false
+ rules.addEdge(g, vnf3, servinst3); //false
+ rules.addTreeEdge(g, servinst3, servsub3); //false
+ rules.addTreeEdge(g, servsub3, customer2); //false
+
+
+ expectedResult.add(servinst1);
+ expectedResult.add(servsub1);
+ expectedResult.add(servinst2);
+ expectedResult.add(servsub2);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "service-fromPserverandSubsName";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","pserver").has("hostname", "pservername01");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("subscriberName","subscriberName01");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java
new file mode 100644
index 0000000..17ddfc5
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java
@@ -0,0 +1,127 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.RawFormat;
+import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+
+import com.google.gson.JsonObject;
+
+public class SimpleFormatTest {
+
+ protected Graph graph;
+ private TransactionalGraphEngine dbEngine;
+
+ protected final List<Vertex> expectedResult = new ArrayList<>();
+ protected final EdgeRules rules = EdgeRules.getInstance();
+ protected Loader loader;
+ private DBSerializer serializer;
+
+ @Mock
+ private UrlBuilder urlBuilder;
+ private RawFormat _simpleFormat;
+
+ Vertex vfmodule = null;
+
+ public SimpleFormatTest() throws AAIException, NoEdgeRuleFoundException {
+ setUp();
+ }
+
+ public void setUp() throws AAIException, NoEdgeRuleFoundException {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ MockitoAnnotations.initMocks(this);
+ graph = TinkerGraph.open();
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
+ vfmodule = graph.addVertex(T.label, "vf-module",
+ T.id, "5",
+ "aai-node-type", "vf-module",
+ "vf-module-id", "vf-module-id-val-68205",
+ "vf-module-name", "example-vf-module-name-val-68205",
+ "heat-stack-id", "example-heat-stack-id-val-68205",
+ "orchestration-status", "example-orchestration-status-val-68205",
+ "is-base-vf-module", "true",
+ "resource-version", "1498166571906",
+ "model-invariant-id", "fe8aac07-ce6c-4f9f-aa0d-b561c77da9e8",
+ "model-invariant-id-local", "fe8aac07-ce6c-4f9f-aa0d-b561c77da9e8",
+ "model-version-id", "0d23052d-8ffe-433e-a25d-da5da027bb7c",
+ "model-version-id-local", "0d23052d-8ffe-433e-a25d-da5da027bb7c",
+ "widget-model-id", "example-widget-model-id-val-68205",
+ "widget-model-version", "example-widget--model-version-val-68205",
+ "contrail-service-instance-fqdn", "example-contrail-service-instance-fqdn-val-68205");
+
+ final ModelType factoryType = ModelType.MOXY;
+ Loader loader = LoaderFactory.createLoaderForVersion(factoryType, Version.v10);
+ dbEngine = spy(new TitanDBEngine(
+ QueryStyle.TRAVERSAL,
+ DBConnectionType.CACHED,
+ loader));
+
+ when(dbEngine.tx()).thenReturn(graph);
+ TransactionalGraphEngine.Admin spyAdmin = spy(dbEngine.asAdmin());
+ when(spyAdmin.getTraversalSource()).thenReturn(graph.traversal());
+ when(dbEngine.asAdmin()).thenReturn(spyAdmin);
+ serializer = new DBSerializer(Version.v10, dbEngine, factoryType, "Junit");
+ _simpleFormat = new RawFormat.Builder(loader, serializer, urlBuilder).modelDriven().build();
+ dbEngine.startTransaction();
+ }
+
+ @Test
+ public void run() throws AAIFormatVertexException {
+ assertNotNull(dbEngine.tx());
+ System.out.println(dbEngine.tx());
+ assertNotNull(graph.traversal());
+ JsonObject json = _simpleFormat.createPropertiesObject(vfmodule);
+ json.entrySet().stream().forEach((System.out::println));
+ assertTrue(json.has("model-invariant-id"));
+
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
new file mode 100644
index 0000000..a99fa8f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
@@ -0,0 +1,117 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/TopologyDetailsQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
new file mode 100644
index 0000000..1891914
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
@@ -0,0 +1,168 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java
new file mode 100644
index 0000000..8068c31
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java
@@ -0,0 +1,160 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologyFromCloudRegionIdAndServiceIdTest extends QueryTest {
+ public TopologyFromCloudRegionIdAndServiceIdTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "61", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
+ Vertex availibityzone1 = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1", "service-id", "service-id-1");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1", "vserver-selflink", "vserver-selflink-1");
+ Vertex flavor1 = graph.addVertex(T.label, "flavor", T.id, "8", "aai-node-type", "flavor", "flavor-id", "flavor-id-1", "flavor-name", "flavor-name-1", "flavor-selflink", "flavor-selflink-1");
+ Vertex image1 = graph.addVertex(T.label, "image", T.id, "9", "aai-node-type", "image", "image-id", "image-id-1", "image-name", "image-name-1", "image-os-distro", "image-os-distro-1", "image-os-version", "image-os-version-1");
+ Vertex volume1 = graph.addVertex(T.label, "volume", T.id, "10", "aai-node-type", "volume", "volume-id", "volume-id-1", "volume-selflink", "volume-selflink-1");
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc", T.id, "11", "aai-node-type", "vnfc", "vnfc-name", "vnfc-name-1", "nfc-naming-code", "nfc-naming-code-1");
+ Vertex snapshot1 = graph.addVertex(T.label, "snapshot", T.id, "12", "aai-node-type", "snapshot", "snapshot-id", "snapshot-id-1");
+ Vertex vfmodule1 = graph.addVertex(T.label, "vf-module", T.id, "13", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+ Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "14", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
+ Vertex logicallink1 = graph.addVertex(T.label, "logical-link", T.id, "15", "aai-node-type", "logical-link", "link-name", "link-name-1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-1");
+ Vertex subnet14 = graph.addVertex(T.label, "subnet", T.id, "17", "aai-node-type", "subnet", "subnet-id", "subnet-id-14");
+ Vertex l3network14 = graph.addVertex(T.label, "l3-network", T.id, "18", "aai-node-type", "l3-network", "network-id", "network-id-14", "network-name", "network-name-14");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "19", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-1");
+ Vertex subnet16 = graph.addVertex(T.label, "subnet", T.id, "20", "aai-node-type", "subnet", "subnet-id", "subnet-id-16");
+ Vertex l3network16 = graph.addVertex(T.label, "l3-network", T.id, "21", "aai-node-type", "l3-network", "network-id", "network-id-16", "network-name", "network-name16");
+
+ Vertex gnvf2 = graph.addVertex(T.label, "generic-vnf", T.id, "33", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name-2", "service-id", "service-id-wrong");
+ Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "36", "aai-node-type", "service-instance", "service-instance-id", "servInstId-2", "service-type", "servType-2", "service-role", "servRole-2");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "37", "aai-node-type", "vserver", "vserver-id", "vserver-id-2", "vserver-name", "vserver-name-2", "vserver-selflink", "vserver-selflink-2");
+ Vertex flavor2 = graph.addVertex(T.label, "flavor", T.id, "38", "aai-node-type", "flavor", "flavor-id", "flavor-id-2", "flavor-name", "flavor-name-2", "flavor-selflink", "flavor-selflink-2");
+ Vertex image2 = graph.addVertex(T.label, "image", T.id, "39", "aai-node-type", "image", "image-id", "image-id-2", "image-name", "image-name-2", "image-os-distro", "image-os-distro-2", "image-os-version", "image-os-version-2");
+ Vertex volume2 = graph.addVertex(T.label, "volume", T.id, "40", "aai-node-type", "volume", "volume-id", "volume-id-2", "volume-selflink", "volume-selflink-2");
+ Vertex vnfc2 = graph.addVertex(T.label, "vnfc", T.id, "41", "aai-node-type", "vnfc", "vnfc-name", "vnfc-name-2", "nfc-naming-code", "nfc-naming-code-2");
+ Vertex snapshot2 = graph.addVertex(T.label, "snapshot", T.id, "42", "aai-node-type", "snapshot", "snapshot-id", "snapshot-id-2");
+ Vertex vfmodule2 = graph.addVertex(T.label, "vf-module", T.id, "43", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-2", "vf-module-name", "vf-module-name2");
+ Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "44", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
+ Vertex logicallink2 = graph.addVertex(T.label, "logical-link", T.id, "45", "aai-node-type", "logical-link", "link-name", "link-name-2", "l-interface-name", "l-interface-name2");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "46", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-2");
+ Vertex subnet24 = graph.addVertex(T.label, "subnet", T.id, "47", "aai-node-type", "subnet", "subnet-id", "subnet-id-24");
+ Vertex l3network24 = graph.addVertex(T.label, "l3-network", T.id, "48", "aai-node-type", "l3-network", "network-id", "network-id-24", "network-name", "network-name-24");
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "49", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-2");
+ Vertex subnet26 = graph.addVertex(T.label, "subnet", T.id, "50", "aai-node-type", "subnet", "subnet-id", "subnet-id-26");
+ Vertex l3network26 = graph.addVertex(T.label, "l3-network", T.id, "51", "aai-node-type", "l3-network", "network-id", "network-id-26", "network-name", "network-name26");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, cloudregion1, availibityzone1);//true
+ rules.addEdge(g, availibityzone1, gnvf1);//true
+ rules.addEdge(g, gnvf1, serviceinstance1);//true
+ rules.addEdge(g, gnvf1, vserver1);//true
+
+ rules.addEdge(g, vserver1, flavor1);//true
+ rules.addEdge(g, vserver1, image1);//true
+ rules.addTreeEdge(g, vserver1, volume1);//true
+ rules.addEdge(g, vserver1, vnfc1);//true
+ rules.addEdge(g, vserver1, snapshot1);//true
+ rules.addEdge(g, vserver1, vfmodule1);//true
+ rules.addEdge(g, linter1, logicallink1);//true
+ rules.addTreeEdge(g, vserver1, linter1);//true
+ rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);//true
+ rules.addTreeEdge(g, linter1, l3inter1ipv6addresslist);//true
+ rules.addEdge(g, l3inter1ipv4addresslist, subnet14);//true
+ rules.addTreeEdge(g, subnet14, l3network14);//true
+ rules.addEdge(g, l3inter1ipv6addresslist, subnet16);//true
+ rules.addTreeEdge(g, subnet16, l3network16);//true
+
+ // false
+ rules.addEdge(g, availibityzone1, gnvf2);
+ rules.addEdge(g, gnvf2, serviceinstance2);
+ rules.addEdge(g, gnvf2, vserver2);
+ rules.addEdge(g, vserver2, flavor2);
+ rules.addEdge(g, vserver2, image2);
+ rules.addTreeEdge(g, vserver2, volume2);
+ rules.addEdge(g, vserver2, vnfc2);
+ rules.addEdge(g, vserver2, snapshot2);
+ rules.addEdge(g, vserver2, vfmodule2);
+ rules.addEdge(g, linter2, logicallink2);
+ rules.addTreeEdge(g, vserver2, linter2);
+ rules.addTreeEdge(g, linter2, l3inter1ipv4addresslist2);
+ rules.addTreeEdge(g, linter2, l3inter1ipv6addresslist2);
+ rules.addEdge(g, l3inter1ipv4addresslist2, subnet24);
+ rules.addTreeEdge(g, subnet24, l3network24);
+ rules.addEdge(g, l3inter1ipv6addresslist2, subnet26);
+ rules.addTreeEdge(g, subnet26, l3network26);
+
+
+ expectedResult.add(serviceinstance1);
+ expectedResult.add(vserver1);
+ expectedResult.add(flavor1);
+ expectedResult.add(image1);
+ expectedResult.add(volume1);
+ expectedResult.add(vnfc1);
+ expectedResult.add(snapshot1);
+ expectedResult.add(vfmodule1);
+ expectedResult.add(linter1);
+ expectedResult.add(logicallink1);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(subnet14);
+ expectedResult.add(l3network14);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(subnet16);
+ expectedResult.add(l3network16);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "topology-fromCloudRegionIdandServiceId";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","cloud-region").has("cloud-owner","cloud-owner-1").has("cloud-region-id","cloud-region-id-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("serviceId", "service-id-1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
new file mode 100644
index 0000000..b10abf3
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
@@ -0,0 +1,251 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.common.base.CaseFormat;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologyFromSubscriberNameAndServiceTypeTest extends QueryTest {
+ private static final EELFLogger LOGGER = EELFManager.getInstance()
+ .getLogger(TopologyFromSubscriberNameAndServiceTypeTest.class);
+
+ public TopologyFromSubscriberNameAndServiceTypeTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ // Set up the test graph
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "1", "aai-node-type", "customer",
+ "global-customer-id", "global-customer-id-1", "subscriber-name", "subscriber-name-1");
+ //Customer has 2 subscriptions - we filter by subscription-type
+ Vertex servicesubscription1 = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type",
+ "service-subscription", "service-type", "service-type-1");
+ Vertex servicesubscription112 = graph.addVertex(T.label, "service-subscription", T.id, "112", "aai-node-type",
+ "service-subscription", "service-type", "service-type-112");
+
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name",
+ "service-instance-name-1");
+ Vertex serviceinstance113 = graph.addVertex(T.label, "service-instance", T.id, "113", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id-113", "service-instance-name",
+ "service-instance-name-113");
+
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id",
+ "vnf-id-1", "vnf-name", "vnf-name-1", "service-id", "service-id-1");
+ Vertex gnvf114 = graph.addVertex(T.label, "generic-vnf", T.id, "114", "aai-node-type", "generic-vnf", "vnf-id",
+ "vnf-id-114", "vnf-name", "vnf-name-2", "service-id", "service-id-2");
+
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname",
+ "pservername1");
+ Vertex pserver115 = graph.addVertex(T.label, "pserver", T.id, "115", "aai-node-type", "pserver", "hostname",
+ "pservername115");
+
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex",
+ "physical-location-id", "physical-location-id-1", "country", "US");
+
+ Vertex pnfint1 = graph.addVertex(T.label, "p-interface", T.id, "7", "aai-node-type", "p-interface",
+ "interface-name", "ge0/0/0");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "8", "aai-node-type", "vserver", "vserver-id",
+ "vserver-id-1", "vserver-name", "vserver-name-1", "vserver-selflink", "vserver-selflink-1");
+
+ Vertex vserver116 = graph.addVertex(T.label, "vserver", T.id, "116", "aai-node-type", "vserver", "vserver-id",
+ "vserver-id-116", "vserver-name", "vserver-name-116", "vserver-selflink", "vserver-selflink-116");
+
+ Vertex flavor1 = graph.addVertex(T.label, "flavor", T.id, "9", "aai-node-type", "flavor", "flavor-id",
+ "flavor-id-1", "flavor-name", "flavor-name-1", "flavor-selflink", "flavor-selflink-1");
+ Vertex image1 = graph.addVertex(T.label, "image", T.id, "10", "aai-node-type", "image", "image-id",
+ "image-id-1", "image-name", "image-name-1", "image-os-distro", "image-os-distro-1", "image-os-version",
+ "image-os-version-1");
+
+ Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
+ "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
+ Vertex logicallink1 = graph.addVertex(T.label, "logical-link", T.id, "12", "aai-node-type", "logical-link",
+ "link-name", "link-name-1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "13",
+ "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address",
+ "l3-interface-ipv4-address-1");
+ Vertex subnet1 = graph.addVertex(T.label, "subnet", T.id, "14", "aai-node-type", "subnet", "subnet-id",
+ "subnet-id-1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "15", "aai-node-type", "l3-network",
+ "network-id", "network-id-1", "network-name", "network-name-1");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "16",
+ "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address",
+ "l3-interface-ipv6-address-1");
+ Vertex subnet2 = graph.addVertex(T.label, "subnet", T.id, "17", "aai-node-type", "subnet", "subnet-id",
+ "subnet-id-2");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "18", "aai-node-type", "l3-network",
+ "network-id", "network-id-2", "network-name", "network-name2");
+
+ Vertex customer2 = graph.addVertex(T.label, "customer", T.id, "19", "aai-node-type", "customer",
+ "global-customer-id", "global-customer-id-2", "subscriber-name", "subscriber-name-2");
+ Vertex servicesubscription2 = graph.addVertex(T.label, "service-subscription", T.id, "20", "aai-node-type",
+ "service-subscription", "service-type", "service-type-2");
+ Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "21", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name",
+ "service-instance-name-2");
+ Vertex gnvf2 = graph.addVertex(T.label, "generic-vnf", T.id, "22", "aai-node-type", "generic-vnf", "vnf-id",
+ "vnf-id-2", "vnf-name", "vnf-name-2", "service-id", "service-id-2");
+
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "23", "aai-node-type", "pserver", "hostname",
+ "pservername1");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "24", "aai-node-type", "complex",
+ "physical-location-id", "physical-location-id-2", "country", "US");
+ Vertex pnfint2 = graph.addVertex(T.label, "p-interface", T.id, "25", "aai-node-type", "p-interface",
+ "interface-name", "ge0/0/0");
+
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "251", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "26", "aai-node-type", "vserver", "vserver-id",
+ "vserver-id-2", "vserver-name", "vserver-name-2", "vserver-selflink", "vserver-selflink-2");
+ Vertex flavor2 = graph.addVertex(T.label, "flavor", T.id, "27", "aai-node-type", "flavor", "flavor-id",
+ "flavor-id-2", "flavor-name", "flavor-name-2", "flavor-selflink", "flavor-selflink-2");
+ Vertex image2 = graph.addVertex(T.label, "image", T.id, "28", "aai-node-type", "image", "image-id",
+ "image-id-2", "image-name", "image-name-2", "image-os-distro", "image-os-distro-2", "image-os-version",
+ "image-os-version-2");
+
+ Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "29", "aai-node-type", "l-interface",
+ "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
+ Vertex logicallink2 = graph.addVertex(T.label, "logical-link", T.id, "30", "aai-node-type", "logical-link",
+ "link-name", "link-name-2", "l-interface-name", "l-interface-name2");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "31",
+ "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address",
+ "l3-interface-ipv4-address-2");
+ Vertex subnet3 = graph.addVertex(T.label, "subnet", T.id, "32", "aai-node-type", "subnet", "subnet-id",
+ "subnet-id-3");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "33", "aai-node-type", "l3-network",
+ "network-id", "network-id-3", "network-name", "network-name-3");
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "34",
+ "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address",
+ "l3-interface-ipv6-address-2");
+ Vertex subnet4 = graph.addVertex(T.label, "subnet", T.id, "35", "aai-node-type", "subnet", "subnet-id",
+ "subnet-id-4");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "36", "aai-node-type", "l3-network",
+ "network-id", "network-id-4", "network-name", "network-name4");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, customer1, servicesubscription1);// true
+
+ rules.addTreeEdge(g, customer1, servicesubscription112);// true
+
+ rules.addTreeEdge(g, servicesubscription1, serviceinstance1);// true
+ rules.addTreeEdge(g, servicesubscription1, serviceinstance113);// true
+
+
+ rules.addEdge(g, serviceinstance1, gnvf1);// true
+ rules.addEdge(g, serviceinstance113, gnvf114);// true
+
+ rules.addEdge(g, gnvf1, vserver1);// true
+ rules.addEdge(g, gnvf114, vserver116);// true
+
+ rules.addEdge(g, gnvf1, pserver1);// true
+ rules.addEdge(g, gnvf114, pserver115);// true
+
+ rules.addEdge(g, pserver1, complex1);// true
+ rules.addTreeEdge(g, pserver1, pnfint1);
+ rules.addEdge(g, pnfint1, plink1);
+
+ rules.addEdge(g, vserver1, flavor1);// true
+ rules.addEdge(g, vserver1, image1);// true
+ rules.addEdge(g, vserver1, pserver1);// true
+ rules.addEdge(g, linter1, logicallink1);// true
+ rules.addTreeEdge(g, vserver1, linter1);// true
+ rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);// true
+ rules.addTreeEdge(g, linter1, l3inter1ipv6addresslist);// true
+ rules.addEdge(g, l3inter1ipv4addresslist, subnet1);// true
+ rules.addTreeEdge(g, subnet1, l3network1);// true
+ rules.addEdge(g, l3inter1ipv6addresslist, subnet2);// true
+ rules.addTreeEdge(g, subnet2, l3network2);// true
+ // false
+
+ rules.addTreeEdge(g, customer2, servicesubscription2);// true
+ rules.addTreeEdge(g, servicesubscription2, serviceinstance2);// true
+ rules.addEdge(g, serviceinstance2, gnvf2);// true
+ rules.addEdge(g, gnvf2, pserver2);// true
+ rules.addEdge(g, pserver2, complex2);// true
+ rules.addTreeEdge(g, pserver2, pnfint2);// true
+
+ rules.addEdge(g, gnvf2, vserver2);// true
+
+ rules.addEdge(g, vserver2, flavor2);// true
+ rules.addEdge(g, vserver2, image2);// true
+ rules.addEdge(g, linter2, logicallink2);// true
+ rules.addTreeEdge(g, vserver2, linter2);// true
+ rules.addTreeEdge(g, linter2, l3inter1ipv4addresslist2);// true
+ rules.addTreeEdge(g, linter2, l3inter1ipv6addresslist2);// true
+ rules.addEdge(g, l3inter1ipv4addresslist2, subnet3);// true
+ rules.addTreeEdge(g, subnet3, l3network3);// true
+ rules.addEdge(g, l3inter1ipv6addresslist2, subnet4);// true
+ rules.addTreeEdge(g, subnet4, l3network4);// true
+
+ expectedResult.add(complex1);
+ expectedResult.add(vserver1);
+ expectedResult.add(vserver116);
+ expectedResult.add(pserver1);
+ expectedResult.add(flavor1);
+ expectedResult.add(image1);
+ expectedResult.add(linter1);
+ expectedResult.add(logicallink1);
+ expectedResult.add(plink1);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(subnet1);
+ expectedResult.add(l3network1);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(subnet2);
+ expectedResult.add(l3network2);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "spaas-topology-fromServiceInstance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "customer").has("global-customer-id", "global-customer-id-1").out("subscribesTo").has("aai-node-type","service-subscription").has("service-type", "service-type-1").out("hasInstance").has("aai-node-type","service-instance");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ //params.put("serviceType", "service-type-1");
+ //params.put("subscriberName", "subscriber-name-1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java
new file mode 100644
index 0000000..ecf30b3
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java
@@ -0,0 +1,85 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfInstancesFromServiceInstancebyModelVersionTest extends QueryTest {
+ public VnfInstancesFromServiceInstancebyModelVersionTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
+
+ Vertex model1 = graph.addVertex(T.label, "model", T.id, "4", "aai-node-type", "model", "model-invariant-id", "modinvariant-id1", "model-type", "modtype");
+ Vertex modelver1 = graph.addVertex(T.label, "model-ver", T.id, "5", "aai-node-type", "model-ver", "model-version-id", "modver-id1", "model-name", "modname1", "model-version", "v1.0");
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "vnfname1", "vnf-type", "vnftype1", "model-invariant-id-local", "modinvariant-id1", "model-version-id-local", "modver-id1");
+
+// Vertex model2 = graph.addVertex(T.label, "model", T.id, "7", "aai-node-type", "model", "model-invariant-id", "modinvariant-id2", "model-type", "modtype");
+// Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "8", "aai-node-type", "model-ver", "model-version-id", "modver-id2", "model-name", "modname2", "model-version", "v1.0");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2", "vnf-name", "vnfname2", "vnf-type", "vnftype2", "model-invariant-id-local", "modinvariant-id1", "model-version-id-local", "modver-id1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, model1, modelver1);//true
+ rules.addEdge(g, vnf1, serviceinstance);//true
+ rules.addEdge(g, vnf2, serviceinstance);//false
+ rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
+ rules.addTreeEdge(g, servicesubscription, customer);//true
+
+ expectedResult.add(vnf1);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "vnf-instances-fromServiceInstancebyModelVersion";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("vnfType", "vnftype1");
+ params.put("modelVersionId", "modver-id1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java
new file mode 100644
index 0000000..b426ee1
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java
@@ -0,0 +1,128 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfTopologyFromServiceInstanceTest extends QueryTest {
+ public VnfTopologyFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
+ Vertex allottedresource = graph.addVertex(T.label, "allotted-resource", T.id, "4", "aai-node-type", "allotted-resource", "allotted-resource-id", "allotted-resource-id-1", "allotted-resource-name", "allotted-resource-name1");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "5", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+ Vertex volumegroup = graph.addVertex(T.label, "volume-group", T.id, "6", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-1", "volume-group-name", "volume-group-name1");
+ Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "7", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list-id", "l3-interface-ipv4-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-1", "l3-network-name", "l3-network-name1");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name1", "vservername1");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "12", "aai-node-type", "tenant", "tenant-name1", "tenant-name-1","tenant-id", "tenant-id-1");
+ Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "13", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
+ Vertex l3inter2ipv4addresslist = graph.addVertex(T.label, "interface-ipv6-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "17", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-2", "l3-network-name", "l3-network-name2");
+ Vertex l3inter2ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "18", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "19", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-3", "l3-network-name", "l3-network-name3");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "20", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-4", "l3-network-name", "l3-network-name4");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gnvf1, serviceinstance);//false
+ rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
+ rules.addTreeEdge(g, servicesubscription, customer);//true
+ rules.addTreeEdge(g, serviceinstance, allottedresource);//true
+ rules.addTreeEdge(g, gnvf1, vfmodule);//true
+ rules.addEdge(g, gnvf1, volumegroup);//false
+ rules.addTreeEdge(g, gnvf1, linter1);//true
+ rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);//true
+ rules.addEdge(g, l3inter1ipv4addresslist, l3network1);//false
+ rules.addTreeEdge(g, linter1, l3inter1ipv6addresslist);//true
+ rules.addEdge(g, l3inter1ipv6addresslist, l3network2);//false
+ rules.addEdge(g, gnvf1, vserver);//false
+ rules.addTreeEdge(g, vserver, tenant);//true
+ rules.addTreeEdge(g, tenant, region1);//true
+ rules.addEdge(g, vserver, pserver);//false
+ rules.addTreeEdge(g, vserver, linter2);//false
+ rules.addTreeEdge(g, linter2, l3inter2ipv4addresslist);//false
+ rules.addEdge(g, l3inter2ipv4addresslist, l3network3);//false
+ rules.addTreeEdge(g, linter2, l3inter2ipv6addresslist);//true
+ rules.addEdge(g, l3inter2ipv6addresslist, l3network4);//true
+
+
+ expectedResult.add(gnvf1);
+ expectedResult.add(serviceinstance);
+ expectedResult.add(customer);
+ expectedResult.add(allottedresource);
+ expectedResult.add(vfmodule);
+ expectedResult.add(volumegroup);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3network1);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(l3network2);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(region1);
+ expectedResult.add(pserver);
+ expectedResult.add(l3inter2ipv4addresslist);
+ expectedResult.add(l3network3);
+ expectedResult.add(l3inter2ipv6addresslist);
+ expectedResult.add(l3network4);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vnf-topology-fromServiceInstance";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("service-instance-name", "service-instance-name-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVfModuleTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVfModuleTest.java
new file mode 100644
index 0000000..7fbc175
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVfModuleTest.java
@@ -0,0 +1,134 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfTopologyFromVfModuleTest extends QueryTest {
+ public VnfTopologyFromVfModuleTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+
+
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
+ Vertex allottedresource = graph.addVertex(T.label, "allotted-resource", T.id, "4", "aai-node-type", "allotted-resource", "allotted-resource-id", "allotted-resource-id-1", "allotted-resource-name", "allotted-resource-name1");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "5", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+ Vertex volumegroup = graph.addVertex(T.label, "volume-group", T.id, "6", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-1", "volume-group-name", "volume-group-name1");
+ Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "7", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list-id", "l3-interface-ipv4-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-1", "l3-network-name", "l3-network-name1");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name1", "vservername1");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "12", "aai-node-type", "tenant", "tenant-name1", "tenant-name-1","tenant-id", "tenant-id-1");
+ Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "13", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
+ Vertex l3inter2ipv4addresslist = graph.addVertex(T.label, "interface-ipv6-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "17", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-2", "l3-network-name", "l3-network-name2");
+ Vertex l3inter2ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "18", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "19", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-3", "l3-network-name", "l3-network-name3");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "20", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-4", "l3-network-name", "l3-network-name4");
+ Vertex vfmoduleStart = graph.addVertex(T.label, "vf-module", T.id, "21", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-2", "vf-module-name", "vf-module-name2");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, gnvf1, vfmoduleStart);//true
+ rules.addEdge(g, gnvf1, serviceinstance);//false
+ rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
+ rules.addTreeEdge(g, servicesubscription, customer);//true
+ rules.addTreeEdge(g, serviceinstance, allottedresource);//true
+ rules.addTreeEdge(g, gnvf1, vfmodule);//true
+ rules.addEdge(g, gnvf1, volumegroup);//false
+ rules.addTreeEdge(g, gnvf1, linter1);//true
+ rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);//true
+ rules.addEdge(g, l3inter1ipv4addresslist, l3network1);//false
+ rules.addTreeEdge(g, linter1, l3inter1ipv6addresslist);//true
+ rules.addEdge(g, l3inter1ipv6addresslist, l3network2);//false
+ rules.addEdge(g, gnvf1, vserver);//false
+ rules.addTreeEdge(g, vserver, tenant);//true
+ rules.addTreeEdge(g, tenant, region1);//true
+ rules.addEdge(g, vserver, pserver);//false
+ rules.addTreeEdge(g, vserver, linter2);//false
+ rules.addTreeEdge(g, linter2, l3inter2ipv4addresslist);//false
+ rules.addEdge(g, l3inter2ipv4addresslist, l3network3);//false
+ rules.addTreeEdge(g, linter2, l3inter2ipv6addresslist);//true
+ rules.addEdge(g, l3inter2ipv6addresslist, l3network4);//true
+
+
+ expectedResult.add(gnvf1);
+ expectedResult.add(serviceinstance);
+ expectedResult.add(customer);
+ expectedResult.add(allottedresource);
+ expectedResult.add(vfmodule);
+ expectedResult.add(vfmoduleStart);
+ expectedResult.add(volumegroup);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3network1);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(l3network2);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(region1);
+ expectedResult.add(pserver);
+ expectedResult.add(l3inter2ipv4addresslist);
+ expectedResult.add(l3network3);
+ expectedResult.add(l3inter2ipv6addresslist);
+ expectedResult.add(l3network4);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vnf-topology-fromVfModule";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vf-module-name", "vf-module-name2");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java
new file mode 100644
index 0000000..af935f7
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java
@@ -0,0 +1,130 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfTopologyFromVnfTest extends QueryTest {
+ public VnfTopologyFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
+ Vertex allottedresource = graph.addVertex(T.label, "allotted-resource", T.id, "4", "aai-node-type", "allotted-resource", "allotted-resource-id", "allotted-resource-id-1", "allotted-resource-name", "allotted-resource-name1");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "5", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+ Vertex volumegroup = graph.addVertex(T.label, "volume-group", T.id, "6", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-1", "volume-group-name", "volume-group-name1");
+ Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "7", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list-id", "l3-interface-ipv4-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-1", "l3-network-name", "l3-network-name1");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name1", "vservername1");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "12", "aai-node-type", "tenant", "tenant-name1", "tenant-name-1","tenant-id", "tenant-id-1");
+ Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "13", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
+ Vertex l3inter2ipv4addresslist = graph.addVertex(T.label, "interface-ipv6-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "17", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-2", "l3-network-name", "l3-network-name2");
+ Vertex l3inter2ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "18", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "19", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-3", "l3-network-name", "l3-network-name3");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "20", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-4", "l3-network-name", "l3-network-name4");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gnvf1, serviceinstance);//false
+ rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
+ rules.addTreeEdge(g, servicesubscription, customer);//true
+ rules.addTreeEdge(g, serviceinstance, allottedresource);//true
+ rules.addTreeEdge(g, gnvf1, vfmodule);//true
+ rules.addEdge(g, gnvf1, volumegroup);//false
+ rules.addTreeEdge(g, gnvf1, linter1);//true
+ rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);//true
+ rules.addEdge(g, l3inter1ipv4addresslist, l3network1);//false
+ rules.addTreeEdge(g, linter1, l3inter1ipv6addresslist);//true
+ rules.addEdge(g, l3inter1ipv6addresslist, l3network2);//false
+ rules.addEdge(g, gnvf1, vserver);//false
+ rules.addTreeEdge(g, vserver, tenant);//true
+ rules.addTreeEdge(g, tenant, region1);//true
+ rules.addEdge(g, vserver, pserver);//false
+ rules.addTreeEdge(g, vserver, linter2);//false
+ rules.addTreeEdge(g, linter2, l3inter2ipv4addresslist);//false
+ rules.addEdge(g, l3inter2ipv4addresslist, l3network3);//false
+ rules.addTreeEdge(g, linter2, l3inter2ipv6addresslist);//true
+ rules.addEdge(g, l3inter2ipv6addresslist, l3network4);//true
+
+
+ expectedResult.add(gnvf1);
+ expectedResult.add(serviceinstance);
+ expectedResult.add(customer);
+ expectedResult.add(allottedresource);
+ expectedResult.add(vfmodule);
+ expectedResult.add(volumegroup);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3network1);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(l3network2);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(region1);
+ expectedResult.add(pserver);
+ expectedResult.add(vserver);
+ expectedResult.add(l3inter2ipv4addresslist);
+ expectedResult.add(l3network3);
+ expectedResult.add(l3inter2ipv6addresslist);
+ expectedResult.add(l3network4);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vnf-topology-fromVnf";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-name", "vnf-name-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromPserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromPserverQueryTest.java
new file mode 100644
index 0000000..a3f9c97
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromPserverQueryTest.java
@@ -0,0 +1,91 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfsFromPserverQueryTest extends QueryTest {
+ public VnfsFromPserverQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "sample");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername1");
+
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername2");
+
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "7", "aai-node-type", "tenant", "tenant-id", "tenantuuid", "tenant-name", "tenantname");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "8", "aai-node-type", "cloud-region", "cloud-region-id", "clouduuid", "cloud-region-owner", "cloudOwnername");
+
+ Vertex vnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnfid3", "vnf-name", "sample");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, pserver1, vnf1);
+ rules.addEdge(g, pserver1, vnf2);
+ rules.addEdge(g, pserver1, vnf3);
+
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addEdge(g, vserver, pserver3);
+ rules.addEdge(g, vserver, vnf2);
+
+ //expectedResult.add(vnf2);
+ expectedResult.add(vnf1);
+ //expectedResult.add(vnf3);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "vnfs-fromPserver";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ //g.has("vnf-id", "vnfid2");
+ g.has("aai-node-type","generic-vnf").has("vnf-id", "vnfid1").has("vnf-name", "sample");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("hostname", "pservername1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromServiceInstanceTest.java
new file mode 100644
index 0000000..6e4f923
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromServiceInstanceTest.java
@@ -0,0 +1,80 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfsFromServiceInstanceTest extends QueryTest {
+ public VnfsFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "vnfname1", "vnf-type", "vnftype1");
+ Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "5", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name", "service-instance-name-2");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2", "vnf-name", "vnfname2", "vnf-type", "vnftype1");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, vnf1, serviceinstance);//true
+ rules.addEdge(g, vnf2, serviceinstance2);
+
+ rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
+ rules.addTreeEdge(g, serviceinstance2, servicesubscription);
+ rules.addTreeEdge(g, servicesubscription, customer);//true
+
+ expectedResult.add(vnf1);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "vnfs-fromServiceInstance";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java
new file mode 100644
index 0000000..acec2e7
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java
@@ -0,0 +1,88 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class 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/onap/aai/rest/search/VserverLogicallinkFromPServerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLogicallinkFromPServerTest.java
new file mode 100644
index 0000000..8901de2
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLogicallinkFromPServerTest.java
@@ -0,0 +1,88 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VserverLogicallinkFromPServerTest extends QueryTest {
+
+ public VserverLogicallinkFromPServerTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "hostname-1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
+ Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "3", "aai-node-type", "l-interface", "interface-name", "interface-name-1");
+ Vertex logicalLink1 = graph.addVertex(T.label, "l", T.id, "4", "aai-node-type", "logical-link", "link-name", "link-name-1");
+
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "hostname-2");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver", "vserver-id", "vserver-id-2", "vserver-name", "vserver-name-2");
+ Vertex lInterface2 = graph.addVertex(T.label, "l-interface", T.id, "7", "aai-node-type", "l-interface", "interface-name", "interface-name-2");
+ Vertex logicalLink2 = graph.addVertex(T.label, "l", T.id, "8", "aai-node-type", "logical-link", "link-name", "link-name-2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver1, vserver1);
+ rules.addTreeEdge(g, vserver1, lInterface1);
+ rules.addEdge(g, lInterface1, logicalLink1);
+
+ rules.addEdge(g, pserver2, vserver2);
+ rules.addTreeEdge(g, vserver2, lInterface2);
+ rules.addEdge(g, lInterface2, logicalLink2);
+
+ expectedResult.add(vserver1);
+ expectedResult.add(logicalLink1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vserverlogicallink-frompServer";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "hostname-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
new file mode 100644
index 0000000..d06c8b7
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
@@ -0,0 +1,136 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.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/java/org/onap/aai/rest/util/LogFormatToolsTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java
new file mode 100644
index 0000000..c4cc211
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java
@@ -0,0 +1,36 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.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/onap/aai/rest/util/ValidateEncodingTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java
new file mode 100644
index 0000000..fa6480f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java
@@ -0,0 +1,102 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.util;
+
+import static org.junit.Assert.*;
+
+import java.io.UnsupportedEncodingException;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriInfo;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class ValidateEncodingTest {
+
+
+ @Test
+ public void badPath() throws UnsupportedEncodingException {
+ String badPath = "/aai/v6/network/vces/vce/blahh::blach/others/other/jklfea{}";
+ UriInfo mockUriInfo = getMockUriInfo(badPath, new MultivaluedHashMap<String, String>());
+ ValidateEncoding validator = ValidateEncoding.getInstance();
+
+ assertEquals(false, validator.validate(mockUriInfo));
+ }
+
+ @Test
+ public void goodPath() throws UnsupportedEncodingException {
+ String goodPath = "/aai/v6/network/vces/vce/blahh%3A%3Ablach/others/other/jklfea%7B%7D";
+ UriInfo mockUriInfo = getMockUriInfo(goodPath, new MultivaluedHashMap<String, String>());
+ ValidateEncoding validator = ValidateEncoding.getInstance();
+
+ assertEquals(true, validator.validate(mockUriInfo));
+ }
+
+ @Test
+ public void badQueryParamsKey() throws UnsupportedEncodingException {
+ MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
+ map.putSingle("blahblah", "test");
+ map.putSingle("blahblah", "test2");
+ map.putSingle("bad::bad", "test3");
+ UriInfo mockUriInfo = getMockUriInfo("", map);
+
+ ValidateEncoding validator = ValidateEncoding.getInstance();
+
+ assertEquals(false, validator.validate(mockUriInfo));
+
+ }
+ @Test
+ public void badQueryParamsValue() throws UnsupportedEncodingException {
+ MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
+ map.putSingle("blahblah", "test");
+ map.putSingle("blahblah", "test//:2");
+ map.putSingle("badbad", "test3");
+ UriInfo mockUriInfo = getMockUriInfo("", map);
+
+ ValidateEncoding validator = ValidateEncoding.getInstance();
+
+ assertEquals(false, validator.validate(mockUriInfo));
+ }
+ @Test
+ public void goodQueryParams() throws UnsupportedEncodingException {
+ MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
+ map.putSingle("blahblah", "test");
+ map.putSingle("blahblah", "test2");
+ map.putSingle("badbad", "~test%2F%2F%3A3");
+ UriInfo mockUriInfo = getMockUriInfo("", map);
+
+ ValidateEncoding validator = ValidateEncoding.getInstance();
+
+ assertEquals(true, validator.validate(mockUriInfo));
+ }
+
+ private UriInfo getMockUriInfo(String path, MultivaluedMap<String, String> map) {
+ UriInfo mockUriInfo = Mockito.mock(UriInfo.class);
+ Mockito.when(mockUriInfo.getPath(false)).thenReturn(path);
+ Mockito.when(mockUriInfo.getQueryParameters(false)).thenReturn(map);
+
+ return mockUriInfo;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java
new file mode 100644
index 0000000..3e323dd
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java
@@ -0,0 +1,111 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.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.onap.aai.ajsc_aai.JaxrsUserService;
+import org.onap.aai.introspection.Version;
+import org.onap.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/onap/aai/retiredcustomer/RetiredConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java
new file mode 100644
index 0000000..3810d44
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java
@@ -0,0 +1,129 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.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.onap.aai.introspection.Version;
+import org.onap.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/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java
new file mode 100644
index 0000000..e02cf38
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java
@@ -0,0 +1,34 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.retiredcustomer;
+
+import org.onap.aai.rest.retired.RetiredConsumer;
+import org.onap.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/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java
new file mode 100644
index 0000000..7c75e60
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java
@@ -0,0 +1,34 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.retiredcustomer;
+
+import org.onap.aai.rest.retired.RetiredConsumer;
+import org.onap.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/onap/aai/transforms/JoltTestUtil.java b/aai-traversal/src/test/java/org/onap/aai/transforms/JoltTestUtil.java
new file mode 100644
index 0000000..6a1966c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/transforms/JoltTestUtil.java
@@ -0,0 +1,62 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.transforms;
+
+
+import java.io.IOException;
+
+import org.junit.Assert;
+
+import com.bazaarvoice.jolt.ArrayOrderObliviousDiffy;
+import com.bazaarvoice.jolt.Diffy;
+import com.bazaarvoice.jolt.JsonUtils;
+
+public class JoltTestUtil {
+
+ private static final Diffy diffy = new Diffy();
+ private static final Diffy arrayOrderObliviousDiffy = new ArrayOrderObliviousDiffy();
+
+ public static void runDiffy( String failureMessage, Object expected, Object actual ) throws IOException {
+ runDiffy( diffy, failureMessage, expected, actual );
+ }
+
+ public static void runDiffy( Object expected, Object actual ) throws IOException {
+ runDiffy( diffy, "Failed", expected, actual );
+ }
+
+ public static void runArrayOrderObliviousDiffy( String failureMessage, Object expected, Object actual ) throws IOException {
+ runDiffy( arrayOrderObliviousDiffy, failureMessage, expected, actual );
+ }
+
+ public static void runArrayOrderObliviousDiffy( Object expected, Object actual ) throws IOException {
+ runDiffy( arrayOrderObliviousDiffy, "Failed", expected, actual );
+ }
+
+
+ private static void runDiffy( Diffy diffy, String failureMessage, Object expected, Object actual ) {
+ String actualObject = JsonUtils.toPrettyJsonString( actual );
+ Diffy.Result result = diffy.diff( expected, actual );
+ if (!result.isEmpty()) {
+ Assert.fail( "\nActual object\n" + actualObject + "\n" + failureMessage + "\nDiffy output\n" + result.toString());
+ }
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java b/aai-traversal/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java
new file mode 100644
index 0000000..8c8837c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java
@@ -0,0 +1,74 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.transforms;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.Assert.*;
+
+@RunWith(Parameterized.class)
+public class LowerHyphenToLowerCamelConverterTest {
+
+ private Converter converter = new LowerHyphenToLowerCamelConverter();
+
+ private String input;
+ private String expected;
+
+ public LowerHyphenToLowerCamelConverterTest(String input, String expected){
+ this.input = input;
+ this.expected = expected;
+ }
+
+ /**
+ * Data Provider for the Lower Hyphen to Camel Converter Tests
+ * Make sure the capitalization is not lost during the conversion
+ * @return
+ */
+ @Parameters
+ public static Collection<Object[]> data(){
+
+ return Arrays.asList(new Object[][]{
+ {null, null},
+ {"test-name", "testName"},
+ {"test---name", "testName"}, // Case multiple
+ {"testName", "testName"}, // Case where upper case word shouldn't be lowercased
+ {"test-name-cool", "testNameCool"},
+ {"test-name-Cool", "testNameCool"},
+ {"test-name-Cool-Name-wow----Rest", "testNameCoolNameWowRest"},
+ {"test-name#fast#", "testName#fast#"},
+ {"test-name---", "testName"},
+ {"----test-name", "TestName"},
+ });
+ }
+
+ @Test
+ public void testIfInputSuccessfullyModified(){
+ String actual = converter.convert(input);
+ assertEquals(expected, actual);
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/transforms/MapTraverserTest.java b/aai-traversal/src/test/java/org/onap/aai/transforms/MapTraverserTest.java
new file mode 100644
index 0000000..f26f719
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/transforms/MapTraverserTest.java
@@ -0,0 +1,57 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.transforms;
+
+import org.onap.aai.transforms.LowerCamelToLowerHyphenConverter;
+import org.onap.aai.transforms.MapTraverser;
+import com.bazaarvoice.jolt.JsonUtils;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class MapTraverserTest {
+
+ private final String testResources = "src/test/resources/maputils/testcases/";
+
+ private String[] testCases = { "TestCase1.json", "TestCase2.json" };
+ private MapTraverser traverser = new MapTraverser(new LowerCamelToLowerHyphenConverter());
+
+ @Test(expected = NullPointerException.class)
+ public void testIfMapIsNullThrowNullPointerException(){
+ Map<String, Object> map = null;
+ traverser.convertKeys(map);
+ }
+
+ @Test
+ public void runTestCases() throws IOException {
+
+ for(String testCase : testCases){
+ Map<String, Object> values = JsonUtils.filepathToMap(testResources + testCase);
+
+ Object input = values.get("input");
+ Object actual = traverser.convertKeys((Map<String, Object>)input);
+ Object output = values.get("output");
+ JoltTestUtil.runArrayOrderObliviousDiffy( "failed case " + testCase, output, actual );
+ }
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java
new file mode 100644
index 0000000..003c4e0
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java
@@ -0,0 +1,178 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.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.onap.aai.dbmap.AAIGraph;
+import org.onap.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();
+ }
+
+}