diff options
Diffstat (limited to 'catalog-model/src/test')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java | 27 |
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"; |