aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraditya <ag282f@att.com>2017-10-09 23:31:07 -0500
committeraditya <ag282f@att.com>2017-10-09 23:31:07 -0500
commitc147c1d307cd4a475b25f962e4d1a6f63305c192 (patch)
tree31a7780d2fc90d7a4d4e8f11956b18e8a27f1f88
parented2aea524aa3a743a04a48dd8e1b4065f815d2e4 (diff)
Add unit test cases to increase the sonar coverage
Add unit test cases to increase the sonar coverage Issue ID: AAI-212 Change-Id: Ife2e388dec30068781f83e478180fc0054d83f17 Signed-off-by: Aditya Gajulapalli <ag282f@att.com>
-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
2 files changed, 824 insertions, 1439 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
deleted file mode 100644
index bd3705e..0000000
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
+++ /dev/null
@@ -1,984 +0,0 @@
-/**
- * ============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 406d122..624bf19 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,522 +21,891 @@
*/
package org.onap.aai.dbgraphgen;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+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 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.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
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.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
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.exceptions.AAIUnknownObjectException;
+import org.onap.aai.introspection.Version;
import org.onap.aai.parsers.exceptions.AAIIdentityMapParseException;
-import org.onap.aai.query.builder.GraphTraversalBuilder;
-import org.onap.aai.query.builder.QueryBuilder;
-import org.onap.aai.query.builder.TraversalQuery;
-import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.db.EdgeType;
+import org.onap.aai.serialization.db.EdgeRules;
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 java.util.*;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
-@RunWith(MockitoJUnitRunner.class)
public class ModelBasedProcessingTest {
- @Mock private static TransactionalGraphEngine dbEngine;
+ 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;
private static Loader loader;
- @Mock private static DBSerializer serializer;
- @Mock private static TransactionalGraphEngine.Admin admin;
- ModelBasedProcessing mockProcessor;
- @Mock
- private DbMethHelper dbMethHelper;
-
+ EdgeRules rules;
+
+ ModelBasedProcessing modelBasedProcessor;
+
+ GraphTraversalSource source;
+
+ Graph graph;
+
+ Vertex model;
+ Vertex modelVersion;
+ Vertex modelElement;
+ Vertex constrainedElementSet;
+ Vertex namedQueryElement;
+ Vertex linkagePoints;
+ Vertex namedQuery;
+
@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);
-
+ public void init() throws AAIException {
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 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);
+ 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);
}
-
- @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");
-
-
+
+ @Test
+ public void testGetStartNodesAndModVersionIds_ModelInId() throws AAIException {
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,"");
+ 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(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");
-
-
+ @Test
+ public void testGetStartNodesAndModVersionIds_ModelName() throws AAIException {
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,"");
+ 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);
+ }
+
+ @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 {
+ 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);
+ }
+
+ @Test(expected=AAIException.class)
+ public void testQueryByModel_Timed() 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.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 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);
+ 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 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);
+ public void testShowResultSet_NullVertex() {
+ ResultSet rs = getResultSet();
+ rs.setVert(null);
+ modelBasedProcessor.showResultSet(rs, 1);
}
-
- @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
+ public void testShowResultSet_NonEmptyOverrideHash() {
+ ResultSet rs = getResultSet();
+ modelBasedProcessor.showResultSet(rs, 2);
}
-
- //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 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;
}
-
- //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 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<>());
}
-
- //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 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(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 testCollapseForDoNotOutput_FlagTrue() throws AAIException{
+
+ ResultSet rs = getResultSet();
+ List<ResultSet> subResultSet = new ArrayList<>();
+ subResultSet.add(getResultSet());
+ rs.setSubResultSet(subResultSet);
+ rs.setDoNotOutputFlag("true");
+ modelBasedProcessor.collapseForDoNotOutput(rs);
}
-
- //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 testCollapseForDoNotOutput_FlagFalse() throws AAIException{
+
+ ResultSet rs = getResultSet();
+ List<ResultSet> subResultSet = new ArrayList<>();
+ subResultSet.add(getResultSet());
+ rs.setSubResultSet(subResultSet);
+ rs.setDoNotOutputFlag("false");
+ modelBasedProcessor.collapseForDoNotOutput(rs);
}
-
- //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 testMakeSureItsAnArrayList() {
+ String listString = getArrayListAsString();
+ modelBasedProcessor.makeSureItsAnArrayList(listString);
}
-
- @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);
-
-
+
+ private String getArrayListAsString() {
+ List<String> strList = new ArrayList<>();
+ strList.add("1");
+ strList.add("2");
+ strList.add("3");
+ String listString = strList.toString();
+ return listString;
}
- @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
+ 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 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 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 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 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 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 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 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 testGetNextStepElementsFromSet_NullVertex() throws AAIException{
+ modelBasedProcessor.getNextStepElementsFromSet(null);
}
-
- @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
+ 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 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 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(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
+ 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 getNamedQueryExtraDataLookupTest() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",null,vertex,
- "");
+
+ @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 getNamedQueryExtraDataLookupTest1() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",vertex,null,
- "");
+
+ @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);
+ }
+
+ @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");
}
- @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);
-
+ @Test(expected=AAIException.class)
+ public void testCheck4EdgeRule_InvalidNodeB() throws AAIException {
+ modelBasedProcessor.check4EdgeRule("model-ver", "model-version1");
+ }
+
+ @Test(expected=AAIException.class)
+ public void testCheck4EdgeRule_InvalidEdge() throws AAIException {
+ modelBasedProcessor.check4EdgeRule("model-ver", "named-query");
+ }
+
+ @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);
+ }
+
+ @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");
+ }
+
+ @Test
+ public void testGetModelThatNqElementRepresents() throws AAIException {
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
+ modelBasedProcessor.getModelThatNqElementRepresents(namedQueryElement, "");
+ }
+
+ @Test
+ public void testGetModelVerThatElementRepresents() throws AAIException{
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
+ modelBasedProcessor.getModelVerThatElementRepresents(modelElement, "");
+ }
+
+ @Test
+ public void testGetModelTypeFromModel() throws AAIException {
+ Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
+ Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(source);
+ modelBasedProcessor.getModelTypeFromModel(model, "");
+ }
+
+ @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
+ 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=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
+ public void testSecondConstructor() {
+ ModelBasedProcessing mdp = new ModelBasedProcessing();
+ }
+
+ @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=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 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=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 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=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 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
+ 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);
}
+
}