From c8e1fa30e88ff067e1beeb61e4bee062f5f68b83 Mon Sep 17 00:00:00 2001 From: "isaac.manuelraj" Date: Wed, 28 Nov 2018 17:47:11 +0530 Subject: Add new test cases on existing class. Added new test cases on top of existing test classes. Issue-ID: SDC-1774 Change-Id: I2025ea57ab61df6955eed7b409e720583a8bdcff Signed-off-by: isaac.manuelraj --- .../impl/ComponentInstanceOperationTest.java | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'catalog-model/src/test') diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java index 70e866b5cd..a19f188ce1 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java @@ -39,11 +39,21 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.dao.titan.TitanGenericDao; +import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; +import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; +import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentInstanceInput; +import org.openecomp.sdc.be.model.GroupInstance; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; +import org.openecomp.sdc.be.resources.data.ComponentInstanceData; + +import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) @@ -81,4 +91,62 @@ public class ComponentInstanceOperationTest { result = componentInstanceOperation.updateCustomizationUUID(componentInstanceId); assertEquals(StorageOperationStatus.OK, result); } + + @Test + public void testupdateComponentInstanceModificationTimeAndCustomizationUuidOnGraph_CatchException() throws Exception { + ComponentInstance componentInstance = new ComponentInstance(); + GroupInstance groupInstance=new GroupInstance(); + groupInstance.setCreationTime(23234234234L); + groupInstance.setCustomizationUUID("CUSTUUID0.1"); + groupInstance.setGroupUid("GRP0.1"); + groupInstance.setGroupUUID("GRPU0.1"); + groupInstance.setGroupName("GRP1"); + List gilist = new ArrayList(); + gilist.add(groupInstance); + componentInstance.setUniqueId("INST0.1"); + componentInstance.setComponentUid("RES0.1"); + componentInstance.setGroupInstances(gilist); + Either result = componentInstanceOperation.updateComponentInstanceModificationTimeAndCustomizationUuidOnGraph(componentInstance, NodeTypeEnum.Component,234234545L,false); + assertEquals(StorageOperationStatus.GENERAL_ERROR, result.right().value()); + } + + @Test + public void testupdateComponentInstanceModificationTimeAndCustomizationUuidOnGraph_GENERAL_ERROR() throws Exception { + ComponentInstance componentInstance = new ComponentInstance(); + GroupInstance groupInstance=new GroupInstance(); + groupInstance.setCreationTime(23234234234L); + groupInstance.setCustomizationUUID("CUSTUUID0.1"); + groupInstance.setGroupUid("GRP0.1"); + groupInstance.setGroupUUID("GRPU0.1"); + groupInstance.setGroupName("GRP1"); + List gilist = new ArrayList(); + gilist.add(groupInstance); + componentInstance.setUniqueId("INST0.1"); + componentInstance.setComponentUid("RES0.1"); + componentInstance.setGroupInstances(gilist); + when(titanGenericDao.updateNode(anyObject(),eq(ComponentInstanceData.class))).thenReturn(Either.right(TitanOperationStatus.GENERAL_ERROR)); + Either result = componentInstanceOperation.updateComponentInstanceModificationTimeAndCustomizationUuidOnGraph(componentInstance, NodeTypeEnum.Component,234234545L,false); + assertEquals(StorageOperationStatus.GENERAL_ERROR, result.right().value()); + } + + @Test + public void testupdateComponentInstanceModificationTimeAndCustomizationUuidOnGraph() throws Exception { + ComponentInstance componentInstance = new ComponentInstance(); + GroupInstance groupInstance=new GroupInstance(); + groupInstance.setCreationTime(23234234234L); + groupInstance.setCustomizationUUID("CUSTUUID0.1"); + groupInstance.setGroupUid("GRP0.1"); + groupInstance.setGroupUUID("GRPU0.1"); + groupInstance.setGroupName("GRP1"); + List gilist = new ArrayList(); + gilist.add(groupInstance); + componentInstance.setUniqueId("INST0.1"); + componentInstance.setComponentUid("RES0.1"); + componentInstance.setGroupInstances(gilist); + ComponentInstanceData componentInstanceData = new ComponentInstanceData(); + when(titanGenericDao.updateNode(anyObject(),eq(ComponentInstanceData.class))).thenReturn(Either.left(componentInstanceData)); + Either result = componentInstanceOperation.updateComponentInstanceModificationTimeAndCustomizationUuidOnGraph(componentInstance, NodeTypeEnum.Component,234234545L,false); + assertEquals(componentInstanceData, result.left().value()); + } + } -- cgit 1.2.3-korg