summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSindhuri.A <arcot.sindhuri@huawei.com>2018-11-09 22:40:50 +0530
committerTal Gitelman <tal.gitelman@att.com>2018-11-12 13:41:14 +0000
commitc52c3072387ba5caec0b8ca5d58b429a6e39b798 (patch)
tree98483478869cfed3bd950d4d77fd4a5563f83ce9
parent01c427f1a30ecbcee63fabbee4bc0877a9aec53b (diff)
UT-ToscaOperationFacade 4
UT for catalog be ToscaOperationFacade class Issue-ID: SDC-1775 Change-Id: I9d42dfe6d6a2997e2d9f96d0fdd0f617a0e2cc3c Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
index 85019e6f1b..b40f5d1cb8 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
@@ -41,6 +41,7 @@ import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
@@ -53,6 +54,7 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.PolicyDefinition;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.NodeType;
import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
@@ -89,6 +91,9 @@ public class ToscaOperationFacadeTest {
@Mock
private TopologyTemplateOperation topologyTemplateOperationMock;
+ @Mock
+ private NodeTypeOperation nodeTypeOperation;
+
@Before
public void setUp() throws Exception {
testInstance = new ToscaOperationFacade();
@@ -313,6 +318,28 @@ public class ToscaOperationFacadeTest {
assertEquals(false, result.left().value());
}
+ @Test
+ public void testOverrideComponent() {
+ Either<Resource, StorageOperationStatus> result;
+ Resource resource = new Resource();
+ String id = "id";
+ resource.setUniqueId(id);
+ GraphVertex graphVertex = getTopologyTemplateVertex();
+ graphVertex.setLabel(VertexTypeEnum.TOPOLOGY_TEMPLATE);
+ NodeType nodeType = new NodeType();
+ nodeType.setComponentType(ComponentTypeEnum.RESOURCE);
+ ToscaElement toscaElement = new TopologyTemplate();
+ toscaElement.setComponentType(ComponentTypeEnum.SERVICE);
+ when(titanDaoMock.getVertexById(id, JsonParseFlagEnum.NoParse)).thenReturn(Either.left(graphVertex));
+ when(titanDaoMock.getParentVertex(graphVertex, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse)).thenReturn(Either.left(graphVertex));
+ when(topologyTemplateOperationMock.deleteToscaElement(graphVertex)).thenReturn(Either.left(toscaElement));
+ when(nodeTypeOperation.createToscaElement(any(ToscaElement.class))).thenReturn(Either.left(nodeType));
+ when(titanDaoMock.getVertexById(null, JsonParseFlagEnum.NoParse)).thenReturn(Either.left(graphVertex));
+ when(titanDaoMock.createEdge(graphVertex, graphVertex, EdgeLabelEnum.VERSION, null)).thenReturn(TitanOperationStatus.OK);
+ result = testInstance.overrideComponent(resource, resource);
+ assertTrue(result.isLeft());
+ }
+
private Either<PolicyDefinition, StorageOperationStatus> associatePolicyToComponentWithStatus(StorageOperationStatus status) {
PolicyDefinition policy = new PolicyDefinition();
String componentId = "componentId";