summaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2018-01-18 11:04:20 -0500
committerVenkata Harish K Kajur <vk250x@att.com>2018-02-15 11:43:25 -0500
commitf702ccd5b3f92fabfe21a1d3f3af762b6c628b88 (patch)
tree19204529e31d9393f5eb6e496a4ce2a6857d22ac /aai-traversal/src/test
parent0de265c8b69c955c296f368c2875e9845bb824e4 (diff)
Sync logging context changes
Issue-ID: AAI-493 Change-Id: I8c460cce840b4fe46ff4deacbe3a770755a4c677 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-traversal/src/test')
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java984
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java1279
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java61
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java13
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java315
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java234
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java124
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java77
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java85
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java115
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java82
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java80
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java138
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java8
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java52
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java105
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java8
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java81
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java111
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java67
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java3
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java156
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java1
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java24
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java94
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java149
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java85
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java80
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java86
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java87
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java11
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java9
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java122
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java2
-rw-r--r--aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties10
-rw-r--r--aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties60
-rw-r--r--aai-traversal/src/test/resources/logback.xml239
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/cloud-region-with-linterface.json57
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/custom-query.json4
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/gremlin-query.json4
48 files changed, 4459 insertions, 1129 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
index 624bf19..406d122 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
@@ -21,891 +21,522 @@
*/
package org.onap.aai.dbgraphgen;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Map.Entry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import com.bazaarvoice.jolt.modifier.DataType;
+import com.google.common.collect.Multimap;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.mockito.internal.exceptions.MockitoLimitations;
+import org.mockito.runners.MockitoJUnitRunner;
import org.onap.aai.db.DbMethHelper;
import org.onap.aai.db.props.AAIProperties;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.parsers.exceptions.AAIIdentityMapParseException;
+import org.onap.aai.query.builder.GraphTraversalBuilder;
+import org.onap.aai.query.builder.QueryBuilder;
+import org.onap.aai.query.builder.TraversalQuery;
+import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.db.EdgeType;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
+import java.util.*;
+@RunWith(MockitoJUnitRunner.class)
public class ModelBasedProcessingTest {
- private static final Version version = Version.getLatest();
- private static final ModelType introspectorFactoryType = ModelType.MOXY;
- private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private static final DBConnectionType type = DBConnectionType.REALTIME;
-
- private static final String TRANSACTION_ID = "transaction-1";
- private static final String FROM_APP_ID = "JUNIT";
- private static final String API_VERSION = "1.0";
- private static final String AAI_NODE_TYPE = "aai-node-type";
-
- private static final String MODEL_VESION_NODE_VALUE = "model-ver";
- private static final String MODEL_VERSION_ID_KEY = "model-version-id";
- private static final String MODEL_VERSION_ID_VALUE = "model-version-id-1";
-
- private static final String MODEL_INVARIANT_ID_NODE_VALUE = "model-invariant-id-local";
- private static final String MODEL_INVARIANT_ID_KEY = "model-invariant-id-local";
- private static final String MODEL_INVARIANT_ID_VALUE = "model-invariant-id-1";
-
- private static final String MODEL_NAME_NODE_VALUE = "model-name";
- private static final String MODEL_NAME_ID_KEY = "model-name";
- private static final String MODEL_NAME_ID_VALUE = "generic-vnf";
-
-
- private static TransactionalGraphEngine dbEngine;
- private static TransactionalGraphEngine.Admin admin;
- DBSerializer serializer;
+ @Mock private static TransactionalGraphEngine dbEngine;
private static Loader loader;
- EdgeRules rules;
-
- ModelBasedProcessing modelBasedProcessor;
-
- GraphTraversalSource source;
-
- Graph graph;
-
- Vertex model;
- Vertex modelVersion;
- Vertex modelElement;
- Vertex constrainedElementSet;
- Vertex namedQueryElement;
- Vertex linkagePoints;
- Vertex namedQuery;
-
+ @Mock private static DBSerializer serializer;
+ @Mock private static TransactionalGraphEngine.Admin admin;
+ ModelBasedProcessing mockProcessor;
+ @Mock
+ private DbMethHelper dbMethHelper;
+
@BeforeClass
public static void configure() throws Exception {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+
+
}
-
+
@Before
- public void init() throws AAIException {
+ public void init() {
+ mockProcessor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
MockitoAnnotations.initMocks(this);
- rules = EdgeRules.getInstance();
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, AAIProperties.LATEST);
- TransactionalGraphEngine newDbEngine = new TitanDBEngine(queryStyle, type, loader);
- dbEngine = Mockito.spy(newDbEngine);
- serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- admin = Mockito.spy(dbEngine.asAdmin());
- modelBasedProcessor = new ModelBasedProcessing(loader, dbEngine, serializer);
- graph = TinkerGraph.open();
- source = createGraph();
- }
-
- private GraphTraversalSource createGraph() throws AAIException {
- model = graph.addVertex(T.label, "model", T.id, "0", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "widget");
- modelVersion = graph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "1", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE, MODEL_VERSION_ID_KEY,
- MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- graph.addVertex(T.label, MODEL_INVARIANT_ID_NODE_VALUE, T.id, "2", MODEL_INVARIANT_ID_KEY, MODEL_INVARIANT_ID_VALUE, "model-version-id-local", MODEL_VERSION_ID_VALUE);
- namedQuery = graph.addVertex(T.label, "named-query", T.id, "3","aai-node-type", "named-query", "named-query-uuid", "named-query-uuid-1");
- graph.addVertex(T.label, MODEL_NAME_NODE_VALUE, T.id, "4", AAI_NODE_TYPE, MODEL_NAME_NODE_VALUE, MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE);
- modelElement = graph.addVertex(T.label, "model-element", T.id, "5", AAI_NODE_TYPE, "model-element");
- Vertex modelConstraint = graph.addVertex(T.label, "model-constraint", T.id, "6", AAI_NODE_TYPE, "model-constraint","constrained-element-set-uuid-2-replace","cesu2r-1");
- constrainedElementSet = graph.addVertex(T.label, "constrained-element-set", T.id, "7", AAI_NODE_TYPE, "constrained-element-set");
- Vertex elementChoiceSet = graph.addVertex(T.label, "element-choice-set", T.id, "8", AAI_NODE_TYPE, "element-choice-set");
- namedQueryElement = graph.addVertex(T.label, "named-query-element", T.id, "9","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- linkagePoints = graph.addVertex(T.label, "linkage-points", T.id, "10", AAI_NODE_TYPE, "linkage-points", "linkage-points", getArrayListAsString(),
- "new-data-del-flag", "F");
-
- GraphTraversalSource g = graph.traversal();
- rules.addTreeEdge(g, model, modelVersion);
- rules.addTreeEdge(g, modelElement, modelConstraint);
- rules.addTreeEdge(g, constrainedElementSet, modelConstraint);
- rules.addTreeEdge(g, modelVersion, modelElement);
- rules.addTreeEdge(g, modelElement, constrainedElementSet);
- rules.addTreeEdge(g, constrainedElementSet, elementChoiceSet);
- rules.addTreeEdge(g, modelElement, elementChoiceSet);
- rules.addTreeEdge(g, namedQuery, namedQueryElement);
- rules.addTreeEdge(g, namedQueryElement, namedQueryElement);
- rules.addEdge(g, modelVersion, modelElement);
- rules.addEdge(g, model, namedQueryElement);
- return g;
- }
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NullId_ExpectException() throws AAIException {
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelVerId = null;
- String passedModelInvId = null;
- String passedModelName = null;
- modelBasedProcessor.getStartNodesAndModVersionIds("9999","postmen",passedModelVerId,passedModelInvId,
- passedModelName,"generic-vnf",startNodeFilterArrayOfHashes,"");
- }
-
- @Test
- public void testGetStartNodesAndModVersionIds_ModelVersion() throws AAIException{
-
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelInvId = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, passedModelInvId, passedModelName,
- AAI_NODE_TYPE, startNodeFilterArrayOfHashes, API_VERSION);
- }
-
- @Test
- public void testGetStartNodesAndModVersionIds_ModelInId() throws AAIException {
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelVersion = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,MODEL_INVARIANT_ID_VALUE, passedModelName,
- AAI_NODE_TYPE, startNodeFilterArrayOfHashes, API_VERSION);
}
@Test
- public void testGetStartNodesAndModVersionIds_ModelName() throws AAIException {
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelVersion = null;
- String passedModelInvId = null;
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,passedModelInvId, MODEL_NAME_ID_VALUE,
- AAI_NODE_TYPE, startNodeFilterArrayOfHashes, API_VERSION);
+ public void testPropNameChange1() throws AAIUnknownObjectException {
+ String result;
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id");
+ assertEquals("result has -local tacked on the end as it should", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "vnf-id");
+ assertEquals("result does NOT have -local tacked on the end as it should", "vnf-id", result);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX);
+ assertEquals("property not modified because it already includes the right suffix", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
}
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_ModelVersion() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelInvId = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, passedModelInvId, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_ModelInvId() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelVersion = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,MODEL_INVARIANT_ID_VALUE, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_ModelName() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelVersion = null;
- String passedModelInvId = null;
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,passedModelInvId, MODEL_NAME_ID_VALUE,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testQueryByModel() throws AAIException {
+
+ @Mock
+ GraphTraversal<Vertex, Vertex> v;
+ @Mock
+ GraphTraversal<Vertex, Vertex> graphTraversal;
+ @Mock
+ GraphTraversalSource graphTraversalSource;
+ @Mock Iterable <?> uniqVerts;
+ List<Vertex> vertexList=new ArrayList<>();
+ @Mock Vertex vertex;
+ @Mock Vertex vertex1;
+ @Mock
+ QueryBuilder<Vertex> queryBuilder;
+
+ EdgeType treeType;
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIds() throws AAIException{
+
+ vertex.property("model-ver","model-version-id");
+ vertex1.property(AAIProperties.NODE_TYPE,"model-ver");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-ver","model-version-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
+
+ queryBuilder.toList().add(vertex);
+ Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder);
+
+ Introspector obj=loader.introspectorFromName("model-ver");
+
+ Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder);
+ //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1");
+
+
List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelInvId = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.queryByModel(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, passedModelInvId, passedModelName,
- AAI_NODE_TYPE, startNodeFilterArrayOfHashes, API_VERSION);
+
+ Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
+ "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
}
-
- @Test(expected=AAIException.class)
- public void testQueryByModel_Timed() throws AAIException {
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIds1() throws AAIException{
+
+ vertex.property("model-version-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"model-ver");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-version-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
+
+ queryBuilder.toList().add(vertex);
+ Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder);
+
+ Introspector obj=loader.introspectorFromName("generic-vnf");
+ Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder);
+ //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1");
+
+
List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- String passedModelVersion = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.queryByModel_Timed(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,MODEL_INVARIANT_ID_VALUE, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
- }
- @Test(expected=AAIException.class)
- public void testgetModelTypeFromModelVer_NullVertexArg() throws AAIException{
- Vertex nullVertex = null;
- modelBasedProcessor.getModelVerTopWidgetType(nullVertex, "");
- }
-
- @Test
- public void testValidateNamedQuery_FoundQuery() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- modelBasedProcessor.validateNamedQuery("9999", "JUNIT", "named-query-uuid-1", "1.0");
- }
-
- @Test(expected=AAIException.class)
- public void testValidateNamedQuery_NotFoundQuery() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- modelBasedProcessor.validateNamedQuery("9999", "JUNIT", "named-query-uuid", "1.0");
- }
-
- @Test(expected=AAIException.class)
- public void testGetNodeUsingUniqueId_NullUniqueId() throws AAIException{
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","");
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id",null);
- }
-
- @Test(expected=AAIException.class)
- public void testGetNodeUsingUniqueId_NullPropertyName() throws AAIException{
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","","vnf-id-1");
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","generic-vnf",null,"vnf-id-1");
- }
-
- @Test(expected=AAIException.class)
- public void testGetNodeUsingUniqueId_NullNodeType() throws AAIException{
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen","","vnf-id","vnf-id-1");
- modelBasedProcessor.getNodeUsingUniqueId("9999", "postmen",null,"vnf-id","vnf-id-1");
- }
-
- @Test(expected=AAIException.class)
- public void testValidateModel() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.validateModel("9999", "JUNIT", MODEL_VERSION_ID_VALUE, "1.0");
- }
-
- @Test
- public void testShowResultSet_NullVertex() {
- ResultSet rs = getResultSet();
- rs.setVert(null);
- modelBasedProcessor.showResultSet(rs, 1);
- }
-
- @Test
- public void testShowResultSet_NonEmptyOverrideHash() {
- ResultSet rs = getResultSet();
- modelBasedProcessor.showResultSet(rs, 2);
- }
-
- @Test
- public void testShowResultSet_EmptyOverrideHash() {
- ResultSet rs = getResultSet();
- rs.setPropertyOverRideHash(new HashMap<String, Object>());
- modelBasedProcessor.showResultSet(rs, 2);
- }
-
- private ResultSet getResultSet() {
- ResultSet rs = new ResultSet();
- rs.setVert(model);
- rs.setLocationInModelSubGraph("2");
- Map<String,Object> overrideHash = new HashMap<String, Object>();
- rs.setPropertyOverRideHash(overrideHash);
- overrideHash.put("key1", "value1");
- overrideHash.put("key2", "value2");
- overrideHash.put("key3", "value3");
- overrideHash.put("key4", "value4");
-
- Map<String,Object> extraHash = new HashMap<String, Object>();
- rs.setExtraPropertyHash(extraHash);
- extraHash.put("key1", "value1");
- extraHash.put("key2", "value2");
- extraHash.put("key3", "value3");
- extraHash.put("key4", "value4");
-
- return rs;
- }
-
- @Test
- public void testPruneResultSet_NotCutPointType() throws AAIException{
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- ResultSet rs = getResultSet();
- List<ResultSet> subResultSet = new ArrayList<>();
- subResultSet.add(getResultSet());
- rs.setSubResultSet(subResultSet);
- modelBasedProcessor.pruneResultSet(rs, "mdl", new HashMap<>());
- }
-
- @Test
- public void testPruneResultSet_CutPointType() throws AAIException{
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- ResultSet rs = getResultSet();
- Map<String, Object> startNodeFilterHash = new HashMap<>();
- startNodeFilterHash.put("model.model_type","widget");
- startNodeFilterHash.put("named_query.named-query-uuid","named-query-uuid-1");
- modelBasedProcessor.pruneResultSet(rs, "model", startNodeFilterHash);
- }
-
- @Test
- public void testCollapseForDoNotOutput_FlagTrue() throws AAIException{
-
- ResultSet rs = getResultSet();
- List<ResultSet> subResultSet = new ArrayList<>();
- subResultSet.add(getResultSet());
- rs.setSubResultSet(subResultSet);
- rs.setDoNotOutputFlag("true");
- modelBasedProcessor.collapseForDoNotOutput(rs);
- }
-
- @Test
- public void testCollapseForDoNotOutput_FlagFalse() throws AAIException{
-
- ResultSet rs = getResultSet();
- List<ResultSet> subResultSet = new ArrayList<>();
- subResultSet.add(getResultSet());
- rs.setSubResultSet(subResultSet);
- rs.setDoNotOutputFlag("false");
- modelBasedProcessor.collapseForDoNotOutput(rs);
- }
-
- @Test
- public void testMakeSureItsAnArrayList() {
- String listString = getArrayListAsString();
- modelBasedProcessor.makeSureItsAnArrayList(listString);
- }
-
- private String getArrayListAsString() {
- List<String> strList = new ArrayList<>();
- strList.add("1");
- strList.add("2");
- strList.add("3");
- String listString = strList.toString();
- return listString;
+ Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
+ "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
}
@Test
- public void testGetModConstraintHash() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getModConstraintHash(modelElement, new HashMap<>());
- }
-
- @Test(expected=AAIException.class)
- public void testGenTopoMap4ModelVer_WidgetType() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.genTopoMap4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelVersion, MODEL_VERSION_ID_VALUE);
- }
-
- @Test(expected=AAIException.class)
- public void testGenTopoMap4ModelVer_ServiceType() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "20", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "service");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "21", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "22", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.genTopoMap4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelVerV, MODEL_VERSION_ID_VALUE);
- }
-
- @Test(expected=AAIException.class)
- public void testCollectTopology4ModelVer() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- Multimap <String, String> initialEmptyMap = ArrayListMultimap.create();
- List<String> vidsTraversed = new ArrayList<>();
- modelBasedProcessor.collectTopology4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelElement, "", initialEmptyMap, vidsTraversed,
- 0, null, MODEL_INVARIANT_ID_VALUE, MODEL_VERSION_ID_VALUE);
- }
-
- @Test(expected=AAIException.class)
- public void testGetNextStepElementsFromSet_NullVertex() throws AAIException{
- modelBasedProcessor.getNextStepElementsFromSet(null);
- }
-
- @Test
- public void testRundeleteAsNeededFromResultSet() throws AAIException{
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- ResultSet rs = getResultSet();
- rs.setNewDataDelFlag("T");
- modelBasedProcessor.deleteAsNeededFromResultSet(TRANSACTION_ID, FROM_APP_ID, rs,
- "", API_VERSION, API_VERSION, new HashMap<>());
- }
-
- @Test(expected=AAIException.class)
- public void testQueryByNamedQuery() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.queryByNamedQuery(TRANSACTION_ID, FROM_APP_ID, "named-query-uuid-1", new ArrayList<>(), API_VERSION);
- }
-
- @Test
- public void testCollectInstanceData() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- Multimap <String, String> validNextStepMap = ArrayListMultimap.create();
- validNextStepMap.put("named-query-element-uuid-1", "named-query-element-uuid-1");
- List<String> vidsTraversed=new ArrayList<>();
- vidsTraversed.add("named-query-element-uuid-1");
- Map<String,String> namedQueryElementHash = new HashMap<>();
- namedQueryElementHash.put("named-query-element-uuid-1", "named-query-element-uuid-1");
- modelBasedProcessor.collectInstanceData(TRANSACTION_ID, FROM_APP_ID, modelElement, "named-query-element-uuid-1",
- validNextStepMap, vidsTraversed, 0, new HashMap<>(), namedQueryElementHash, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullNamedQueryVertex() throws AAIException {
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, null, model, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullInstanceVertex() throws AAIException {
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, model, null, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullContraintType() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "30","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "31", AAI_NODE_TYPE, "property-constraint");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "32", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullPropertyName() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "33","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "34", AAI_NODE_TYPE, "property-constraint", "constraint-type", "EQUALS");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "35", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testNamedQueryConstraintSaysStop_NullPropertyValue() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "36","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "37", AAI_NODE_TYPE, "property-constraint",
- "constraint-type", "EQUALS", "property-name", "property-name");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "38", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test
- public void testNamedQueryConstraintSaysStop_ConstraintTypeEquals() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "39","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "40", AAI_NODE_TYPE, "property-constraint",
- "constraint-type", "EQUALS", "property-name", "property-name", "property-value", "property-value");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "41", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test
- public void testNamedQueryConstraintSaysStop_ConstraintTypeNotEquals() throws AAIException {
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "42","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex propertyContraintV = graph.addVertex(T.label, "property-constraint", T.id, "43", AAI_NODE_TYPE, "property-constraint",
- "constraint-type", "NOT-EQUALS", "property-name", "property-name", "property-value", "property-value");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "44", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.namedQueryConstraintSaysStop(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test(expected=AAIException.class)
- public void testGetNamedQueryExtraDataLookup_TargetNodeTypeNull() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "45","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex relatedLookUpV = graph.addVertex(T.label, "related-lookup", T.id, "46", AAI_NODE_TYPE, "related-lookup",
- "source-node-property", "source-node-property", "source-node-type", "generic-vnf");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "47", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getNamedQueryExtraDataLookup(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test
- public void testGetNamedQueryExtraDataLookup_InvalidSourceProperty() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "51","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex relatedLookUpV = graph.addVertex(T.label, "related-lookup", T.id, "52", AAI_NODE_TYPE, "related-lookup",
- "source-node-property", "source-node-property", "source-node-type", "generic-vnf", "target-node-type", "generic-vnf",
- "target-node-property", "generic-vnf", "property-collect-list", "property-collect-list");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "53", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
- GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getNamedQueryExtraDataLookup(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testGetNamedQueryExtraDataLookup_ValidSourceProperty() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex namedQueryElementV = graph.addVertex(T.label, "named-query-element", T.id, "54","aai-node-type", "named-query-element",
- "property-limit-desc", "show-all", "do-not-output", "true", "named-query-element-uuid", "named-query-element-uuid-1",
- "property-collect-list", "property-collect-list-1");
- Vertex relatedLookUpV = graph.addVertex(T.label, "related-lookup", T.id, "55", AAI_NODE_TYPE, "related-lookup",
- "source-node-property", "source-node-property", "source-node-type", "generic-vnf", "target-node-type", "generic-vnf", "target-node-property", "generic-vnf");
- Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "56", AAI_NODE_TYPE, "instance-vertex", "source-node-property", "source-node-property");
- GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getNamedQueryExtraDataLookup(TRANSACTION_ID, FROM_APP_ID, namedQueryElementV, instanceVertexV, API_VERSION);
- }
-
- @Test
- public void testCollectNQElementHash() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.collectNQElementHash(TRANSACTION_ID, FROM_APP_ID, namedQueryElement, "", new HashMap<>(), new ArrayList<>(), 0);
+ public void getNodeUsingUniqueIdTest() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
}
-
+
@Test
- public void testCollectDeleteKeyHash() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.collectDeleteKeyHash(TRANSACTION_ID, FROM_APP_ID, linkagePoints, "", new HashMap<>(), new ArrayList<>(),
- 0, new HashMap<>(), "model-version-1", "model-version-id-local");
- }
-
- @Test(expected=AAIException.class)
- public void testCheck4EdgeRule_InvalidNodeA() throws AAIException {
- modelBasedProcessor.check4EdgeRule("model-version1", "model-ver");
+ public void getNodeUsingUniqueIdTest1() throws AAIException{
+ vertex.property("named-query-uui","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uui","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","named-query","named-query-uui","vnf-id-1");
+
+ assertNotNull(result);
}
- @Test(expected=AAIException.class)
- public void testCheck4EdgeRule_InvalidNodeB() throws AAIException {
- modelBasedProcessor.check4EdgeRule("model-ver", "model-version1");
+ @Test(expected = AAIException.class)
+ public void getModelVersUsingNameTest() throws AAIException{
+
+ vertex.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ vertex1.property("generic-vnf","generic-vnf");
+ graphTraversal.addV(vertex1);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-name","generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ //Mockito.when(vertexList.listIterator().hasNext()).thenReturn(true);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ List<Vertex> result=processor.getModelVersUsingName("9999","postment","generic-vnf");
+
+ assertTrue(result.size()>0);
}
-
- @Test(expected=AAIException.class)
- public void testCheck4EdgeRule_InvalidEdge() throws AAIException {
- modelBasedProcessor.check4EdgeRule("model-ver", "named-query");
+
+ //uniqueIdVal Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","");
+
+
}
-
- @Test
- public void testCollectTopology4LinkagePoint() throws AAIException {
- String linkagePointStrVal = new String("model-ver|model");
- String incomingTrail = new String("model|model-ver");
- Multimap <String, String> currentMap = ArrayListMultimap.create();
- modelBasedProcessor.collectTopology4LinkagePoint(TRANSACTION_ID, FROM_APP_ID, linkagePointStrVal, incomingTrail, currentMap);
+
+ //idPropertyName Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","","vnf-id-1");
+
+
}
-
- @Test
- public void testGenTopoMap4NamedQ() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.genTopoMap4NamedQ(TRANSACTION_ID, FROM_APP_ID, namedQuery, "named-query-uuid-1");
+
+ //idPropertyName Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull2() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","","vnf-id","vnf-id-1");
+
+
}
-
- @Test
- public void testGetModelThatNqElementRepresents() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getModelThatNqElementRepresents(namedQueryElement, "");
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestTwoVertex() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
}
-
- @Test
- public void testGetModelVerThatElementRepresents() throws AAIException{
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getModelVerThatElementRepresents(modelElement, "");
+
+ //uniqVerts Null Expection AAI Exception
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestVertexNull() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(null);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
}
-
- @Test
- public void testGetModelTypeFromModel() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getModelTypeFromModel(model, "");
+
+ //uniqVerts Null Expection AAI Exception
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestVertexHasNot() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ //vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
}
-
- @Test
- public void testGetModelVerTopWidgetType() throws AAIException {
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "57", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "service");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "58", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "59", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getModelVerTopWidgetType(modelVerV, "");
+
+ @Test(expected = AAIIdentityMapParseException.class)
+ public void runDeleteByModelTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Optional<Vertex> vertex=Optional.empty();
+ Map<String,Object> startNodeFilterHash=new HashMap<>();
+ startNodeFilterHash.put("related-link.data","relationshipdata");
+ startNodeFilterHash.put("generic-vnf.d","relationshipdata");
+ Mockito.when(dbMethHelper.searchVertexByIdentityMap("relationship-data",startNodeFilterHash)).thenReturn(vertex);
+ Map<String,String> re =processor.runDeleteByModel("9999","postmen","","relationship-data",startNodeFilterHash,"vnf-id","vnf-id");
+ assertNotNull(re);
+
+
}
-
- @Test
- public void testGetModelElementStepName() throws AAIException {
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "60", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "service");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "61", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "62", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.getModelElementStepName(modelElementV, "");
+
+ @Test(expected = AAIException.class)
+ public void getModelGivenModelVerTest() throws AAIException{
+ vertex.property("named-query-uuid","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uuid","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getModelGivenModelVer(vertex,"");
+ assertNotNull(result);
+
}
-
- @Test(expected=IllegalArgumentException.class)
- public void testRunDeleteByModel() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- Map<String, Object> map = new HashMap<>();
- map.put("generic-vnf.d","relationshipdata");
-
- modelBasedProcessor.runDeleteByModel(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, "model-ver", map, API_VERSION, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery_TimedTest() throws AAIException{
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uuid","named-query-element")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
+ Map<String,Object> secondaryFilterHash=new HashMap<>();
+
+ List<ResultSet> res=processor.queryByNamedQuery_Timed("99999","postmen","named-query-element",startNodeFilterArrayOfHashes,"vnf","vnf",
+ secondaryFilterHash);
+
+
}
-
- @Test
- public void testSecondConstructor() {
- ModelBasedProcessing mdp = new ModelBasedProcessing();
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4NamedQTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",vertex,"named-query-element");
}
-
- @Test(expected=AAIIdentityMapParseException.class)
- public void testQueryByNamedQuery_NonEmptyMap() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
-
- modelBasedProcessor.queryByNamedQuery(TRANSACTION_ID, FROM_APP_ID, "named-query-uuid-1", startNodeFilterArrayOfHashes, API_VERSION, null, null);
-
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4NamedQTest1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",null,"named-query-element");
}
-
- @Test(expected=AAIIdentityMapParseException.class)
- public void testRunDeleteByModel_Service() throws AAIException {
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "63", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "service");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "64", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "65", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
-
- Map<String, Object> map = new HashMap<>();
- map.put("generic-vnf.d","relationshipdata");
-
- modelBasedProcessor.runDeleteByModel(TRANSACTION_ID, FROM_APP_ID, MODEL_VERSION_ID_VALUE, "model-ver", map, API_VERSION, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void getModelThatNqElementRepresentsTest() throws AAIException{
+ vertex.property("model-ver","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex v=processor.getModelThatNqElementRepresents(vertex,"g");
}
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_AllEmpty() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelInvId = null;
- String passedModelName = null;
- String passedModelVerId = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID, passedModelVerId, passedModelInvId, passedModelName,
- "", startNodeFilterArrayOfHashes, API_VERSION);
+
+ @Test(expected = NullPointerException.class)
+ public void getModelTypeFromModel() throws AAIException{
+ Vertex vt=Mockito.mock(Vertex.class);
+ vt.property("model-type","named-query-element");
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ String v=processor.getModelTypeFromModel(vt,"g");
}
-
- @Test(expected=AAIException.class)
- public void testGetStartNodesAndModVersionIds_NonEmptyHashMap_ModelTypeNonNull() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelInvId = null;
- String passedModelName = null;
- String passedModelVerId = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.getStartNodesAndModVersionIds(TRANSACTION_ID, FROM_APP_ID, passedModelVerId, passedModelInvId, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void getModelTypeFromModel1() throws AAIException{
+ Vertex vt=Mockito.mock(Vertex.class);
+ vt.property("model-type","named-query-element");
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ String v=processor.getModelTypeFromModel(null,"g");
}
-
- @Test(expected=AAIException.class)
- public void testQueryByModel_Timed_NonEmptyHash() throws AAIException {
- Map<String, Object> map = new HashMap<>();
- map.put("model-ver.model-name", "model-name");
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<>();
- startNodeFilterArrayOfHashes.add(map);
- String passedModelVersion = null;
- String passedModelName = null;
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- modelBasedProcessor.queryByModel_Timed(TRANSACTION_ID, FROM_APP_ID,passedModelVersion,MODEL_INVARIANT_ID_VALUE, passedModelName,
- MODEL_NAME_ID_VALUE, startNodeFilterArrayOfHashes, API_VERSION);
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModelInvId() throws AAIException{
+
+ vertex.property(AAIProperties.NODE_TYPE,"model-invariant-id");
+ vertex1.property("model","model-invariant-id");
+ graphTraversal.addV(vertex1);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-invariant-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model","model-invariant-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Iterator<Vertex> result=processor.getModVersUsingModelInvId("9999","postment","model");
}
-
- @Test(expected=AAIException.class)
- public void testRunDeleteByModel_NullVersionAndNode() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- Map<String, Object> map = new HashMap<>();
- map.put("generic-vnf.d","relationshipdata");
-
- modelBasedProcessor.runDeleteByModel(TRANSACTION_ID, FROM_APP_ID, "", "", map, API_VERSION, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void getNamedQueryExtraDataLookupTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",null,vertex,
+ "");
}
-
- @Test(expected=AAIException.class)
- public void testRunDeleteByModel_NullVersion() throws AAIException {
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
- Map<String, Object> map = new HashMap<>();
- map.put("generic-vnf.d","relationshipdata");
-
- modelBasedProcessor.runDeleteByModel(TRANSACTION_ID, FROM_APP_ID, "", "model-ver", map, API_VERSION, API_VERSION);
+
+ @Test(expected = AAIException.class)
+ public void getNamedQueryExtraDataLookupTest1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",vertex,null,
+ "");
}
-
- @Test
- public void testGenTopoMap4ModelVer_WidgetType_Map() throws AAIException{
-
- Graph serviceGraph = TinkerGraph.open();
- Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "66", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "widget");
- Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "67", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
- MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- //Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "68", AAI_NODE_TYPE, "model-element");
- GraphTraversalSource gts = serviceGraph.traversal();
-
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- //rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- //rules4Service.addEdge(gts, modelElementV, modelVerV);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
-
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
- modelBasedProcessor.genTopoMap4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelVerV, MODEL_VERSION_ID_VALUE);
+
+ @Test(expected = NullPointerException.class)
+ public void showResultSet() throws AAIException{
+ vertex.property("model-ver","model-versionId");
+ vertex.property("aai","model-versionId");
+
+
+ ResultSet rs= Mockito.mock(ResultSet.class);
+ Mockito.when(rs.getVert()).thenReturn(vertex);
+
+ List<VertexProperty<String>> vb=new ArrayList<>();
+ VertexProperty<String> v=Mockito.mock(VertexProperty.class);
+ v.property("model-ver","1");
+ vb.add(v);
+ v.property("aai","5");
+ vb.add(v);
+ v.property("source-of-truth","6");
+ vb.add(v);
+
+ vertex.properties("model-ver","aai");
+ Mockito.when(vertex.<String>property(AAIProperties.NODE_TYPE)).thenReturn(v);
+ //Mockito.when(vertex.properties()).thenReturn(Mockito.any());
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ processor.showResultSet(rs,8);
+
}
-
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
new file mode 100644
index 0000000..f86010e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.dbgraphmap;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.onap.aai.exceptions.AAIException;
+
+@Ignore
+public class SearchGraphEdgeRuleTest {
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
+ @Test
+ public void getEdgeLabelTest() throws AAIException {
+ String[] label = SearchGraph.getEdgeLabel("customer", "service-subscription");
+
+ assertEquals("subscribesTo", label[0]);
+ }
+
+ @Test
+ public void getEdgeLabelThrowsExceptionWhenNoRuleExists() throws Exception {
+ String nodeTypeA = "complex";
+ String nodeTypeB = "service";
+ expectedEx.expect(AAIException.class);
+ expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: complex, service.");
+ SearchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
+ }
+
+ @Test
+ public void getEdgeLabelThrowsExceptionWhenNodeTypesDoNotExist() throws Exception {
+ String nodeTypeA = "A";
+ String nodeTypeB = "B";
+ expectedEx.expect(AAIException.class);
+ expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: A, B.");
+ SearchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java
index 6efb0d1..fcc1ee3 100644
--- a/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java
@@ -27,6 +27,7 @@ import org.mockito.Mockito;
import org.onap.aai.logging.LoggingContext;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -50,11 +51,11 @@ public class PostAaiAjscInterceptorTest {
public void testAllowOrRejectIfSuccess() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-
- LoggingContext.put(LoggingContext.LoggingField.RESPONSE_CODE.toString(), "SUCCESS");
+ HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
+ response.setStatus(200);
Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj"));
- boolean success = postAaiAjscInterceptor.allowOrReject(request, null, null);
+ boolean success = postAaiAjscInterceptor.allowOrReject(request, response, null);
assertTrue("Expecting the post interceptor to return success regardless", success);
}
@@ -63,11 +64,11 @@ public class PostAaiAjscInterceptorTest {
public void testAllowOrRejectIfFailure() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-
- LoggingContext.put(LoggingContext.LoggingField.RESPONSE_CODE.toString(), "ERR.");
+ HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
+ response.setStatus(400);
Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj"));
- boolean success = postAaiAjscInterceptor.allowOrReject(request, null, null);
+ boolean success = postAaiAjscInterceptor.allowOrReject(request, response, null);
assertTrue("Expecting the post interceptor to return success regardless", success);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
new file mode 100644
index 0000000..a351de0
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
@@ -0,0 +1,315 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.jayway.jsonpath.JsonPath;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.HttpTestUtil;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.introspection.Version;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.*;
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class GfpVserverDataStoredQueryTest {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(GfpVserverDataStoredQueryTest.class);
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private HttpHeaders httpHeaders;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private HttpTestUtil httpTestUtil;
+
+ private QueryConsumer queryConsumer;
+
+ private static final Version VERSION = Version.v11;
+ private static final String CLOUD_REGION_URI = "/aai/" + VERSION.toString()
+ + "/cloud-infrastructure/cloud-regions/"
+ + "cloud-region/testOwner1/testRegion1";
+
+ @Before
+ public void setup() throws Exception {
+ httpTestUtil = new HttpTestUtil();
+
+ Map<String, String> templateValues = new HashMap<>();
+
+ templateValues.put("cloud-owner", "testOwner1");
+ templateValues.put("cloud-region-id", "testRegion1");
+ templateValues.put("tenant-id", "testTenant1");
+ templateValues.put("tenant-name", "testTenantName1");
+ templateValues.put("vserver-id", "testVserver1");
+ templateValues.put("vserver-name", "junit-vservers");
+ templateValues.put("interface-name", "testlInterfaceName1");
+ templateValues.put("ipv4-address", "192.33.233.233");
+ templateValues.put("ipv6-address", "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
+ templateValues.put("vlan-interface", "vlan-interface1");
+
+ String cloudRegionPayload = PayloadUtil.
+ getTemplatePayload("cloud-region-with-linterface.json", templateValues);
+
+ Response response = httpTestUtil.doPut(CLOUD_REGION_URI, cloudRegionPayload);
+ logger.info("Response status received {}", response.getEntity());
+
+ assertNotNull("Expected the response to be not null", response);
+ assertEquals("Expecting the cloud region to be created", 201, response.getStatus());
+ logger.info("Successfully created the cloud region with linterface");
+
+ queryConsumer = new QueryConsumer();
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Ignore("This is more of a performance test to ensure no failure when too many starting vertexes")
+ @Test
+ public void testStoredQueryVerifyDoesNotThrowMethodTooLargeWhenLargeNumberOfStartingVertexes() throws Exception {
+
+ // Add hundred thousand vserver vertexes to properly
+ // test the scenario where the application was
+ // failing with method too large
+ addVservers(1000000);
+
+ Map<String, String> templateValues = new HashMap<>();
+
+ // Purposefully putting the filter to the testVserver1 as
+ // since this is a junit test other junit tests could put
+ // vserver and not properly clean up after the test
+ // so doing this to ensure that this is testing against the particular vserver
+ // as not to fail when another unit test decide to put vserver and not clean up
+ templateValues.put("start", "nodes/vservers?vserver-name=junit-vservers");
+ templateValues.put("query", "gfp-vserver-data");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
+ String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+
+ UriInfo uriInfo = Mockito.mock(UriInfo.class);
+ HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
+
+ queryParameters.add("format", "resource_and_url");
+ Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getPath()).thenReturn(query);
+
+ Response response = queryConsumer.executeQuery(
+ payload,
+ VERSION.toString(),
+ query,
+ "resource_and_url", "" +
+ "no_op",
+ httpHeaders,
+ uriInfo,
+ httpServletRequest
+ );
+
+ String entity = response.getEntity().toString();
+ assertEquals("Expected the response to be 200 but got this returned: " + response.getEntity().toString(),
+ 200, response.getStatus());
+ List<String> urls = JsonPath.read(entity, "$.results[*].url");
+ assertEquals("Expected the urls to be 3", 3, urls.size());
+ removeVertexes();
+ }
+
+ @Test
+ public void testStoredQueryWhenQueryDoesNotExistShouldReturnBadRequest() throws Exception {
+
+ Map<String, String> templateValues = new HashMap<>();
+
+ templateValues.put("start", "nodes/vservers");
+ templateValues.put("query", "fake-query");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
+ String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+
+ UriInfo uriInfo = Mockito.mock(UriInfo.class);
+ HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
+
+ queryParameters.add("format", "resource_and_url");
+ Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getPath()).thenReturn(query);
+
+ Response response = queryConsumer.executeQuery(
+ payload,
+ VERSION.toString(),
+ query,
+ "resource_and_url", "" +
+ "no_op",
+ httpHeaders,
+ uriInfo,
+ httpServletRequest
+ );
+
+ String entity = response.getEntity().toString();
+
+ assertEquals("Expected the response to be 400 but got this returned: " + entity,
+ 400, response.getStatus());
+
+ assertThat("Expecting error message since query doesn't exist", entity,
+ containsString("Query payload is invalid"));
+ }
+
+ @Test
+ public void testStoredQueryWhenStartFilterReturnsZeroVertexesItShouldHandleProperly() throws Exception {
+
+ Map<String, String> templateValues = new HashMap<>();
+
+ templateValues.put("start", "nodes/vservers?vserver-name=nonexistent-filter");
+ templateValues.put("query", "gfp-vserver-data");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
+ String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+
+ UriInfo uriInfo = Mockito.mock(UriInfo.class);
+ HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
+
+ queryParameters.add("format", "resource_and_url");
+ Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getPath()).thenReturn(query);
+
+ Response response = queryConsumer.executeQuery(
+ payload,
+ VERSION.toString(),
+ query,
+ "resource_and_url", "" +
+ "no_op",
+ httpHeaders,
+ uriInfo,
+ httpServletRequest
+ );
+
+ String entity = response.getEntity().toString();
+
+ assertEquals("Expected the response to be 500 but got this returned: " + entity,
+ 500, response.getStatus());
+
+ assertThat(entity, containsString("Internal Error:groovy.lang.MissingPropertyException"));
+ }
+
+ @After
+ public void tearDown(){
+ removeVertexes();
+ }
+
+ private void removeVertexes(){
+
+ TitanGraph titanGraph = AAIGraph.getInstance().getGraph();
+ TitanTransaction transaction = titanGraph.newTransaction();
+
+ boolean success = true;
+
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ g.V().has("source-of-truth", "JUNIT").toList().stream()
+ .forEach((vertex) -> vertex.remove());
+ } catch(Exception ex){
+ success = false;
+ logger.error("Unable to remove all of the junit vservers due to {}", ex);
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ }
+ }
+
+ }
+
+ private void addVservers(int vserversCount){
+
+ TitanGraph titanGraph = AAIGraph.getInstance().getGraph();
+ TitanTransaction transaction = titanGraph.newTransaction();
+
+ boolean success = true;
+
+ try {
+
+ GraphTraversalSource g = transaction.traversal();
+ for(int index = 0; index < vserversCount; index++){
+ String randomVserverId = UUID.randomUUID().toString();
+ g.addV().property("aai-node-type", "vserver")
+ .property( "vserver-id", "random-" + randomVserverId)
+ .property( "vserver-name", "junit-vservers")
+ .property( "source-of-truth", "JUNIT")
+ .next();
+ }
+
+ } catch(Exception ex){
+ success = false;
+ logger.error("Unable to add all of the vservers due to {}", ex);
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ }
+ }
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
new file mode 100644
index 0000000..d05702e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
@@ -0,0 +1,234 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.dsl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.onap.aai.exceptions.AAIException;
+
+/**
+ * The Class DslMain.
+ */
+public class DslQueryProcessorTest {
+
+
+ @Test
+ public void cloudRegion1Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String aaiQuery = "cloud-region* !('cloud-owner','coid')('cloud-region-id','crid') LIMIT 10";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".getVerticesByProperty('cloud-region-id','crid').store('x').cap('x').unfold().dedup().limit(10)";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_entitlementTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String aaiQuery = "generic-vnf (> vserver > tenant > cloud-region*('cloud-region-id','One')) > entitlement*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').where("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ + ".getVerticesByProperty('cloud-region-id','One').store('x'))"
+ + ".createEdgeTraversal(EdgeType.TREE, 'generic-vnf','entitlement').store('x').cap('x').unfold().dedup()";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void complex_az_fromComplexTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') > [ availability-zone* , complex*]";
+ String query = dslTest.parseAaiQuery(aaiQuery);
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ + ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
+ + ".union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'cloud-region','availability-zone').store('x')"
+ + ",builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','complex').store('x')).cap('x').unfold().dedup()";
+
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromComplex1Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('country','count-name')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x').cap('x').unfold().dedup()";
+ String aaiQuery = "complex('country','count-name') > cloud-region*";
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromComplex2Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('country','count-name')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').getVerticesByProperty('cloud-region-version','crv')"
+ + ".store('x').cap('x').unfold().dedup()";
+ String aaiQuery = "complex('country','count-name') > cloud-region*('cloud-region-version','crv')";
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromNfTypeTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'image').getVerticesByProperty('application-vendor','F5')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'image','vserver')"
+ + ".where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver','generic-vnf').getVerticesByProperty('vnf-name','ZALL1MMSC03'))"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ + ".store('x').cap('x').unfold().dedup()";
+ String aaiQuery = "image('application-vendor','F5') > vserver (>generic-vnf('vnf-name','ZALL1MMSC03')) > tenant > cloud-region*";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromNfTypeVendorVersionTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'image').getVerticesByProperty('application-vendor','vendor')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'image','vserver').where("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver','generic-vnf').getVerticesByProperty('nf-type','nfType')"
+ + ").createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "image('application-vendor','vendor') > vserver( >generic-vnf('nf-type', 'nfType') ) > tenant > cloud-region*";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloud_region_fromVnfTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vnfc','vserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').store('x')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region').store('x')"
+ + ".cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf('vnf-id','vnfId') > vnfc* > vserver* > tenant* > cloud-region*";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloud_region_sitesTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')."
+ + "getVerticesByProperty('cloud-owner','co').store('x').createEdgeTraversal(EdgeType.COUSIN, "
+ + "'cloud-region','complex').store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "cloud-region*('cloud-owner','co') > complex*";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void complex_fromVnf2Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-Id','vnfId').store('x').union("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ + ").cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-Id','vnfId') > " + "[ pserver* > complex*, "
+ + " vserver > pserver* > complex* " + "]";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void complex_fromVnfTest() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-Id','vnfId').store('x').union("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ + ").cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-Id','vnfId') > " + "[ pserver* > complex*, "
+ + " vserver > pserver* > complex* " + "]";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void fn_topology1Test() throws AAIException {
+ DslQueryProcessor dslTest = new DslQueryProcessor();
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'business')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'business','customer').getVerticesByProperty('customer-id','a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'customer','service-subscription').getVerticesByProperty('service-subscription-id','Nimbus')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'service-subscription','service-instance').getVerticesByProperty('service-instance-id','sid')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'service-instance','generic-vnf').store('x')"
+ + ".union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pnf').store('x')).cap('x').unfold().dedup()";
+
+ String aaiQuery = "business > customer('customer-id', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') > service-subscription('service-subscription-id', 'Nimbus') "
+ + " > service-instance('service-instance-id','sid') > generic-vnf* "
+ + " > [ vnfc* , vserver*, pserver* , pnf* ]";
+
+ String query = dslTest.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java
new file mode 100644
index 0000000..f6f2a63
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/AccessServiceFromServiceInstanceTest.java
@@ -0,0 +1,124 @@
+/**
+* ============LICENSE_START=======================================================
+* org.onap.aai
+* ================================================================================
+* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+*/
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class AccessServiceFromServiceInstanceTest extends QueryTest {
+
+ public AccessServiceFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-type", "service-subcription-1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "global-customer-id", "customer-id-1", "subscriber-name", "customer-name1", "subscriber-type", "customer-type1");
+ Vertex forwardingPath = graph.addVertex(T.label, "forwarding-path", T.id, "4", "aai-node-type", "forwarding-path", "forwarding-path-id", "forwarding-path-id-1", "forwarding-path-name", "forwarding-path-name-1");
+ Vertex configuration = graph.addVertex(T.label, "configuration", T.id, "5", "aai-node-type", "configuration", "configuration-id", "configuration-1", "configuration-type", "configuration-type-1", "configuration-sub-type", "configuration-sub-type-1");
+ Vertex evc = graph.addVertex(T.label, "evc", T.id, "6", "aai-node-type", "evc", "evc-id", "evc-1");
+ Vertex forwarder = graph.addVertex(T.label, "forwarder", T.id,"7", "aai-node-type", "forwarder", "sequence", "forwarder-1");
+ Vertex forwarderEvc = graph.addVertex(T.label, "forwarder-evc", T.id, "8", "aai-node-type", "forwarder-evc", "forwarder-evc-id", "forwarder-evc-1");
+ Vertex pInterface = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "p-interface-1");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "10", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex lagInterface = graph.addVertex(T.label, "lag-interface", T.id, "11", "aai-node-type", "lag-interface","interface-name", "lagint1");
+ Vertex logicalLink = graph.addVertex(T.label, "logical-link", T.id, "12", "aai-node-type", "logical-link", "link-name", "logical-link-1", "link-type", "LAG");
+ Vertex badLogicalLink = graph.addVertex(T.label, "logical-link", T.id, "13", "aai-node-type", "logical-link", "link-name", "logical-link-bad", "link-type", "BAD");
+ Vertex wrongInterfaceOne = graph.addVertex(T.label, "l-interface", T.id, "14", "aai-node-type", "l-interface", "interface-name", "wrong-interface-1");
+ Vertex wrongInterfaceTwo = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "interface-name", "wrong-interface-2");
+ Vertex wrongInterfaceThree = graph.addVertex(T.label, "l-interface", T.id, "16", "aai-node-type", "l-interface", "interface-name", "wrong-interface-3");
+ Vertex wrongInterfaceFour = graph.addVertex(T.label, "l-interface", T.id, "17", "aai-node-type", "l-interface", "interface-name", "wrong-interface-4");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, serviceInstance, serviceSubscription);
+ rules.addTreeEdge(g, serviceSubscription, customer);
+ rules.addEdge(g, serviceInstance,forwardingPath);
+ rules.addEdge(g, forwardingPath, configuration);
+ rules.addTreeEdge(g, configuration,evc);
+ rules.addTreeEdge(g, forwardingPath,forwarder);
+ rules.addEdge(g, forwarder, configuration);
+ rules.addTreeEdge(g, configuration,forwarderEvc);
+ rules.addEdge(g, forwarder, pInterface);
+ rules.addTreeEdge(g, pnf,pInterface);
+ rules.addEdge(g, forwarder, lagInterface);
+ rules.addTreeEdge(g, lagInterface,pnf);
+ rules.addEdge(g, logicalLink,lagInterface);
+
+ //incorrect nodes
+ rules.addEdge(g, badLogicalLink, lagInterface);
+ rules.addEdge(g, configuration, wrongInterfaceOne);
+ rules.addEdge(g, forwarder, wrongInterfaceTwo);
+ rules.addTreeEdge(g, pInterface, wrongInterfaceThree);
+ rules.addTreeEdge(g, lagInterface, wrongInterfaceFour);
+
+
+ expectedResult.add(serviceInstance);
+ expectedResult.add(serviceSubscription);
+ expectedResult.add(customer);
+ expectedResult.add(forwardingPath);
+ expectedResult.add(configuration);
+ expectedResult.add(evc);
+ expectedResult.add(forwarder);
+ expectedResult.add(forwarderEvc);
+ expectedResult.add(pInterface);
+ expectedResult.add(pnf);
+ expectedResult.add(lagInterface);
+ expectedResult.add(logicalLink);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "access-service-fromServiceInstance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "customer").has("global-customer-id", "customer-id-1").in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "service-subscription").has("service-type", "service-subcription-1").in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java
new file mode 100644
index 0000000..295194f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/AvailabilityZoneAndComplexfromCloudRegionQueryTest.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class AvailabilityZoneAndComplexfromCloudRegionQueryTest extends QueryTest {
+ public AvailabilityZoneAndComplexfromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
+ Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "2", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1","country","country1");
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
+ Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex", "physical-location-id", "physical-location-id-20","country","country20");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, cloudregion, availibityzone);
+ rules.addEdge(g, cloudregion,complex);
+
+ rules.addTreeEdge(g, cloudregion1, availibityzone1);
+ rules.addEdge(g, cloudregion1,complex1);
+
+ expectedResult.add(availibityzone);
+ expectedResult.add(complex);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "availabilityZoneAndComplex-fromCloudRegion";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","cloud-region").has("cloud-owner","cloud-owner-1").has("cloud-region-id","cloud-region-id-1");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java
new file mode 100644
index 0000000..59d2167
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionSitesQueryTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionSitesQueryTest extends QueryTest {
+
+ public CloudRegionSitesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region3 = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
+ Vertex region4 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner2");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "4", "aai-node-type", "complex");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex");
+ Vertex complex3 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, region1, complex1);
+ rules.addEdge(g, region2, complex1);
+ rules.addEdge(g, region3, complex2);
+ rules.addEdge(g, region4, complex3);
+
+ expectedResult.add(region1);
+ expectedResult.add(region2);
+ expectedResult.add(region3);
+ expectedResult.add(complex1);
+ expectedResult.add(complex2);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloud-region-sites";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "cloud-region");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("owner", "cloudOwner1");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java
new file mode 100644
index 0000000..9cffc37
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ColocatedDevicesQueryTest.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ColocatedDevicesQueryTest extends QueryTest {
+ public ColocatedDevicesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserverint1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "3", "aai-node-type", "pnf", "pnf-name", "pnfname1");
+ Vertex pnfint1 = graph.addVertex(T.label, "p-interface", T.id, "4", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "5", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex", "physical-location-id", "clli2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "xe0/0/1");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "9", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex pserverint3 = graph.addVertex(T.label, "p-interface", T.id, "10", "aai-node-type", "p-interface", "interface-name", "xe0/0/3");
+ Vertex plink2 = graph.addVertex(T.label, "physical-link", T.id, "11", "aai-node-type", "physical-link", "link-name", "xe0/0/1-to-xe0/0/3");
+
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "12", "aai-node-type", "pnf", "pnf-name", "pnfname2");
+ Vertex pnfint2 = graph.addVertex(T.label, "p-interface", T.id, "13", "aai-node-type", "p-interface", "interface-name", "ge0/0/2");
+ Vertex pnf3 = graph.addVertex(T.label, "pnf", T.id, "14", "aai-node-type", "pnf", "pnf-name", "pnfname3");
+ Vertex pnfint3 = graph.addVertex(T.label, "p-interface", T.id, "15", "aai-node-type", "p-interface", "interface-name", "ge0/0/3");
+ Vertex plink3 = graph.addVertex(T.label, "physical-link", T.id, "16", "aai-node-type", "physical-link", "link-name", "ge0/0/2-to-ge0/0/3");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver1, complex1);
+ rules.addTreeEdge(g, pserver1, pserverint1);
+ rules.addEdge(g, pnf1, complex1);
+ rules.addTreeEdge(g, pnf1, pnfint1);
+ rules.addEdge(g, pserverint1, plink1);
+ rules.addEdge(g, pnfint1, plink1);
+
+ rules.addEdge(g, pserver2, complex1);
+ rules.addTreeEdge(g, pserver2, pserverint2);
+ rules.addEdge(g, pserver3, complex2);
+ rules.addTreeEdge(g, pserver3, pserverint3);
+ rules.addEdge(g, pserverint2, plink2);
+ rules.addEdge(g, pserverint3, plink2);
+
+ rules.addEdge(g, pnf2, complex2);
+ rules.addTreeEdge(g, pnf2, pnfint2);
+ rules.addEdge(g, pnf3, complex2);
+ rules.addTreeEdge(g, pnf3, pnfint3);
+ rules.addEdge(g, pnfint2, plink3);
+ rules.addEdge(g, pnfint3, plink3);
+
+
+ expectedResult.add(pnf1);
+ expectedResult.add(pnfint1);
+ expectedResult.add(pserver1);
+ expectedResult.add(pserverint1);
+ expectedResult.add(plink1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserverint2);
+ expectedResult.add(plink2);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "colocated-devices";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java
new file mode 100644
index 0000000..e0ae06c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ComplexFromVnfTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ComplexFromVnfTest extends QueryTest {
+ public ComplexFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "1", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "hostname-1");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1", "country", "US");
+
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "hostname-2");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2", "country", "US");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, gnvf1, vserver1);
+ rules.addEdge(g, vserver1, pserver1);
+ rules.addEdge(g, pserver1, complex1);
+ rules.addEdge(g, gnvf1, pserver2);
+ rules.addEdge(g, pserver2, complex2);
+
+ expectedResult.add(gnvf1);
+ expectedResult.add(pserver1);
+ expectedResult.add(complex1);
+ expectedResult.add(pserver2);
+ expectedResult.add(complex2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "complex-fromVnf";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-name", "vnf-name-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java
new file mode 100644
index 0000000..523693e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CountVnfByVnfTypeTest.java
@@ -0,0 +1,80 @@
+/**
+* ============LICENSE_START=======================================================
+* org.onap.aai
+* ================================================================================
+* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+*/
+package org.onap.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CountVnfByVnfTypeTest extends QueryTest {
+
+ public CountVnfByVnfTypeTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run(true);
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex genericVnfTypeA1 = graph.addVertex(T.label, "genric-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1", "vnf-type", "A");
+ Vertex genericVnfTypeB1 = graph.addVertex(T.label, "genric-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name-2", "vnf-type", "B");
+ Vertex genericVnfTypeC1 = graph.addVertex(T.label, "genric-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-3", "vnf-name", "vnf-name-3", "vnf-type", "C");
+ Vertex genericVnfTypeA2 = graph.addVertex(T.label, "genric-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-4", "vnf-name", "vnf-name-4", "vnf-type", "A");
+ Vertex genericVnfTypeB2 = graph.addVertex(T.label, "genric-vnf", T.id, "5", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-5", "vnf-name", "vnf-name-5", "vnf-type", "B");
+ Vertex genericVnfTypeA3 = graph.addVertex(T.label, "genric-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-6", "vnf-name", "vnf-name-6", "vnf-type", "A");
+ Vertex genericVnfTypeA4 = graph.addVertex(T.label, "genric-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-7", "vnf-name", "vnf-name-7", "vnf-type", "A");
+
+ GraphTraversalSource g = graph.traversal();
+
+ expectedResultForMaps = expectedResultForMaps + "[A=4, B=2, C=1]";
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "count-vnf-byVnfType";
+ }
+
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ return;
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java
new file mode 100644
index 0000000..f3d374c
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GFPVnfDataTest.java
@@ -0,0 +1,138 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GFPVnfDataTest extends QueryTest {
+ public GFPVnfDataTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0","vnf-name", "vnf-name-1", "nf-type", "sample-nf-type");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "3", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-0");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "4", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-0");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "5", "aai-node-type", "vlan","vlan-interface", "vlan1");
+ Vertex vnfImage = graph.addVertex(T.label, "vnf-image", T.id, "6", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid");
+ Vertex networkProfile = graph.addVertex(T.label, "network-profile", T.id, "7","aai-node-type", "network-profile","nm-profile-name", "nm-profile-name-1");
+ Vertex lagint = graph.addVertex(T.label, "lag-interface", T.id, "8", "aai-node-type", "lag-interface","interface-name", "lagint1");
+
+ Vertex lagint0 = graph.addVertex(T.label, "lag-interface", T.id, "11", "aai-node-type", "lag-interface","interface-name", "lagint31");
+ Vertex linterface0 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id30", "l-interface-name", "l-interface-name30");
+ Vertex vlan0 = graph.addVertex(T.label, "vlan", T.id, "13", "aai-node-type", "vlan","vlan-interface", "vlan31");
+ Vertex l3inter1ipv4addresslist0 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "14", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-30");
+ Vertex l3inter1ipv6addresslist0 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "15", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-30");
+
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "10", "aai-node-type", "generic-vnf", "vnf-id", "vnfid10","vnf-name", "vnf-name-11", "nf-type", "sample-nf-type11");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "20", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id10", "l-interface-name", "l-interface-name10");
+ Vertex l3inter1ipv4addresslist1 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "30", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-10");
+ Vertex l3inter1ipv6addresslist1 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "40", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-10");
+ Vertex vlan1 = graph.addVertex(T.label, "vlan", T.id, "50", "aai-node-type", "vlan","vlan-interface", "vlan11");
+ Vertex vnfImage1 = graph.addVertex(T.label, "vnf-image", T.id, "60", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid11");
+ Vertex networkProfile1 = graph.addVertex(T.label, "network-profile", T.id, "70","aai-node-type", "network-profile","nm-profile-name", "nm-profile-name-11");
+ Vertex lagint1 = graph.addVertex(T.label, "lag-interface", T.id, "80", "aai-node-type", "lag-interface","interface-name", "lagint11");
+
+
+ Vertex lagint2 = graph.addVertex(T.label, "lag-interface", T.id, "21", "aai-node-type", "lag-interface","interface-name", "lagint312");
+ Vertex linterface2 = graph.addVertex(T.label, "l-interface", T.id, "22", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id30", "l-interface-name", "l-interface-name302");
+ Vertex vlan2 = graph.addVertex(T.label, "vlan", T.id, "23", "aai-node-type", "vlan","vlan-interface", "vlan312");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "24", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-302");
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "25", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-302");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, genericvnf, linterface);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addTreeEdge(g, linterface,vlan);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, vlan);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, vlan);
+
+ rules.addTreeEdge(g, genericvnf, lagint0);
+ rules.addTreeEdge(g, lagint0,linterface0);
+ rules.addTreeEdge(g, linterface0,vlan0);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist0, linterface0);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist0, linterface0);
+
+ rules.addEdge(g, genericvnf, vnfImage);
+ rules.addEdge(g, genericvnf, networkProfile);
+
+
+
+ //false
+ rules.addTreeEdge(g, genericvnf1, linterface1);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist1, linterface1);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist1, linterface1);
+ rules.addTreeEdge(g, linterface1,vlan1);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist1, vlan1);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist1, vlan1);
+
+ rules.addTreeEdge(g, genericvnf1, lagint2);
+ rules.addTreeEdge(g, linterface2,lagint2);
+ rules.addTreeEdge(g, linterface2,vlan2);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist2, linterface2);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist2, linterface2);
+
+ rules.addEdge(g, genericvnf1, vnfImage1);
+ rules.addEdge(g, genericvnf1, networkProfile1);
+
+
+ expectedResult.add(genericvnf);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(vlan);
+ expectedResult.add(linterface0);
+ expectedResult.add(vnfImage);
+ expectedResult.add(networkProfile);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "gfp-vnf-data";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-name", "vnf-name-1").has("vnf-id", "vnfid0");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
index 58c5876..9001f48 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java
@@ -2,6 +2,8 @@ package org.onap.aai.rest.search;
import static org.junit.Assert.*;
+import java.util.ArrayList;
+
import org.junit.Before;
import org.junit.Test;
@@ -43,7 +45,7 @@ public class GetCustomQueryConfigTest {
CustomQueryConfig cqc = getCustomQueryConfig.getStoredQuery("queryName2");
assertEquals(Lists.newArrayList("prop5"), cqc.getQueryOptionalProperties());
- assertEquals(null, cqc.getQueryRequiredProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryRequiredProperties());
assertEquals("out('bar').has('stuff','baz')", cqc.getQuery());
}
@@ -54,8 +56,8 @@ public class GetCustomQueryConfigTest {
GetCustomQueryConfig getCustomQueryConfig = new GetCustomQueryConfig(configJson);
CustomQueryConfig cqc = getCustomQueryConfig.getStoredQuery("queryName3");
- assertEquals(null, cqc.getQueryOptionalProperties());
- assertEquals(null, cqc.getQueryRequiredProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryOptionalProperties());
+ assertEquals(new ArrayList<String>(), cqc.getQueryRequiredProperties());
assertEquals("out('bar1').has('stuff','baz1')", cqc.getQuery());
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
new file mode 100644
index 0000000..2c67917
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
@@ -0,0 +1,84 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GfpVserverDataQueryTest extends QueryTest {
+ public GfpVserverDataQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0", "nf-type", "sample-nf-type");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "2", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "4", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "5", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-0");
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-0");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "9", "aai-node-type", "vlan", "vlan-interface", "vlan-interface0");
+ Vertex sriovVf = graph.addVertex(T.label, "sriov-vf", T.id, "10", "aai-node-type", "sriov-vf", "pci-id", "pci-id0");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addEdge(g, genericvnf, vserver);
+ rules.addTreeEdge(g, linterface, vserver);
+ rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addTreeEdge(g, vlan, linterface);
+ rules.addTreeEdge(g, sriovVf, linterface);
+
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3inter1ipv6addresslist);
+ expectedResult.add(vlan);
+ }
+ @Override
+ protected String getQueryName() {
+ return "gfp-vserver-data";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vserver");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
index 5c6a45f..1ef953a 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
@@ -135,7 +135,7 @@ public class GremlinServerImplTest {
loader);
GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
builder.queryFrom(URI.create("te"));
-builder.queryFrom("te");
+builder.queryFrom("te", "gremlin");
builder.create();
builder.processWith(QueryProcessorType.GREMLIN_SERVER);
builder.processWith(QueryProcessorType.LOCAL_GROOVY);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
index 3735e97..f1eacc6 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
@@ -135,7 +135,7 @@ public class GroovyShellImplTest {
loader);
GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
builder.queryFrom(URI.create("te"));
-builder.queryFrom("te");
+builder.queryFrom("te", "gremlin");
builder.create();
builder.processWith(QueryProcessorType.GREMLIN_SERVER);
builder.processWith(QueryProcessorType.LOCAL_GROOVY);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
index dcc3d32..e57c698 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
@@ -70,7 +70,7 @@ public class LinkedDevices_NewvceVserverTest extends QueryTest {
"interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region",
- "cloud-owner", "att", "cloud-region-id", "crId");
+ "cloud-owner", "onap", "cloud-region-id", "crId");
Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "60", "aai-node-type", "tenant",
"tenant-id", "tenId", "tenant-name", "verity");
Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "30", "aai-node-type", "vserver",
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
index ea5bc85..9ab7bc5 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
@@ -95,6 +95,8 @@ public class ModelAndNamedQueryRestProviderTest {
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
+ when(uriInfo.getPath()).thenReturn("JUNITURI");
+
headersMultiMap = new MultivaluedHashMap<>();
queryParameters = Mockito.spy(new MultivaluedHashMap<>());
@@ -143,7 +145,8 @@ public class ModelAndNamedQueryRestProviderTest {
Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
httpHeaders,
request,
- queryParameters
+ queryParameters,
+ uriInfo
);
assertNotNull(response);
@@ -164,13 +167,58 @@ public class ModelAndNamedQueryRestProviderTest {
Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
httpHeaders,
null,
- "cloud-region"
+ "cloud-region",
+ uriInfo
);
assertNotNull(response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
+ @Test
+ public void testNamedQueryCallTimeoutThrown() throws Exception {
+
+ String queryParameters = getPayload("payloads/named-queries/named-query.json");
+ HttpServletRequest request = mock(HttpServletRequest.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(request.getContentType()).thenReturn("application/json");
+
+ Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
+ httpHeaders,
+ request,
+ queryParameters,
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testNamedQueryCallTimeoutBypassed() throws Exception {
+
+ String queryParameters = getPayload("payloads/named-queries/named-query.json");
+ HttpServletRequest request = mock(HttpServletRequest.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(request.getContentType()).thenReturn("application/json");
+
+ Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
+ httpHeaders,
+ request,
+ queryParameters,
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ }
+
public String getPayload(String filename) throws IOException {
InputStream inputStream = getClass()
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java
new file mode 100644
index 0000000..226c9fc
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PnfTopologyQueryTest.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PnfTopologyQueryTest extends QueryTest {
+
+ public PnfTopologyQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "0", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "1", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pnf1int1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex pnf1int2 = graph.addVertex(T.label, "p-interface", T.id, "3", "aai-node-type", "p-interface", "interface-name", "ge0/0/1");
+ Vertex pnf1int3 = graph.addVertex(T.label, "p-interface", T.id, "4", "aai-node-type", "p-interface", "interface-name", "ge0/0/2");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "7", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "8", "aai-node-type", "pnf", "pnf-name", "pnf2name");
+ Vertex pnf2int = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "ge0/1/0");
+ Vertex plink2 = graph.addVertex(T.label, "physical-link", T.id, "10", "aai-node-type", "physical-link", "link-name", "ge0/0/1-to-ge0/1/0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "xe0/0/1");
+ Vertex pnf2int2 = graph.addVertex(T.label, "p-interface", T.id, "13", "aai-node-type", "p-interface", "interface-name", "ge0/1/0");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pnf1, complex);
+ rules.addTreeEdge(g, pnf1, pnf1int1);
+ rules.addTreeEdge(g, pnf1, pnf1int2);
+ rules.addTreeEdge(g, pnf1, pnf1int3);
+ rules.addEdge(g, pserver, complex);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addEdge(g, pnf1int1, plink1);
+ rules.addEdge(g, pserverint, plink1);
+ rules.addEdge(g, pnf2, complex);
+ rules.addTreeEdge(g, pnf2, pnf2int);
+ rules.addEdge(g, pnf1int2, plink2);
+ rules.addEdge(g, pnf2int, plink2);
+ rules.addEdge(g, vserver, pserver);
+ rules.addTreeEdge(g, pserver, pserverint2);
+ rules.addTreeEdge(g, pnf2, pnf2int2);
+
+ expectedResult.add(pnf1);
+ expectedResult.add(complex);
+ expectedResult.add(pnf1int1);
+ expectedResult.add(pnf1int2);
+ expectedResult.add(pserver);
+ expectedResult.add(pserverint);
+ expectedResult.add(plink1);
+ expectedResult.add(pnf2);
+ expectedResult.add(pnf2int);
+ expectedResult.add(plink2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ // TODO Auto-generated method stub
+ return "pnf-topology";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("pnf-name", "pnf1name");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
index 9a427ca..d445a51 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
@@ -53,6 +53,8 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
"link-type", "link-type1");
Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored", "true",
"in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
// Following are extra nodes that should not be picked up in
// expectedResults
@@ -71,10 +73,10 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
rules.addEdge(g, lint2, loglink1);
rules.addEdge(g, loglink1, pserver1);
rules.addEdge(g, loglink1, gvnf1);
+ rules.addEdge(g, gvnf1, pnf1);
// These should not be picked up in expectedResults
//rules.addEdge(g, config2, loglink2);
- rules.addEdge(g, lint2, loglink2);
rules.addEdge(g, loglink2, pserver2);
rules.addEdge(g, loglink2, gvnf2);
@@ -84,6 +86,7 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
expectedResult.add(lint1);
expectedResult.add(pserver1);
expectedResult.add(gvnf1);
+ expectedResult.add(pnf1);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
index 9638cfd..d4fe7d9 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
@@ -53,6 +53,8 @@ public class PserverfromConfigurationTest extends QueryTest {
"link-type", "link-type1");
Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored", "true",
"in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
// Following are extra nodes that should not be picked up in
// expectedResults
@@ -63,6 +65,8 @@ public class PserverfromConfigurationTest extends QueryTest {
"link-type", "link-type2");
Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "16", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored",
"true", "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id2");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "18", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor2", "equip-model",
+ "equip-model2");
GraphTraversalSource g = graph.traversal();
rules.addEdge(g, config1, loglink1);
@@ -70,18 +74,20 @@ public class PserverfromConfigurationTest extends QueryTest {
rules.addEdge(g, lint2, loglink1);
rules.addEdge(g, loglink1, pserver1);
rules.addEdge(g, loglink1, gvnf1);
+ rules.addEdge(g, gvnf1, pnf1);
// These should not be picked up in expectedResults
rules.addEdge(g, config2, loglink2);
- rules.addEdge(g, lint2, loglink2);
rules.addEdge(g, loglink2, pserver2);
rules.addEdge(g, loglink2, gvnf2);
+ rules.addEdge(g, gvnf2, pnf2);
expectedResult.add(config1);
expectedResult.add(lint1);
expectedResult.add(lint2);
expectedResult.add(pserver1);
expectedResult.add(gvnf1);
+ expectedResult.add(pnf1);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java
new file mode 100644
index 0000000..64971d6
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversWithNoComplexTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserversWithNoComplexTest extends QueryTest {
+
+ public PserversWithNoComplexTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername2");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex pserver4 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername4");
+ Vertex pserver5 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername5");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex",
+ "physical-location-id", "physical-location-id-1", "country", "US");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "7", "aai-node-type", "complex",
+ "physical-location-id", "physical-location-id-2", "country", "USA");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver4,complex1);
+ rules.addEdge(g, pserver5,complex2);
+
+ expectedResult.add(pserver1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserver3);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pservers-withNoComplex";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ return;
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java
new file mode 100644
index 0000000..c9a83e7
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelByRegionTest.java
@@ -0,0 +1,111 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class QueryPnfFromModelByRegionTest extends QueryTest {
+ public QueryPnfFromModelByRegionTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //serviceInstance 1,2,3 are good and 4 is bad based upon the filters
+ Vertex serviceInst1 = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance1", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst2 = graph.addVertex(T.label, "service-instance", T.id, "2", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance2", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst3 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance3", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex serviceInst4 = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance4", "model-invariant-id", "miid2", "model-version-id", "mvid2");
+
+ //pnf 1,2 & 3 are good based upon the filters
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "5", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "6", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf3 = graph.addVertex(T.label, "pnf", T.id, "7", "aai-node-type", "pnf", "pnf-name", "pnf3name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+ Vertex pnf4 = graph.addVertex(T.label, "pnf", T.id, "12", "aai-node-type", "pnf", "pnf-name", "pnf4name", "equip-vendor", "equip-vendor4",
+ "equip-model", "equip-model4");
+
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "9", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
+
+ //cr 1 is good based upon the filter
+ Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region1");
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "11", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region2");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, serviceInst1, pnf1);
+ rules.addEdge(g, serviceInst2, pnf2);
+ rules.addEdge(g, serviceInst3, pnf3);
+ rules.addEdge(g, serviceInst4, pnf4);
+
+ rules.addEdge(g, pnf1, complex1);
+ rules.addEdge(g, pnf2, complex1);
+ rules.addEdge(g, pnf3, complex2);
+ rules.addEdge(g, pnf4, complex2);
+
+ rules.addEdge(g, cloudRegion1, complex1);
+ rules.addEdge(g, cloudRegion2, complex2);
+
+
+ expectedResult.add(pnf1);
+ expectedResult.add(pnf2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pnf-fromModel-byRegion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("model-invariant-id", "miid1").has("model-version-id", "mvid1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionId", "cloud-region1");
+ params.put("equipVendor", "equip-vendor1");
+ params.put("equipModel", "equip-model1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
index a7c8470..ae54449 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
@@ -21,15 +21,21 @@
*/
package org.onap.aai.rest.search;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -48,18 +54,23 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
public abstract class QueryTest {
-
+
+ private EELFLogger logger;
protected Graph graph;
private GremlinServerSingleton gremlinServerSingleton;
private GremlinGroovyShellSingleton shell;
@Mock private TransactionalGraphEngine dbEngine;
protected final List<Vertex> expectedResult = new ArrayList<>();
+ //expectedResultForMaps is for when the query returns a HashMap, not a Vertex
+ protected String expectedResultForMaps = new String();
protected final EdgeRules rules = EdgeRules.getInstance();
protected Loader loader;
public QueryTest() throws AAIException, NoEdgeRuleFoundException {
setUp();
+ logger = EELFManager.getInstance().getLogger(getClass());
}
+
public void setUp() throws AAIException, NoEdgeRuleFoundException {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
@@ -72,23 +83,61 @@ public abstract class QueryTest {
}
public void run() {
+ this.run(false);
+ }
+
+ public void run(boolean isHashMap) {
String query = gremlinServerSingleton.getStoredQueryFromConfig(getQueryName());
Map<String, Object> params = new HashMap<>();
addParam(params);
when(dbEngine.getQueryBuilder(any(QueryStyle.class))).thenReturn(new GremlinTraversal<>(loader, graph.traversal()));
+ logger.info("Stored query in abstraction form {}", query);
query = GroovyQueryBuilderSingleton.getInstance().executeTraversal(dbEngine, query, params);
+ logger.info("After converting to gremlin query {}", query);
query = "g" + query;
GraphTraversal<Vertex, Vertex> g = graph.traversal().V();
addStartNode(g);
params.put("g", g);
- GraphTraversal<Vertex, Vertex> result = (GraphTraversal<Vertex, Vertex>)shell.executeTraversal(query, params);
- List<Vertex> vertices = result.toList();
- assertTrue("all vertices found", vertices.containsAll(expectedResult) && expectedResult.containsAll(vertices));
+ //Certain custom queries return HashMaps instead of Vertex; different code must used for both cases to avoid a ClassCastException
+ if(!isHashMap) {
+ GraphTraversal<Vertex, Vertex> result = (GraphTraversal<Vertex, Vertex>)shell.executeTraversal(query, params);
+
+ List<Vertex> vertices = result.toList();
+
+ logger.info("Expected result set of vertexes [{}]", convert(expectedResult));
+ logger.info("Actual Result set of vertexes [{}]", convert(vertices));
+ List<Vertex> nonDuplicateExpectedResult = new ArrayList<>(new HashSet<>(expectedResult));
+ vertices = new ArrayList<>(new HashSet<>(vertices));
+
+ nonDuplicateExpectedResult.sort(Comparator.comparing(vertex -> vertex.id().toString()));
+ vertices.sort(Comparator.comparing(vertex -> vertex.id().toString()));
+
+ // Use this instead of the assertTrue as this provides more useful
+ // debugging information such as this when expected and actual differ:
+ // java.lang.AssertionError: Expected all the vertices to be found
+ // Expected :[v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]]
+ // Actual :[v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]]
+ assertEquals("Expected all the vertices to be found", nonDuplicateExpectedResult, vertices);
+ }
+ else {
+ GraphTraversal<HashMap<String,Long>, HashMap<String,Long>> result = (GraphTraversal<HashMap<String,Long>, HashMap<String,Long>>)shell.executeTraversal(query, params);
+
+ String map = result.toList().toString();
+ System.out.println(map);
+ assertTrue("all hash maps found", map.equals(expectedResultForMaps) && expectedResultForMaps.equals(map));
+ }
}
-
+
+ private String convert(List<Vertex> vertices){
+ return vertices
+ .stream()
+ .map(vertex -> vertex.property("aai-node-type").value().toString())
+ .collect(Collectors.joining(","));
+ }
+
protected abstract void createGraph() throws AAIException, NoEdgeRuleFoundException;
protected abstract String getQueryName();
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
index 67f7d11..6d6cf10 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java
@@ -80,10 +80,7 @@ public class QueryVnfFromModelByRegionTest extends QueryTest {
rules.addEdge(g, genericVnf3, vserver3);
rules.addTreeEdge(g, tenant1, vserver3);
- rules.addEdge(g, serviceInst1, genericVnf3);
-
expectedResult.add(genericVnf1);
- expectedResult.add(genericVnf3);
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
index 8633cb4..bb04653 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
@@ -91,6 +91,8 @@ public class SearchProviderTest {
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
+ when(uriInfo.getPath()).thenReturn("JUNITURI");
+
headersMultiMap = new MultivaluedHashMap<>();
queryParameters = Mockito.spy(new MultivaluedHashMap<>());
@@ -146,7 +148,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -158,7 +161,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- "latest"
+ "latest",
+ uriInfo
);
assertNotNull(response);
@@ -188,7 +192,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -196,6 +201,73 @@ public class SearchProviderTest {
}
@Test
+ public void testNodesQueryTimeoutThrown() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getNodesQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("7406"));
+ }
+
+ @Test
+ public void testNodesQueryTimeoutBypassed() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getNodesQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("4009"));
+ }
+
+
+ @Test
public void testGenericQueryInvalidData() throws Exception {
List<String> keys = new ArrayList<>();
@@ -214,7 +286,8 @@ public class SearchProviderTest {
keys,
includeStrings,
0,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
@@ -226,7 +299,8 @@ public class SearchProviderTest {
"cloud-region",
keys,
includeStrings,
- "latest"
+ "latest",
+ uriInfo
);
assertNotNull(response);
@@ -257,11 +331,81 @@ public class SearchProviderTest {
keys,
includeStrings,
0,
- version.toString()
+ version.toString(),
+ uriInfo
);
assertNotNull(response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
+ @Test
+ public void testGenericQueryTimeoutThrown() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP1");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getGenericQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ 0,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("7406"));
+ }
+
+ @Test
+ public void testGenericQueryBypassTimeout() throws Exception {
+
+ List<String> keys = new ArrayList<>();
+ keys.add("cloud-region.cloud-owner:test-aic");
+
+ List<String> includeStrings = new ArrayList<>();
+ includeStrings.add("cloud-region");
+
+ httpHeaders = mock(HttpHeaders.class);
+
+ headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+
+ Response response = searchProvider.getGenericQueryResponse(
+ httpHeaders,
+ null,
+ "cloud-region",
+ keys,
+ includeStrings,
+ 0,
+ version.toString(),
+ uriInfo
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(true, response.getEntity().toString().contains("4009"));
+ }
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
index 3be5b34..26b34a4 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java
@@ -78,7 +78,6 @@ public class ServiceFromPserverAndSubsNameTest extends QueryTest {
rules.addEdge(g, vserver2, pserver1); //true
rules.addEdge(g, vnf2, vserver2); //true
rules.addEdge(g, vnf2, servinst2); //true
- rules.addEdge(g, vnf2, servinst3); //false
rules.addTreeEdge(g, servinst2, servsub2); //true
rules.addTreeEdge(g, servsub2, customer1); //true
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
index abf9139..93a8195 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
@@ -47,16 +47,24 @@ public class ServiceModelsByDistributionStatusTest extends QueryTest {
Vertex modelver11 = graph.addVertex(T.label, "model-ver", T.id, "21", "aai-node-type", "model-ver", "model-version-id", "model-version-id-11","model-name","model-name11", "model-version","model-version-1", "distribution-status", "distribution-status2");
Vertex model2 = graph.addVertex(T.label, "model", T.id, "3", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-2", "model-type", "resource");
- Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver", "model-version-id", "model-version-id-2","model-name","model-name2", "model-version","model-version-1", "distribution-status", "distribution-status2");
- GraphTraversalSource g = graph.traversal();
+ Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver", "model-version-id", "model-version-id-2","model-name","model-name2", "model-version","model-version-22", "distribution-status", "distribution-status2");
+
+ Vertex model3 = graph.addVertex(T.label, "model", T.id, "5", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-3", "model-type", "service");
+ Vertex modelver3 = graph.addVertex(T.label, "model-ver", T.id, "6", "aai-node-type", "model-ver", "model-version-id", "model-version-id-13","model-name","model-name3", "model-version","model-version-3", "distribution-status", "distribution-status1");
+ Vertex modelver13 = graph.addVertex(T.label, "model-ver", T.id, "7", "aai-node-type", "model-ver", "model-version-id", "model-version-id-33","model-name","model-name33", "model-version","model-version-33", "distribution-status", "distribution-status2");
+
+ GraphTraversalSource g = graph.traversal();
- rules.addTreeEdge(g, modelver1, model1);
- rules.addTreeEdge(g, modelver11, model1);
- rules.addTreeEdge(g, modelver2, model1);
+ rules.addTreeEdge(g, modelver2,model2);
+
+ rules.addTreeEdge(g, modelver3, model3);
+ rules.addTreeEdge(g, modelver13, model3);
+ rules.addTreeEdge(g, modelver11, model3);
- expectedResult.add(model1);
+ expectedResult.add(model3);
+ expectedResult.add(modelver13);
expectedResult.add(modelver11);
- expectedResult.add(modelver2);
+
}
@Override
@@ -65,7 +73,7 @@ public class ServiceModelsByDistributionStatusTest extends QueryTest {
}
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1");
+ g.has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-3");
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java
new file mode 100644
index 0000000..55510fa
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceSitesQueryTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ServiceSitesQueryTest extends QueryTest {
+
+ public ServiceSitesQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "0", "aai-node-type", "customer", "global-customer-id", "customer1");
+ Vertex customer2 = graph.addVertex(T.label, "customer", T.id, "1", "aai-node-type", "customer", "global-customer-id", "customer2");
+ Vertex service1 = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-type", "service1");
+ Vertex service2 = graph.addVertex(T.label, "service-subscription", T.id, "3", "aai-node-type", "service-subscription", "service-type", "service2");
+ Vertex instance = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance");
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "5", "aai-node-type", "generic-vnf");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "9", "aai-node-type", "tenant");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, customer1, service1);
+ rules.addTreeEdge(g, customer1, service2);
+ rules.addTreeEdge(g, service1, instance);
+ rules.addEdge(g, vnf, instance);
+ rules.addEdge(g, vnf, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, region);
+ rules.addEdge(g, region, complex);
+ rules.addEdge(g, vserver, pserver);
+ rules.addEdge(g, pserver, complex);
+
+ expectedResult.add(instance);
+ expectedResult.add(vnf);
+ expectedResult.add(region);
+ expectedResult.add(complex);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "service-sites";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "customer");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("customerId", "customer1");
+ params.put("type", "service1");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java
new file mode 100644
index 0000000..92d925b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceTopologyTest.java
@@ -0,0 +1,149 @@
+package org.onap.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class ServiceTopologyTest extends QueryTest {
+ public ServiceTopologyTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex servinst = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "servInstId01", "service-type", "servType01");
+ Vertex gv = graph.addVertex(T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "name", "vnf-type", "type");
+ Vertex vnfc = graph.addVertex(T.id, "3", "aai-node-type", "vnfc","vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
+
+ Vertex vipipv4addresslist1 = graph.addVertex(T.label, "vip-ipv4-address-list", T.id, "4", "aai-node-type", "vip-ipv4-address-list", "vip-ipv4-addres", "vip-ipv4-address1");
+ Vertex subnet1 = graph.addVertex(T.label, "subnet", T.id, "5", "aai-node-type", "subnet", "subnet-id", "subnet1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network", "network-id", "network1-id1", "network-name", "network1-name1");
+
+ Vertex vipipv6addresslist1 = graph.addVertex(T.label, "vip-ipv6-address-list", T.id, "7", "aai-node-type", "vip-ipv6-address-list", "vip-ipv6-address", "vip-ipv6-address2");
+ Vertex subnet2 = graph.addVertex(T.label, "subnet", T.id, "8", "aai-node-type", "subnet", "subnet-id", "subnet2");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "network-id", "network1-id2", "network-name", "network2-name2");
+
+ Vertex l3inter1ipv4addresslist1 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address1");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "11", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name3");
+ Vertex subnet3 = graph.addVertex(T.label, "subnet", T.id, "12", "aai-node-type", "subnet", "subnet-id", "subnet3");
+ Vertex l3network3_2 = graph.addVertex(T.label, "l3-network", T.id, "13", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network3_2-name3_2");
+
+ Vertex l3inter1ipv6addresslist1 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "14", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address1");
+ Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "15", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name4");
+ Vertex subnet4 = graph.addVertex(T.label, "subnet", T.id, "16", "aai-node-type", "subnet", "subnet-id", "subnet4");
+ Vertex l3network4_2 = graph.addVertex(T.label, "l3-network", T.id, "17", "aai-node-type", "l3-network", "network-id", "network3-id4", "network-name", "network4_2-name4_2");
+
+
+ Vertex vserv1 = graph.addVertex(T.id, "18", "aai-node-type", "vserver", "vserver-id", "vservId1", "vserver-name", "vservName1");
+ Vertex tenant1 = graph.addVertex(T.id, "19", "aai-node-type", "tenant", "tenant-id", "ten1", "tenant-name", "tenName1");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "20", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id1", "l-interface-name", "l-interface-name1");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "21", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address2");
+ Vertex l3network5 = graph.addVertex(T.label, "l3-network", T.id, "22", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name3");
+ Vertex subnet5 = graph.addVertex(T.label, "subnet", T.id, "23", "aai-node-type", "subnet", "subnet-id", "subnet3");
+ Vertex l3network5_2 = graph.addVertex(T.label, "l3-network", T.id, "24", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network3_2-name3_2");
+
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "25", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address1");
+ Vertex l3network6 = graph.addVertex(T.label, "l3-network", T.id, "26", "aai-node-type", "l3-network", "network-id", "network3-id3", "network-name", "network2-name4");
+ Vertex subnet6 = graph.addVertex(T.label, "subnet", T.id, "27", "aai-node-type", "subnet", "subnet-id", "subnet4");
+ Vertex l3network6_2 = graph.addVertex(T.label, "l3-network", T.id, "28", "aai-node-type", "l3-network", "network-id", "network3-id4", "network-name", "network4_2-name4_2");
+
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "29", "aai-node-type", "pserver", "hostname", "pservername1");
+
+
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "30", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "31", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "32", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, servinst , gv);
+ rules.addEdge(g,gv,vnfc);
+ rules.addEdge(g,vnfc,vipipv4addresslist1);
+ rules.addEdge(g,vipipv4addresslist1,subnet1);
+ rules.addTreeEdge(g,subnet1,l3network1);
+ rules.addEdge(g,vnfc,vipipv6addresslist1);
+ rules.addEdge(g,vipipv6addresslist1,subnet2);
+ rules.addTreeEdge(g,subnet2,l3network2);
+ rules.addTreeEdge(g,vnfc,l3inter1ipv4addresslist1);
+ rules.addEdge(g,l3inter1ipv4addresslist1,l3network3);
+ rules.addEdge(g,l3inter1ipv4addresslist1,subnet3);
+ rules.addTreeEdge(g,subnet3,l3network3_2);
+ rules.addTreeEdge(g,vnfc,l3inter1ipv6addresslist1);
+ rules.addEdge(g,l3inter1ipv6addresslist1,l3network4);
+ rules.addEdge(g,l3inter1ipv6addresslist1,subnet4);
+ rules.addTreeEdge(g,subnet4,l3network4_2);
+ rules.addEdge(g,gv,vserv1);
+ rules.addTreeEdge(g,vserv1,tenant1);
+ rules.addTreeEdge(g,vserv1,linterface1);
+ rules.addTreeEdge(g,linterface1,l3inter1ipv4addresslist2);
+ rules.addEdge(g,l3inter1ipv4addresslist2,l3network5);
+ rules.addEdge(g,l3inter1ipv4addresslist2,subnet5);
+ rules.addTreeEdge(g,subnet5,l3network5_2);
+ rules.addTreeEdge(g,linterface1,l3inter1ipv6addresslist2);
+ rules.addEdge(g,l3inter1ipv6addresslist2,l3network6);
+ rules.addEdge(g,l3inter1ipv6addresslist2,subnet6);
+ rules.addTreeEdge(g,subnet6,l3network6_2);
+ rules.addEdge(g,vserv1,pserver1);
+ rules.addEdge(g,gv,pserver2);
+ rules.addTreeEdge(g,pserver2,pserverint);
+ rules.addEdge(g,pserverint,plink1);
+
+ expectedResult.add(servinst);
+ expectedResult.add(gv);
+ expectedResult.add(vnfc);
+ expectedResult.add(vipipv4addresslist1);
+ expectedResult.add(subnet1);
+ expectedResult.add(l3network1);
+ expectedResult.add(vipipv6addresslist1);
+ expectedResult.add(subnet2);
+ expectedResult.add(l3network2);
+ expectedResult.add(l3inter1ipv4addresslist1);
+ expectedResult.add(l3network3);
+ expectedResult.add(subnet3);
+ expectedResult.add(l3network3_2);
+ expectedResult.add(l3inter1ipv6addresslist1);
+ expectedResult.add(l3network4);
+ expectedResult.add(subnet4);
+ expectedResult.add(l3network4_2);
+ expectedResult.add(vserv1);
+ expectedResult.add(tenant1);
+ expectedResult.add(linterface1);
+ expectedResult.add(l3inter1ipv4addresslist2);
+ expectedResult.add(l3network5);
+ expectedResult.add(subnet5);
+ expectedResult.add(l3network5_2);
+ expectedResult.add(l3inter1ipv6addresslist2);
+ expectedResult.add(l3network6);
+ expectedResult.add(subnet6);
+ expectedResult.add(l3network6_2);
+ expectedResult.add(pserver1);
+ expectedResult.add(pserver2);
+ expectedResult.add(pserverint);
+ expectedResult.add(plink1);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "service-topology";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java
new file mode 100644
index 0000000..2d37d13
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SiteL3NetworkCloudRegionQueryTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SiteL3NetworkCloudRegionQueryTest extends QueryTest {
+
+ public SiteL3NetworkCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "clli2");
+ Vertex network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region");
+ Vertex network3 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, network);
+ rules.addEdge(g, region, network);
+ rules.addEdge(g, complex, network3);
+ rules.addEdge(g, complex2, network2);
+ rules.addEdge(g, region2, network2);
+
+ expectedResult.add(complex);
+ expectedResult.add(network);
+ expectedResult.add(region);
+ expectedResult.add(network3);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "site-l3network-cloudRegion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("physical-location-id", "clli");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java
new file mode 100644
index 0000000..9ddff8a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCloudRegionIdQueryTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCloudRegionIdQueryTest extends QueryTest {
+
+ public SitesByCloudRegionIdQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex");
+ Vertex network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network");
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-region-id", "regionuuid");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex");
+ Vertex network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network");
+ Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "regionuuid2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, network);
+ rules.addEdge(g, region, network);
+ rules.addEdge(g, complex2, network2);
+ rules.addEdge(g, region2, network2);
+
+ expectedResult.add(complex);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCloudRegionId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("cloud-region-id", "regionuuid");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java
new file mode 100644
index 0000000..3f7d404
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionIdQueryTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCountryFilterCloudRegionIdQueryTest extends QueryTest {
+
+
+ public SitesByCountryFilterCloudRegionIdQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli-100", "country", "countrycode-100");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network", "network-id", "networkId-100", "network-name", "networkName-100",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-100", "cloud-region-id", "cloudRegionId-100");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-200", "cloud-region-id", "cloudRegionId-200");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network", "network-id", "networkId-200", "network-name", "networkName-200",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex", "physical-location-id", "clli-200", "country", "countrycode-100");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, l3network);
+ rules.addEdge(g, cloudregion, l3network);
+ rules.addEdge(g, complex2, l3network2);
+ rules.addEdge(g, cloudregion2, l3network2);
+
+ expectedResult.add(complex);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCountryFilterCloudRegionId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "complex").has("country", "countrycode-100");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionId", "cloudRegionId-100");
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java
new file mode 100644
index 0000000..5c0e7fc
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SitesByCountryFilterCloudRegionVerQueryTest.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SitesByCountryFilterCloudRegionVerQueryTest extends QueryTest {
+
+
+ public SitesByCountryFilterCloudRegionVerQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli-100", "country", "countrycode-100");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network", "network-id", "networkId-100", "network-name", "networkName-100",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-100", "cloud-region-id", "cloudRegionId-100",
+ "cloud-region-version", "cloudRegionVer-3.0");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "clli-200", "country", "countrycode-100");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network", "network-id", "networkId-200", "network-name", "networkName-200",
+ "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-200", "cloud-region-id", "cloudRegionId-200",
+ "cloud-region-version", "cloudRegionVer-2.5");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, complex, l3network);
+ rules.addEdge(g, cloudregion, l3network);
+ rules.addEdge(g, complex2, l3network2);
+ rules.addEdge(g, cloudregion2, l3network2);
+
+ expectedResult.add(complex);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "sites-byCountryFilterCloudRegionVer";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "complex").has("country", "countrycode-100");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("cloudRegionVersion", "cloudRegionVer-3.0");
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
index a99fa8f..5e3f7f5 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
@@ -108,8 +108,17 @@ public class TopologyDetailFromVserverQueryTest extends QueryTest {
}
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "cloud-region").has("cloud-region-id", "regionid0").has("cloud-owner", "cloudOwnername0").out("has").has("aai-node-type","tenant").has("tenant-id", "tenantid0").out("owns").has("aai-node-type","vserver").has("vserver-id", "vserverid0");
+ g.has("aai-node-type", "cloud-region")
+ .has("cloud-region-id", "regionid0")
+ .has("cloud-owner", "cloudOwnername0")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","tenant")
+ .has("tenant-id", "tenantid0")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","vserver")
+ .has("vserver-id", "vserverid0");
}
+
@Override
protected void addParam(Map<String, Object> params) {
return;
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
index 1891914..3b70fe1 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java
@@ -95,7 +95,7 @@ public class TopologyDetailsQueryTest extends QueryTest {
rules.addEdge(g, owningentity, servinst);
rules.addEdge(g, project, servinst);
rules.addEdge(g, genericvnf, vnfc);
- rules.addEdge(g, vnfc, vserver);
+ rules.addEdge(g, genericvnf,vserver);
rules.addTreeEdge(g, linterface, vserver);
rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
rules.addEdge(g, l3inter1ipv4addresslist, subnet4);
@@ -116,7 +116,7 @@ public class TopologyDetailsQueryTest extends QueryTest {
rules.addEdge(g, owningentity1, servinst1);
rules.addEdge(g, project1, servinst1);
rules.addEdge(g, genericvnf1, vnfc1);
- rules.addEdge(g, vnfc1, vserver1);
+ rules.addEdge(g, genericvnf1,vserver1);
rules.addTreeEdge(g, linterface1, vserver1);
rules.addTreeEdge(g, l3inter1ipv4addresslist1, linterface1);
rules.addEdge(g, l3inter1ipv4addresslist1, subnet41);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
index b10abf3..12a7fd2 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
@@ -240,7 +240,14 @@ public class TopologyFromSubscriberNameAndServiceTypeTest extends QueryTest {
@Override
protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("aai-node-type", "customer").has("global-customer-id", "global-customer-id-1").out("subscribesTo").has("aai-node-type","service-subscription").has("service-type", "service-type-1").out("hasInstance").has("aai-node-type","service-instance");
+ g
+ .has("aai-node-type", "customer")
+ .has("global-customer-id", "global-customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","service-subscription")
+ .has("service-type", "service-type-1")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type","service-instance");
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java
new file mode 100644
index 0000000..1622f2e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryQueryTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologySummaryQueryTest extends QueryTest {
+
+ public TopologySummaryQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnfuuid");
+ Vertex vnfint = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface", "interface-name", "xe0/0/0");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "1", "aai-node-type", "vnfc");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver");
+ Vertex vserverint = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "xe0/0/0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "3", "aai-node-type", "tenant");
+ Vertex region = graph.addVertex(T.label, "could-region", T.id, "4", "aai-node-type", "cloud-region");
+ Vertex image = graph.addVertex(T.label, "image", T.id, "5", "aai-node-type", "image");
+ Vertex flavor = graph.addVertex(T.label, "flavor", T.id, "6", "aai-node-type", "flavor");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, vnf, vnfc);
+ rules.addEdge(g, vnf, vserver);
+ rules.addEdge(g, vnfc, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, region);
+ rules.addEdge(g, vserver, image);
+ rules.addEdge(g, vserver, flavor);
+ rules.addEdge(g, vserver, pserver);
+ rules.addEdge(g, pserver, complex);
+ rules.addEdge(g, region, complex);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addTreeEdge(g, vnf, vnfint);
+ rules.addTreeEdge(g, vserver, vserverint);
+
+ expectedResult.add(vnf);
+ expectedResult.add(vnfc);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(region);
+ expectedResult.add(image);
+ expectedResult.add(flavor);
+ expectedResult.add(pserver);
+ expectedResult.add(complex);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "topology-summary";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-id", "vnfuuid");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java
new file mode 100644
index 0000000..c434eb0
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeInstanceQueryTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class UcpeInstanceQueryTest extends QueryTest {
+
+ public UcpeInstanceQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "11", "aai-node-type", "pnf", "pnf-name", "pnfname");
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnfuuid");
+ Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pnfint = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver, complex);
+ rules.addEdge(g, pnf, complex);
+ rules.addEdge(g, vnf, pserver);
+ rules.addTreeEdge(g, pserver, pserverint);
+ rules.addTreeEdge(g, pnf, pnfint);
+
+ expectedResult.add(complex);
+ expectedResult.add(pserver);
+ //expectedResult.add(pnf);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "ucpe-instance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername");
+ //g.has("pnf-name", "pnfname");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
new file mode 100644
index 0000000..59aa3af
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class UcpeTopologyQueryTest extends QueryTest {
+ public UcpeTopologyQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername");
+ Vertex pserverint1 = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex pserverint2 = graph.addVertex(T.label, "p-interface", T.id, "3", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "4", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "5", "aai-node-type", "tenant", "tenant-id", "tenantuuid", "tenant-name", "tenantname");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "6", "aai-node-type", "cloud-region", "cloud-region-id", "clouduuid", "cloud-region-owner", "cloudOwnername");
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf1uuid");
+ Vertex vnf1image = graph.addVertex(T.label, "vnf-image", T.id, "8", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnf1uuid");
+ Vertex vnf2image = graph.addVertex(T.label, "vnf-image", T.id, "10", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf2imageuuid");
+ Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "11", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex pnfint = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "13", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+ Vertex servinst1 = graph.addVertex(T.label, "service-instance", T.id, "14", "aai-node-type", "service-instance", "service-instance-id", "servinst1uuid");
+ Vertex servsub1 = graph.addVertex(T.label, "service-subscription", T.id, "15", "aai-node-type", "service-subscription", "service-type", "servType1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "16", "aai-node-type", "customer", "global-customer-id", "custuuid");
+ Vertex servinst2 = graph.addVertex(T.label, "service-instance", T.id, "17", "aai-node-type", "service-instance", "service-instance-id", "servinst2uuid");
+ Vertex servsub2 = graph.addVertex(T.label, "service-subscription", T.id, "18", "aai-node-type", "service-subscription", "service-type", "servType2");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pserver, complex);
+ rules.addTreeEdge(g, pserver, pserverint1);
+ rules.addTreeEdge(g, pserver, pserverint2);
+ rules.addEdge(g, pnf, complex);
+ rules.addTreeEdge(g, pnf, pnfint);
+ rules.addEdge(g, pserverint1, plink1);
+ rules.addEdge(g, pnfint, plink1);
+ rules.addEdge(g, vserver, pserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, pserver, vnf1);
+ rules.addEdge(g, vserver, vnf2);
+ rules.addEdge(g, vnf1, vnf1image);
+ rules.addEdge(g, vnf2, vnf2image);
+ rules.addEdge(g, vnf1, servinst1);
+ rules.addTreeEdge(g, servinst1, servsub1);
+ rules.addTreeEdge(g, servsub1, customer);
+ rules.addEdge(g, vnf2, servinst2);
+ rules.addTreeEdge(g, servinst2, servsub2);
+ rules.addTreeEdge(g, servsub2, customer);
+
+ expectedResult.add(pnf);
+ expectedResult.add(complex);
+ expectedResult.add(pnfint);
+ expectedResult.add(pserver);
+ expectedResult.add(pserverint1);
+ expectedResult.add(plink1);
+ expectedResult.add(vnf1);
+ expectedResult.add(vnf1image);
+ expectedResult.add(vnf2);
+ expectedResult.add(vnf2image);
+ expectedResult.add(servinst1);
+ expectedResult.add(servinst2);
+ expectedResult.add(servsub1);
+ expectedResult.add(servsub2);
+ expectedResult.add(customer);
+
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "ucpe-topology";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("hostname", "pservername");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java
index 003c4e0..9573d1f 100644
--- a/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java
@@ -78,7 +78,7 @@ public class AAIAppServletContextListenerTest {
* Test contextDestroyed.
*/
@Test(expected = NullPointerException.class)
- //@Ignore
+ @Ignore
public void testContextDestroyed(){
listener.contextDestroyed(arg);
assertTrue(logContains(Level.DEBUG, "AAI Server shutdown"));
diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
index 218d9ac..2fdb55e 100644
--- a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
+++ b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
@@ -105,3 +105,13 @@ aai.dmaap.workload.enableEventProcessing=true
aai.realtime.clients=RO,SDNC,MSO
aai.server.rebind=g
+
+#timeout for traversal enabled flag
+aai.traversal.timeoutenabled=true
+
+#timeout app specific
+aai.traversal.timeout.appspecific=JUNITTESTAPP1,-1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1
+
+#default timeout limit added for traversal if not overridden (in ms)
+aai.traversal.timeoutlimit=180000
+
diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties
index 11416ca..ba71275 100644
--- a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties
+++ b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties
@@ -25,8 +25,13 @@ AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of ty
AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s)
AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s)
AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2
-AAI_3008=5:6:ERROR:3008:400:3008:URI is not encoded in UTF-8
-AAI_3009=5:6:ERROR:3009:400:3002:Malformed URL
+AAI_3008=5:6:WARN:3008:400:3008:URI is not encoded in UTF-8
+AAI_3009=5:6:WARN:3009:400:3002:Malformed URL
+AAI_3010=5:6:WARN:3010:400:3002:Cannot write via this URL
+AAI_3011=5:6:WARN:3011:400:3000:Unknown XML namespace used in payload
+AAI_3012=5:6:WARN:3012:400:3012:Unrecognized AAI function
+AAI_3013=5:6:WARN:3013:400:3013:Query payload missing required parameters %1
+AAI_3014=5:6:WARN:3014:400:3014:Query payload is invalid %1
# pol errors
AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1
AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2
@@ -34,7 +39,7 @@ AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2
AAI_3300=5:1:WARN:3300:403:3300:Unauthorized
AAI_3301=5:1:WARN:3301:401:3301:Stale credentials
AAI_3302=5:1:WARN:3302:401:3301:Not authenticated
-AAI_3303=5:1:ERROR:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry
+AAI_3303=5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry
#--- aaigen: 4000-4099
AAI_4000=5:4:ERROR:4000:500:3002:Internal Error
@@ -44,23 +49,18 @@ AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file
AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file
AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter
AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service
-AAI_4007=5:4:ERROR:4007:500:3102:Input parsing error
+AAI_4007=5:4:WARN:4007:500:3102:Input parsing error
AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error
-AAI_4009=4:0:ERROR:4009:400:3000:Invalid X-FromAppId in header
-AAI_4010=4:0:ERROR:4010:400:3000:Invalid X-TransactionId in header
+AAI_4009=4:0:WARN:4009:400:3000:Invalid X-FromAppId in header
+AAI_4010=4:0:WARN:4010:400:3000:Invalid X-TransactionId in header
AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response
-AAI_4012=5:4:ERROR:4012:500:3002:Bad rule data in RestRules
-AAI_4013=5:4:ERROR:4013:500:3002:Error connecting to AAI REST API
-AAI_4014=4:0:ERROR:4014:400:3000:Invalid Accept header
-AAI_4015=4:0:ERROR:4015:400:3000:You must provide at least one indexed property
-AAI_4016=4:0:ERROR:4016:400:3000:The depth parameter must be a number or the string "all"
+AAI_4014=4:0:WARN:4014:400:3000:Invalid Accept header
+AAI_4015=4:0:WARN:4015:400:3000:You must provide at least one indexed property
+AAI_4016=4:0:WARN:4016:400:3000:The depth parameter must be a number or the string "all"
AAI_4017=5:2:INFO:4017:400:3000:Could not set property
-AAI_4018=5:2:ERROR:4018:400:3000:Unable to convert the string to integer
-#--- aaidbmap: 5101-5199
-AAI_5101=5:4:FATAL:5101:500:3002:Could not connect to database
+AAI_4018=5:2:WARN:4018:400:3000:Unable to convert the string to integer
+#--- aaidbmap: 5102-5199
AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open
-AAI_5103=5:4:ERROR:5103:500:3002:Unexpected error during commit
-AAI_5104=5:4:ERROR:5104:500:3002:Unexpected error during rollback
AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database
AAI_5106=5:4:WARN:5106:404:3001:Node not found
AAI_5107=5:2:WARN:5107:400:3000:Required information missing
@@ -77,14 +77,14 @@ AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data
AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data
AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value
AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted
-AAI_6111=5:4:ERROR:6111:400:3000:JSON processing error
+AAI_6111=5:4:WARN:6111:400:3000:JSON processing error
AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode()
AAI_6114=5:4:INFO:6114:404:3001:Node Not Found
AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType
AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property
AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated
-AAI_6118=5:4:ERROR:6118:400:3000:Required Field not passed.
-AAI_6120=5:4:ERROR:6120:400:3000:Bad Parameter Passed
+AAI_6118=5:4:WARN:6118:400:3000:Required Field not passed.
+AAI_6120=5:4:WARN:6120:400:3000:Bad Parameter Passed
AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data
AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request
AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate
@@ -111,6 +111,7 @@ AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found
AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph
AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship
AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead
+AAI_6147=5:4:ERROR:6147:400:3000:Payload Limit Reached, reduce payload
#--- aaicsvp: 7101-7199
AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing
@@ -138,7 +139,7 @@ AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl
AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API
AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API
AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate
-AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
+#AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
#--- NotificationEvent, using UEB space
AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed
@@ -148,17 +149,24 @@ AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API
AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error
AAI_7403=5:4:WARN:7403:400:3001:Request error
AAI_7404=5:4:INFO:7404:404:3001:Node not found
+AAI_7405=5:4:WARN:7405:200:0:UUID not formatted correctly, generating UUID
+AAI_7406=5:4:ERROR:7406:400:7406:Request Timed Out
+
+#--- aaicsiovals: 7501-7599
+#AAI_7501=5:4:WARN:7501:500:3002:Error getting connection to CSI-OVALS
+AAI_7502=5:4:WARN:7502:500:3002:Bad parameter when trying to build request for CSI-OVALS
+AAI_7503=5:4:WARN:7503:500:3002:Error returned by CSI-OVALS
#--- aaiauth: 9101-9199
AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function
-AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
-AAI_9103=5:0:WARN:9103:403:3300:User not found
-AAI_9104=5:0:WARN:9104:401:3302:Authentication error
-AAI_9105=5:0:WARN:9105:403:3300:Authorization error
-AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
+#AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
+#AAI_9103=5:0:WARN:9103:403:3300:User not found
+#AAI_9104=5:0:WARN:9104:401:3302:Authentication error
+#AAI_9105=5:0:WARN:9105:403:3300:Authorization error
+#AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request
AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin
#--- aaiinstar: 9201-9299
-AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
+#AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread
diff --git a/aai-traversal/src/test/resources/logback.xml b/aai-traversal/src/test/resources/logback.xml
index cc64017..38499e0 100644
--- a/aai-traversal/src/test/resources/logback.xml
+++ b/aai-traversal/src/test/resources/logback.xml
@@ -22,237 +22,14 @@
-->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
- <contextName>${module.ajsc.namespace.name}</contextName>
- <jmxConfigurator />
- <property name="logDirectory" value="${AJSC_HOME}/logs" />
-
- <!-- Example evaluator filter applied against console appender -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> -->
- <level>ERROR</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n
- </pattern>
- </encoder>
- </appender>
- <appender name="METRIC"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>INFO</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <file>${logDirectory}/rest/metric.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/metric.log.%d{yyyy-MM-dd}</fileNamePattern>
- </rollingPolicy>
- <!-- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy> -->
- <encoder>
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="DEBUG"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>DEBUG</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <file>${logDirectory}/rest/debug.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
- </rollingPolicy>
- <!-- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>-->
- <encoder>
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="ERROR"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>WARN</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <file>${logDirectory}/rest/error.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/error.log.%d{yyyy-MM-dd}</fileNamePattern>
- </rollingPolicy>
- <!-- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>-->
- <encoder>
- <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n"</pattern> -->
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="AUDIT"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
- <evaluator>
- <matcher>
- <Name>audit</Name>
- <!-- filter out odd numbered statements -->
- <regex>co\=aairest</regex>
- </matcher>
- <expression>level == INFO &amp;&amp; audit.matches(formattedMessage)</expression>
- </evaluator>
- <OnMatch>ACCEPT</OnMatch>
- <OnMismatch>DENY</OnMismatch>
- </filter>
- <file>${logDirectory}/rest/audit.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/metric.log.%d{yyyy-MM-dd}</fileNamePattern>
- </rollingPolicy>
- <encoder>
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="auditLogs"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- </filter>
- <file>${logDirectory}/rest/audit.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/audit-${lrmRVer}-${lrmRO}-${Pid}.%d{yyyy-MM-dd}.log.zip
- </fileNamePattern>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern>
- </encoder>
- </appender>
-
- <appender name="perfLogs"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- </filter>
- <file>${logDirectory}/rest/perform.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/perform-${lrmRVer}-${lrmRO}-${Pid}.%d{yyyy-MM-dd}.log.zip
- </fileNamePattern>
- </rollingPolicy>
- <!-- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy> -->
- <encoder>
- <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern>
- </encoder>
- </appender>
-
- <!-- Spring related loggers -->
- <logger name="org.springframework" level="WARN" />
- <logger name="org.springframework.beans" level="WARN" />
- <logger name="org.springframework.web" level="WARN" />
- <logger name="com.blog.spring.jms" level="WARN" />
-
- <!-- AJSC Services (bootstrap services) -->
- <logger name="ajsc" level="WARN" />
- <logger name="ajsc.RouteMgmtService" level="WARN" />
- <logger name="ajsc.ComputeService" level="WARN" />
- <logger name="ajsc.VandelayService" level="WARN" />
- <logger name="ajsc.FilePersistenceService" level="WARN" />
- <logger name="ajsc.UserDefinedJarService" level="WARN" />
- <logger name="ajsc.UserDefinedBeansDefService" level="WARN" />
- <logger name="ajsc.LoggingConfigurationService" level="WARN" />
-
- <!-- AJSC related loggers (DME2 Registration, csi logging, restlet, servlet
- logging) -->
- <logger name="ajsc.utils" level="WARN" />
- <logger name="ajsc.utils.DME2Helper" level="WARN" />
- <logger name="ajsc.filters" level="WARN" />
- <logger name="ajsc.beans.interceptors" level="WARN" />
- <logger name="ajsc.restlet" level="WARN" />
- <logger name="ajsc.servlet" level="WARN" />
- <logger name="com.att.ajsc" level="WARN" />
- <logger name="com.att.ajsc.csi.logging" level="WARN" />
- <logger name="com.att.ajsc.filemonitor" level="WARN" />
-
- <!-- Other Loggers that may help troubleshoot -->
- <logger name="net.sf" level="WARN" />
- <logger name="org.apache.commons.httpclient" level="WARN" />
- <logger name="org.apache.commons" level="WARN" />
- <logger name="org.apache.coyote" level="WARN" />
- <logger name="org.apache.jasper" level="WARN" />
-
- <!-- Camel Related Loggers (including restlet/servlet/jaxrs/cxf logging.
- May aid in troubleshooting) -->
- <logger name="org.apache.camel" level="WARN" />
- <logger name="org.apache.cxf" level="WARN" />
- <logger name="org.apache.camel.processor.interceptor" level="WARN" />
- <logger name="org.apache.cxf.jaxrs.interceptor" level="WARN" />
- <logger name="org.apache.cxf.service" level="WARN" />
- <logger name="org.restlet" level="WARN" />
- <logger name="org.apache.camel.component.restlet" level="WARN" />
-
- <!-- logback internals logging -->
- <logger name="ch.qos.logback.classic" level="INFO" />
- <logger name="ch.qos.logback.core" level="INFO" />
-
- <appender name="ASYNC-audit" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>1000</queueSize>
- <discardingThreshold>0</discardingThreshold>
- <appender-ref ref="Audit-Record-Queue" />
- </appender>
-
- <appender name="ASYNC-perf" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>1000</queueSize>
- <discardingThreshold>0</discardingThreshold>
- <appender-ref ref="Performance-Tracker-Queue" />
- </appender>
-
- <!--
- <logger name="AuditRecord" level="INFO" additivity="FALSE">
- <appender-ref ref="ASYNC-audit" />
- <appender-ref ref="auditLogs" />
- </logger>
- <logger name="AuditRecord_DirectCall" level="INFO" additivity="FALSE">
- <appender-ref ref="ASYNC-audit" />
- <appender-ref ref="auditLogs" />
- </logger>
- <logger name="PerfTrackerRecord" level="INFO" additivity="FALSE">
- <appender-ref ref="ASYNC-perf" />
- <appender-ref ref="perfLogs" />
- </logger>
- -->
-
- <logger name="org.onap.aai" level="INFO" />
-
- <!--
- <logger name="org.onap.aai.util" level="WARN" />
- <logger name="org.onap.aai.rest" level="WARN" />
- <logger name="org.onap.aai.rest.Business" level="WARN" />
- -->
-
- <logger name="org.apache" level="WARN" />
- <logger name="org.zookeeper" level="WARN" />
- <logger name="com.thinkaurelius" level="WARN" />
-
- <root level="WARN">
- <appender-ref ref="DEBUG" />
- <appender-ref ref="ERROR" />
- <appender-ref ref="METRIC" />
- <appender-ref ref="AUDIT" />
- </root>
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n</pattern>
+ </encoder>
+ </appender>
+ <root level="INFO">
+ <appender-ref ref="CONSOLE"/>
+ </root>
</configuration>
diff --git a/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-linterface.json b/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-linterface.json
new file mode 100644
index 0000000..54fc44d
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-linterface.json
@@ -0,0 +1,57 @@
+{
+ "cloud-owner": "${cloud-owner}",
+ "cloud-region-id": "${cloud-region-id}",
+ "tenants": {
+ "tenant": [
+ {
+ "tenant-id": "${tenant-id}",
+ "tenant-name": "${tenant-name}",
+ "vservers": {
+ "vserver": [
+ {
+ "vserver-id": "${vserver-id}",
+ "vserver-name": "${vserver-name}",
+ "vserver-name2": "vserver-name-2",
+ "vserver-selflink": "vserver-selflink-1",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "volumes": {},
+ "l-interfaces": {
+ "l-interface": [
+ {
+ "interface-name": "${interface-name}",
+ "interface-role": "role",
+ "v6-wan-link-ip": "test-v6-wan-link-ip",
+ "selflink": "example-selflink-val-10559",
+ "interface-id": "example-interface-id-val",
+ "l3-interface-ipv4-address-list" : [ {
+ "l3-interface-ipv4-address" : "${ipv4-address}",
+ "l3-interface-ipv4-prefix-length" : 849,
+ "vlan-id-inner" : 174,
+ "vlan-id-outer" : 120,
+ "is-floating" : true
+ }],
+ "l3-interface-ipv6-address-list" : [ {
+ "l3-interface-ipv6-address" : "${ipv6-address}",
+ "l3-interface-ipv6-prefix-length" : 509,
+ "vlan-id-inner" : 890,
+ "vlan-id-outer" : 192,
+ "is-floating" : false
+ }],
+ "vlans" : {
+ "vlan" : [ {
+ "vlan-interface" : "${vlan-interface}",
+ "vlan-id-inner" : 948,
+ "vlan-id-outer" : 722,
+ "speed-value" : "oR8Zpuk5",
+ "speed-units" : "lZsf2I"
+ }]}
+ }]}
+
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/aai-traversal/src/test/resources/payloads/templates/custom-query.json b/aai-traversal/src/test/resources/payloads/templates/custom-query.json
new file mode 100644
index 0000000..6875a99
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/custom-query.json
@@ -0,0 +1,4 @@
+{
+ "start": [ "${start}" ],
+ "query": "query/${query}"
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/templates/gremlin-query.json b/aai-traversal/src/test/resources/payloads/templates/gremlin-query.json
new file mode 100644
index 0000000..b163261
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/gremlin-query.json
@@ -0,0 +1,4 @@
+{
+ "gremlin": "${gremlin-query}"
+}
+