diff options
author | vasraz <vasyl.razinkov@est.tech> | 2022-12-24 00:57:54 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-01-03 14:29:22 +0000 |
commit | 5b1a92cea1fb437c236a77468f3e8e351e25a990 (patch) | |
tree | 0df24473b25236a646a094cfcd18ede5c61fc1e1 /catalog-model | |
parent | 5357edd8fb443613f4be4e8a30b03f2a7134e61d (diff) |
Upgrade testing frameworks to latest not-vulnerable versions
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: Ie68290a79d075132c73e6cc9e82b9dbda92fbe8c
Issue-ID: SDC-4313
Diffstat (limited to 'catalog-model')
2 files changed, 61 insertions, 58 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/PolicyOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/PolicyOperationTest.java index 1171a88340..7986e59bb5 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/PolicyOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/PolicyOperationTest.java @@ -44,7 +44,7 @@ import java.util.Collections; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) @@ -87,7 +87,7 @@ public class PolicyOperationTest { JanusGraphOperationStatus.NOT_FOUND)); StorageOperationStatus storageOperationStatus = testInstance.updatePolicyProperties(component, POLICY_ID, Collections.emptyList()); assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.NOT_FOUND); - verifyZeroInteractions(topologyTemplateOperation); + verifyNoInteractions(topologyTemplateOperation); } @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 6ef4a61fcd..c970987ce5 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 @@ -29,8 +29,16 @@ */ package org.openecomp.sdc.be.model.operations.impl; -import org.janusgraph.core.JanusGraphVertex; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + import fj.data.Either; +import java.util.ArrayList; +import java.util.List; +import org.janusgraph.core.JanusGraphVertex; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -47,56 +55,48 @@ 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) public class ComponentInstanceOperationTest { - @InjectMocks - private ComponentInstanceOperation componentInstanceOperation; - - @Mock - protected HealingJanusGraphGenericDao janusGraphGenericDao; - - - @Test - public void testSetJanusGraphGenericDao() { - componentInstanceOperation.setJanusGraphGenericDao(janusGraphGenericDao); - } - - - @Test - public void testUpdateInputValueInResourceInstance() { - ComponentInstanceInput input = null; - String resourceInstanceId = ""; - boolean b = false; - Either<ComponentInstanceInput, StorageOperationStatus> result; - - result = componentInstanceOperation.updateInputValueInResourceInstance(input, resourceInstanceId, b); - assertNull(result); - } - - @Test - public void testUpdateCustomizationUUID() { - StorageOperationStatus result; - String componentInstanceId = "instanceId"; - JanusGraphVertex janusGraphVertex = Mockito.mock(JanusGraphVertex.class); - when(janusGraphGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(),componentInstanceId)).thenReturn(Either.left(janusGraphVertex)); - result = componentInstanceOperation.updateCustomizationUUID(componentInstanceId); - assertEquals(StorageOperationStatus.OK, result); - } - - @Test - public void testupdateComponentInstanceModificationTimeAndCustomizationUuidOnGraph_CatchException() throws Exception { + @InjectMocks + private ComponentInstanceOperation componentInstanceOperation; + + @Mock + protected HealingJanusGraphGenericDao janusGraphGenericDao; + + + @Test + public void testSetJanusGraphGenericDao() { + componentInstanceOperation.setJanusGraphGenericDao(janusGraphGenericDao); + } + + + @Test + public void testUpdateInputValueInResourceInstance() { + ComponentInstanceInput input = null; + String resourceInstanceId = ""; + boolean b = false; + Either<ComponentInstanceInput, StorageOperationStatus> result; + + result = componentInstanceOperation.updateInputValueInResourceInstance(input, resourceInstanceId, b); + assertNull(result); + } + + @Test + public void testUpdateCustomizationUUID() { + StorageOperationStatus result; + String componentInstanceId = "instanceId"; + JanusGraphVertex janusGraphVertex = Mockito.mock(JanusGraphVertex.class); + when(janusGraphGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), componentInstanceId)).thenReturn( + Either.left(janusGraphVertex)); + result = componentInstanceOperation.updateCustomizationUUID(componentInstanceId); + assertEquals(StorageOperationStatus.OK, result); + } + + @Test + public void testupdateComponentInstanceModificationTimeAndCustomizationUuidOnGraph_CatchException() throws Exception { ComponentInstance componentInstance = new ComponentInstance(); - GroupInstance groupInstance=new GroupInstance(); + GroupInstance groupInstance = new GroupInstance(); groupInstance.setCreationTime(23234234234L); groupInstance.setCustomizationUUID("CUSTUUID0.1"); groupInstance.setGroupUid("GRP0.1"); @@ -107,14 +107,15 @@ public class ComponentInstanceOperationTest { componentInstance.setUniqueId("INST0.1"); componentInstance.setComponentUid("RES0.1"); componentInstance.setGroupInstances(gilist); - Either<ComponentInstanceData, StorageOperationStatus> result = componentInstanceOperation.updateComponentInstanceModificationTimeAndCustomizationUuidOnGraph(componentInstance, NodeTypeEnum.Component,234234545L,false); + 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 groupInstance = new GroupInstance(); groupInstance.setCreationTime(23234234234L); groupInstance.setCustomizationUUID("CUSTUUID0.1"); groupInstance.setGroupUid("GRP0.1"); @@ -125,16 +126,17 @@ public class ComponentInstanceOperationTest { componentInstance.setUniqueId("INST0.1"); componentInstance.setComponentUid("RES0.1"); componentInstance.setGroupInstances(gilist); - when(janusGraphGenericDao.updateNode(anyObject(),eq(ComponentInstanceData.class))).thenReturn(Either.right( + when(janusGraphGenericDao.updateNode(any(), eq(ComponentInstanceData.class))).thenReturn(Either.right( JanusGraphOperationStatus.GENERAL_ERROR)); - Either<ComponentInstanceData, StorageOperationStatus> result = componentInstanceOperation.updateComponentInstanceModificationTimeAndCustomizationUuidOnGraph(componentInstance, NodeTypeEnum.Component,234234545L,false); + 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 groupInstance = new GroupInstance(); groupInstance.setCreationTime(23234234234L); groupInstance.setCustomizationUUID("CUSTUUID0.1"); groupInstance.setGroupUid("GRP0.1"); @@ -146,9 +148,10 @@ public class ComponentInstanceOperationTest { componentInstance.setComponentUid("RES0.1"); componentInstance.setGroupInstances(gilist); ComponentInstanceData componentInstanceData = new ComponentInstanceData(); - when(janusGraphGenericDao.updateNode(anyObject(),eq(ComponentInstanceData.class))).thenReturn(Either.left(componentInstanceData)); - Either<ComponentInstanceData, StorageOperationStatus> result = componentInstanceOperation.updateComponentInstanceModificationTimeAndCustomizationUuidOnGraph(componentInstance, NodeTypeEnum.Component,234234545L,false); + when(janusGraphGenericDao.updateNode(any(), eq(ComponentInstanceData.class))).thenReturn(Either.left(componentInstanceData)); + Either<ComponentInstanceData, StorageOperationStatus> result = componentInstanceOperation.updateComponentInstanceModificationTimeAndCustomizationUuidOnGraph( + componentInstance, NodeTypeEnum.Component, 234234545L, false); assertEquals(componentInstanceData, result.left().value()); } - + } |