aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal')
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java983
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java608
2 files changed, 1524 insertions, 67 deletions
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
new file mode 100644
index 0000000..b255916
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
@@ -0,0 +1,983 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.dbgraphgen;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyMap;
+import static org.mockito.Matchers.anyMapOf;
+import static org.mockito.Mockito.*;
+
+import com.bazaarvoice.jolt.modifier.DataType;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.Multimap;
+import com.thinkaurelius.titan.graphdb.olap.computer.VertexMapJob;
+import com.thinkaurelius.titan.graphdb.types.VertexLabelVertex;
+import com.thinkaurelius.titan.graphdb.types.system.BaseVertexLabel;
+import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
+import com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex;
+import com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.openjpa.kernel.exps.Exp;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.openecomp.aai.db.DbMethHelper;
+import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.openecomp.aai.serialization.db.DBSerializer;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+
+import javax.inject.Inject;
+import java.util.*;
+@RunWith(MockitoJUnitRunner.class)
+public class ModelBasedProcessingInvalidDataTest {
+
+ @Mock
+ private static TransactionalGraphEngine dbEngine;
+ private static Loader loader;
+ @Mock
+ private static DBSerializer serializer;
+ ModelBasedProcessing processor;
+
+ @Mock
+ private ModelBasedProcessing mockProcessor;
+
+
+ @Mock
+ private DbMethHelper dbMethHelper;
+
+ @BeforeClass
+ public static void configure() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+
+
+ }
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ dbMethHelper = new DbMethHelper(loader, dbEngine);
+
+ }
+
+ @Test
+ public void getStartNodesAndModVersionIdsTest() throws AAIException {
+
+
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result=new HashMap<>();
+
+ Map<String, String> result1 = mockProcessor.getStartNodesAndModVersionIds("test", "test",
+ "test", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsTest2() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsTest3() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsTest4() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsTest5() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsNullTest() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+
+ assertNotNull(result);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest1() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "Test", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+
+ assertNotNull(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest2() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "test", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest3() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "test",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerTopWidgetTypeTest() throws AAIException {
+ Vertex vertex = new EmptyVertex();
+ //Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(Vertex.class), Mockito.any(String.class))).thenReturn("Sucess");
+ String result = processor.getModelVerTopWidgetType(vertex, "test");
+ assertEquals("result has -local tacked on the end as it should", "Sucess", result
+ );
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerTopWidgetType() throws AAIException {
+ /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class))
+ ).thenReturn("Sucess");*/
+ String result = processor.getModelVerTopWidgetType("test", "test", "test", "Test", "test");
+ assertEquals("result has -local tacked on the end as it should", "Sucess", result
+ );
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByModel() throws AAIException {
+ /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class),
+ Mockito.any(String.class), Mockito.any(String.class))
+ ).thenReturn("Sucess");*/
+ List<ResultSet> result = processor.queryByModel("test", "test",
+ "test", "test", "test",
+ "generic-vnf", null,
+ "test");
+ assertEquals("result has -local tacked on the end as it should", 0, result.size());
+
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void queryByModel_Timed() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ List<ResultSet> result = processor.queryByModel_Timed("test", "test",
+ "test", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertEquals("result has -local tacked on the end as it should", 0, result.size());
+
+
+ }
+
+ @Mock
+ Map<String, Object> startNodeFilterHash;
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModel() throws AAIException {
+ Map<String, String> resultMock = new HashMap<String, String>();
+
+ // when(mockProcessor.getNodeUsingUniqueId(any(String.class),any(String.class),any(String.class),any(String.class),any(String.class))).thenReturn(vertex);
+ when(mockProcessor.runDeleteByModel(any(String.class),
+ any(String.class), any(String.class),
+ any(String.class), anyMapOf(String.class, Object.class), any(String.class), any(String.class))
+ ).thenReturn(resultMock);
+ Map<String, String> result = processor.runDeleteByModel("test", "test",
+ "test", "test", startNodeFilterHash,
+ "test",
+ "test");
+ assertEquals("result has -local tacked on the end as it should", result.size(), resultMock.size());
+
+
+ }
+
+ Optional<Vertex> vertext = Optional.empty();
+
+ @Test(expected = AAIException.class)
+ public void runDeleteByModelWithNullParams() throws AAIException {
+ Map<String, String> resultMock = new HashMap<String, String>();
+
+
+ Map<String, String> result = processor.runDeleteByModel("test", "test",
+ null, null, null,
+ "test",
+ "test");
+
+ assertNotNull(result);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModelWithNullParams1() throws AAIException {
+
+ Map<String, String> result1 = processor.runDeleteByModel("test", "test",
+ null, "unknown", null,
+ "test",
+ "test");
+ assertNotNull(result1);
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModelWithNullParams2() throws AAIException {
+
+ Map<String, String> result1 = processor.runDeleteByModel("test", "test",
+ null, "unknown", null,
+ "test",
+ "test");
+ assertNotNull(result1);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery() throws AAIException{
+ String transId="test";
+ String fromAppId="test";
+ String namedQueryUuid="test";
+ ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
+ String apiVer="test";
+ List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer);
+ assertNotNull(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery1() throws AAIException{
+ String transId="teet";
+ String fromAppId="test";
+ String namedQueryUuid="test";
+ String secondaryFilterCutPoint="test";
+ List <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
+ String apiVer="test";
+ Map<String,Object> secondaryFilterHash=new HashMap<String,Object>();
+ List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer,secondaryFilterCutPoint,secondaryFilterHash);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void deleteAsNeededFromResultSet() throws AAIException {
+ Vertex vert = new BaseVertexLabel("Test");
+ Map<String, String> resultMock = new HashMap<String, String>();
+ ResultSet resultSet = new ResultSet();
+ resultSet.setVert(null);
+
+ Map<String, String> result = processor.deleteAsNeededFromResultSet("test", "test",
+ resultSet, "test", "test",
+ "test",
+ resultMock);
+
+ assertEquals(result.size(), 0);
+
+ resultSet.setVert(vert);
+
+ Map<String, String> result1 = processor.deleteAsNeededFromResultSet("test", "test",
+ resultSet, "test", "test",
+ "test",
+ resultMock);
+
+ assertEquals(result.size(), 0);
+
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void pruneResultSetTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ ResultSet resultSet = processor.pruneResultSet(rs, "testr", map);
+ assertNotNull(resultSet);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void satisfiesFiltersTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ rs.getVert().property(AAIProperties.NODE_TYPE);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+
+ map.put("modern.vertex-id", new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, true);
+ }
+
+ @Test
+ public void satisfiesFiltersTest1() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ //map.put("test.filter",new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, false);
+ }
+
+ @Test(expected = AAIException.class)
+ public void satisfiesFiltersTest2() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("testfilter", new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, false);
+ }
+
+ @Test
+ public void collapseForDoNotOutputTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ rs.setDoNotOutputFlag("true");
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ List<ResultSet> result = processor.collapseForDoNotOutput(rs);
+ assertEquals(result.size(), 1);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectInstanceDataTest() throws AAIException {
+
+ BaseVertexLabel bs = new BaseVertexLabel("test");
+ //bs.setId(80);
+ EmptyVertex ev = new EmptyVertex();
+ //ev.setId(50l);
+ Vertex thisLevelElemVtx = ev;
+
+
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ List<String> vidsTraversed = new ArrayList<String>();
+ // only applies when collecting data using the default model for delete
+ Multimap<String, String> validNextStepMap = ArrayListMultimap.create();
+ Map<String, String> namedQueryElementHash = new HashMap<String, String>();
+ namedQueryElementHash.put("test", "test");
+ Map<String, String> delKeyHash = new HashMap<String, String>();
+
+ ResultSet rs = processor.collectInstanceData("test", "test", thisLevelElemVtx, "test", validNextStepMap, vidsTraversed, 1, delKeyHash, namedQueryElementHash, "test");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void genTopoMap4ModelVerTest() throws
+ AAIException {
+ Vertex vertext = new EmptyVertex();
+ Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
+ assertNotEquals(map, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4ModelVerTestNull() throws
+ AAIException {
+ Vertex vertext = null;
+ Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
+ assertNotEquals(map, null);
+ }
+
+ @Test
+ public void makeSureItsAnArrayListTest() {
+ String input = "model-versionId,modelTestID,modelTestid2;";
+ List<String> result = processor.makeSureItsAnArrayList(input);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModConstraintHashTest() throws AAIException {
+ Vertex modelElementVtx = new EmptyVertex();
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = new EmptyVertex();
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModConstraintHashTestNull() throws AAIException {
+ Vertex modelElementVtx = null;
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 =null;
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getTopElementForSvcOrResModelVerTest() throws AAIException {
+ Vertex modelElementVtx = new EmptyVertex();
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = new EmptyVertex();
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Vertex result = processor.getTopElementForSvcOrResModelVer(modelElementVtx, "test");
+ assertNotEquals(result, null);
+ }
+
+ @Test
+ public void getNamedQueryPropOverRideTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNamedQueryPropOverRideTestNull() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void namedQueryConstraintSaysStopTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void namedQueryConstraintSaysStopTestNull() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void namedQuerynamedQueryElementVertexNullTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = null;
+ String apiVer = "test";
+
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+
+ public void getNamedQueryExtraDataLookupTest() throws Exception {
+
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryExtraDataLookup(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectNQElementHash() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, String> currentHash = new HashMap<String, String>();
+ ArrayList<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Map<String, String> result = processor.collectNQElementHash(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, currentHash,
+ vidsTraversed, levelCounter);
+
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectDeleteKeyHash() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, String> currentHash = new HashMap<String, String>();
+ ArrayList<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+ Map<String, Vertex> modConstraintHash = new HashMap<String, Vertex>();
+ String overRideModelId = "test";
+ String overRideModelVersionId = "test";
+
+ Map<String, String> result = processor.collectDeleteKeyHash(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, currentHash,
+ vidsTraversed, levelCounter, modConstraintHash, overRideModelId, overRideModelVersionId);
+
+ assertNotEquals(result, null);
+ }
+
+ @Test
+ public void getLinkageConnectNodeTypesTest() throws AAIException {
+ List<String> linkagePtList = new ArrayList<String>();
+ linkagePtList.add("modern\\|testdata\\|");
+ Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
+ assertNotEquals(result, null);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getLinkageConnectNodeTypesTest1() throws AAIException {
+
+ Set<String> result1 = processor.getLinkageConnectNodeTypes(null);
+ assertNotEquals(result1, null);
+
+ List<String> linkagePtList = new ArrayList<String>();
+ linkagePtList.add("moderntestdata");
+ Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectTopology4ModelVerTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ List<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Multimap<String, String> result = processor.collectTopology4ModelVer(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter, currentHash
+ , "test", "test");
+
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void check4EdgeRuleTest() throws AAIException {
+ processor.check4EdgeRule("test", "test");
+ }
+
+ @Test(expected = AAIException.class)
+ public void collectTopology4LinkagePointTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ String linkagePointStrVal = "test";
+ String incomingTrail = "test";
+ Multimap<String, String> currentMap = ArrayListMultimap.create();
+
+ Multimap<String, String> result = processor.collectTopology4LinkagePoint(transId, fromAppId, linkagePointStrVal, incomingTrail, currentMap);
+ assertNotEquals(result, null);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getNextStepElementsFromSet() throws AAIException {
+ Vertex constrElemSetVtx = new EmptyVertex();
+ constrElemSetVtx.<String>property(AAIProperties.NODE_TYPE);
+ Map<String, Object> result = processor.getNextStepElementsFromSet(constrElemSetVtx);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void genTopoMap4NamedQTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex queryVertex = new EmptyVertex();
+ String namedQueryUuid = "E44533334343";
+ Multimap<String, String> result = processor.genTopoMap4NamedQ(transId, fromAppId, queryVertex, namedQueryUuid);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectTopology4NamedQTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ List<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Multimap<String, String> result = processor.collectTopology4NamedQ(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelThatNqElementRepresentsTest() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Vertex vertex = processor.getModelThatNqElementRepresents(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelGivenModelVer() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Vertex vertex = processor.getModelGivenModelVer(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelTypeFromModel() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelTypeFromModel(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelTypeFromModelVer() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelTypeFromModelVer(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelElementStepName() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelElementStepName(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void nodeTypeSupportsPersona() throws AAIException {
+ String incomingTrail = "";
+ boolean vertex = processor.nodeTypeSupportsPersona(incomingTrail);
+ assertFalse(vertex);
+
+
+ incomingTrail = "test";
+ boolean vertex1 = processor.nodeTypeSupportsPersona(incomingTrail);
+ assertTrue(vertex1);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNqElementWidgetType() throws AAIException{
+ String appId="test";
+ String transID="test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex1 = processor.getNqElementWidgetType(appId,transID,thisLevelElemVtx,incomingTrail);
+ assertNotEquals(vertex1,null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getModElementWidgetType() throws AAIException{
+ String appId="test";
+ String transID="test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex1 = processor.getModElementWidgetType(thisLevelElemVtx,incomingTrail);
+ assertNotEquals(vertex1,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNodeUsingUniqueId() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "test";
+ String uniqueIdVal="test";
+ Vertex vertex1 = processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "test";
+ String uniqueIdVal="";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull1() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "generic-vnf";
+ String idPropertyName="";
+ String uniqueIdVal="test";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull2() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String nodeType = "";
+ String idPropertyName="test";
+ String uniqueIdVal="test";
+ Vertex vertex1 = null;
+ vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
+ assertNotEquals(vertex1,null);
+
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVersUsingName() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+
+ List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getModelVersUsingNameNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "";
+
+ List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModelInvId() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+
+ Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModVersUsingModelInvIdNull() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "";
+
+ Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModel() throws AAIException{
+ String appId="test";
+ String transID="test";
+ String modelName = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModVersUsingModel1() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ Vertex thisLevelElemVtx = null;
+ List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerIdsUsingName() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelName= "test";
+ List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelVerIdsUsingName1() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelName= "";
+ List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
+ assertNotEquals(result,null);
+ }
+
+ @Test(expected =NullPointerException.class)
+ public void validateModel() throws AAIException{
+ String appId="test";
+ String transID="test";
+
+ String modelVersionId= "test";
+ String modelInvId= "test";
+ String modelName= "test";
+ processor.validateModel(transID,appId,modelName,modelVersionId);
+
+
+ }
+
+
+
+}
+
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
index 7579218..64e723b 100644
--- a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
+++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
@@ -1,67 +1,541 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.openecomp.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.aai.dbgraphgen;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-
-public class ModelBasedProcessingTest {
-
- @Mock private static TransactionalGraphEngine dbEngine;
- private static Loader loader;
- @Mock private static DBSerializer serializer;
- @BeforeClass
- public static void configure() throws Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
-
- }
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testPropNameChange() throws AAIUnknownObjectException {
- String result;
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id");
- assertEquals("result has -local tacked on the end as it should", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
- result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "vnf-id");
- assertEquals("result does NOT have -local tacked on the end as it should", "vnf-id", result);
- result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX);
- assertEquals("property not modified because it already includes the right suffix", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.dbgraphgen;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import com.bazaarvoice.jolt.modifier.DataType;
+import com.google.common.collect.Multimap;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.mockito.internal.exceptions.MockitoLimitations;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.openecomp.aai.db.DbMethHelper;
+import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.Introspector;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.openecomp.aai.parsers.exceptions.AAIIdentityMapParseException;
+import org.openecomp.aai.query.builder.GraphTraversalBuilder;
+import org.openecomp.aai.query.builder.QueryBuilder;
+import org.openecomp.aai.query.builder.TraversalQuery;
+import org.openecomp.aai.schema.enums.PropertyMetadata;
+import org.openecomp.aai.serialization.db.DBSerializer;
+import org.openecomp.aai.serialization.db.EdgeType;
+import org.openecomp.aai.serialization.engines.QueryStyle;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ModelBasedProcessingTest {
+
+ @Mock private static TransactionalGraphEngine dbEngine;
+ private static Loader loader;
+ @Mock private static DBSerializer serializer;
+ @Mock private static TransactionalGraphEngine.Admin admin;
+ ModelBasedProcessing mockProcessor;
+ @Mock
+ private DbMethHelper dbMethHelper;
+
+ @BeforeClass
+ public static void configure() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+
+
+ }
+
+ @Before
+ public void init() {
+ mockProcessor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testPropNameChange1() throws AAIUnknownObjectException {
+ String result;
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id");
+ assertEquals("result has -local tacked on the end as it should", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "vnf-id");
+ assertEquals("result does NOT have -local tacked on the end as it should", "vnf-id", result);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX);
+ assertEquals("property not modified because it already includes the right suffix", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
+ }
+
+ @Mock
+ GraphTraversal<Vertex, Vertex> v;
+ @Mock
+ GraphTraversal<Vertex, Vertex> graphTraversal;
+ @Mock
+ GraphTraversalSource graphTraversalSource;
+ @Mock Iterable <?> uniqVerts;
+ List<Vertex> vertexList=new ArrayList<>();
+ @Mock Vertex vertex;
+ @Mock Vertex vertex1;
+ @Mock
+ QueryBuilder<Vertex> queryBuilder;
+
+ EdgeType treeType;
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIds() throws AAIException{
+
+ vertex.property("model-ver","model-version-id");
+ vertex1.property(AAIProperties.NODE_TYPE,"model-ver");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-ver","model-version-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
+
+ queryBuilder.toList().add(vertex);
+ Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder);
+
+ Introspector obj=loader.introspectorFromName("model-ver");
+
+ Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder);
+ //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1");
+
+
+ List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
+
+ Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
+ "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIds1() throws AAIException{
+
+ vertex.property("model-version-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"model-ver");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-version-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
+
+ queryBuilder.toList().add(vertex);
+ Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder);
+
+ Introspector obj=loader.introspectorFromName("generic-vnf");
+ Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder);
+ //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1");
+
+
+ List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
+
+ Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
+ "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
+ }
+
+ @Test
+ public void getNodeUsingUniqueIdTest() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
+ }
+
+ @Test
+ public void getNodeUsingUniqueIdTest1() throws AAIException{
+ vertex.property("named-query-uui","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uui","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","named-query","named-query-uui","vnf-id-1");
+
+ assertNotNull(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelVersUsingNameTest() throws AAIException{
+
+ vertex.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ vertex1.property("generic-vnf","generic-vnf");
+ graphTraversal.addV(vertex1);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model-name","generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ //Mockito.when(vertexList.listIterator().hasNext()).thenReturn(true);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ List<Vertex> result=processor.getModelVersUsingName("9999","postment","generic-vnf");
+
+ assertTrue(result.size()>0);
+ }
+
+ //uniqueIdVal Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","");
+
+
+ }
+
+ //idPropertyName Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","","vnf-id-1");
+
+
+ }
+
+ //idPropertyName Null Expecting AAI Excpetion
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestNull2() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","","vnf-id","vnf-id-1");
+
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestTwoVertex() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
+ }
+
+ //uniqVerts Null Expection AAI Exception
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestVertexNull() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(null);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
+ }
+
+ //uniqVerts Null Expection AAI Exception
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdTestVertexHasNot() throws AAIException{
+ vertex.property("vnf-id","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ //vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
+
+ assertNotNull(result);
+ }
+
+ @Test(expected = AAIIdentityMapParseException.class)
+ public void runDeleteByModelTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Optional<Vertex> vertex=Optional.empty();
+ Map<String,Object> startNodeFilterHash=new HashMap<>();
+ startNodeFilterHash.put("related-link.data","relationshipdata");
+ startNodeFilterHash.put("generic-vnf.d","relationshipdata");
+ Mockito.when(dbMethHelper.searchVertexByIdentityMap("relationship-data",startNodeFilterHash)).thenReturn(vertex);
+ Map<String,String> re =processor.runDeleteByModel("9999","postmen","","relationship-data",startNodeFilterHash,"vnf-id","vnf-id");
+ assertNotNull(re);
+
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelGivenModelVerTest() throws AAIException{
+ vertex.property("named-query-uuid","vnf-id-1");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uuid","vnf-id-1")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Vertex result=processor.getModelGivenModelVer(vertex,"");
+ assertNotNull(result);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery_TimedTest() throws AAIException{
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ //vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("named-query-uuid","named-query-element")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
+ Map<String,Object> secondaryFilterHash=new HashMap<>();
+
+ List<ResultSet> res=processor.queryByNamedQuery_Timed("99999","postmen","named-query-element",startNodeFilterArrayOfHashes,"vnf","vnf",
+ secondaryFilterHash);
+
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4NamedQTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",vertex,"named-query-element");
+ }
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4NamedQTest1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ vertex.property("named-query-uuid","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+
+ Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",null,"named-query-element");
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelThatNqElementRepresentsTest() throws AAIException{
+ vertex.property("model-ver","named-query-element");
+ vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
+ graphTraversal.addV(vertex);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ QueryBuilder qub=Mockito.mock(QueryBuilder.class);
+ qub.toList().addAll(vertexList);
+ Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
+
+ Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ Vertex v=processor.getModelThatNqElementRepresents(vertex,"g");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelTypeFromModel() throws AAIException{
+ Vertex vt=Mockito.mock(Vertex.class);
+ vt.property("model-type","named-query-element");
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ String v=processor.getModelTypeFromModel(vt,"g");
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelTypeFromModel1() throws AAIException{
+ Vertex vt=Mockito.mock(Vertex.class);
+ vt.property("model-type","named-query-element");
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ String v=processor.getModelTypeFromModel(null,"g");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModelInvId() throws AAIException{
+
+ vertex.property(AAIProperties.NODE_TYPE,"model-invariant-id");
+ vertex1.property("model","model-invariant-id");
+ graphTraversal.addV(vertex1);
+ v.addV(vertex1);
+ vertexList.add(vertex);
+ vertexList.add(vertex1);
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
+ Mockito.when(graphTraversalSource.V()).thenReturn(v);
+ Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-invariant-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.has("model","model-invariant-id")).thenReturn(graphTraversal);
+ Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Iterator<Vertex> result=processor.getModVersUsingModelInvId("9999","postment","model");
+ }
+
+ @Test(expected = AAIException.class)
+ public void getNamedQueryExtraDataLookupTest() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",null,vertex,
+ "");
+ }
+
+ @Test(expected = AAIException.class)
+ public void getNamedQueryExtraDataLookupTest1() throws AAIException{
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",vertex,null,
+ "");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void showResultSet() throws AAIException{
+ vertex.property("model-ver","model-versionId");
+ vertex.property("aai","model-versionId");
+
+
+ ResultSet rs= Mockito.mock(ResultSet.class);
+ Mockito.when(rs.getVert()).thenReturn(vertex);
+
+ List<VertexProperty<String>> vb=new ArrayList<>();
+ VertexProperty<String> v=Mockito.mock(VertexProperty.class);
+ v.property("model-ver","1");
+ vb.add(v);
+ v.property("aai","5");
+ vb.add(v);
+ v.property("source-of-truth","6");
+ vb.add(v);
+
+ vertex.properties("model-ver","aai");
+ Mockito.when(vertex.<String>property(AAIProperties.NODE_TYPE)).thenReturn(v);
+ //Mockito.when(vertex.properties()).thenReturn(Mockito.any());
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ processor.showResultSet(rs,8);
+
+ }
+}