From c52c3072387ba5caec0b8ca5d58b429a6e39b798 Mon Sep 17 00:00:00 2001 From: "Sindhuri.A" Date: Fri, 9 Nov 2018 22:40:50 +0530 Subject: UT-ToscaOperationFacade 4 UT for catalog be ToscaOperationFacade class Issue-ID: SDC-1775 Change-Id: I9d42dfe6d6a2997e2d9f96d0fdd0f617a0e2cc3c Signed-off-by: Sindhuri.A --- .../operations/ToscaOperationFacadeTest.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'catalog-model/src') 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 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 associatePolicyToComponentWithStatus(StorageOperationStatus status) { PolicyDefinition policy = new PolicyDefinition(); String componentId = "componentId"; -- cgit 1.2.3-korg