aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java68
1 files changed, 68 insertions, 0 deletions
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<GroupInstance>();
+ gilist.add(groupInstance);
+ componentInstance.setUniqueId("INST0.1");
+ componentInstance.setComponentUid("RES0.1");
+ componentInstance.setGroupInstances(gilist);
+ Either<ComponentInstanceData, StorageOperationStatus> 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<GroupInstance>();
+ 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<ComponentInstanceData, StorageOperationStatus> 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<GroupInstance>();
+ 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<ComponentInstanceData, StorageOperationStatus> result = componentInstanceOperation.updateComponentInstanceModificationTimeAndCustomizationUuidOnGraph(componentInstance, NodeTypeEnum.Component,234234545L,false);
+ assertEquals(componentInstanceData, result.left().value());
+ }
+
}