From 428dc0cd0ee1f847ea6f49b5a760926566d5c184 Mon Sep 17 00:00:00 2001 From: Dmitry Puzikov Date: Thu, 19 Mar 2020 09:18:59 +0100 Subject: Fix unit tests Add asserts where required, fix tiny issues. Change-Id: Ie88a39642fd574745d9fa1f0eeee301ff8e19e23 Issue-ID: SDC-2838 Signed-off-by: Dmitry Puzikov --- .../merge/instance/ComponentInstanceArtifactsMergeTest.java | 6 +++--- .../instance/ComponentInstanceCapabilitiesPropertiesMergeTest.java | 6 ++++-- .../merge/instance/ComponentInstanceHeatEnvMergeTest.java | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'catalog-be') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java index 07b2ca6135..06b06b08ad 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java @@ -79,7 +79,7 @@ public class ComponentInstanceArtifactsMergeTest { .getComponentInstanceDeploymentArtifactsTimeOut(); assertThat(originalComponentDeploymentArtifactsCreatedOnTheInstance.size()).isEqualTo(1); assertThat(componentInstanceDeploymentArtifactsTimeOut.size()).isEqualTo(3); - assert (originalComponentDeploymentArtifactsCreatedOnTheInstance.containsKey("artifactTwo")); + assertThat(originalComponentDeploymentArtifactsCreatedOnTheInstance.containsKey("artifactTwo")).isTrue(); } @Test @@ -141,8 +141,8 @@ public class ComponentInstanceArtifactsMergeTest { when(artifactsBusinessLogicMock.updateResourceInstanceArtifactNoContent(Mockito.anyString(), Mockito.any(Component.class), Mockito.any(User.class), Mockito.any(Map.class), Mockito.any(ArtifactOperationInfo.class), Mockito.any(ArtifactDefinition.class))).thenReturn(left); - testInstance.mergeDataAfterCreate(user, dataForMergeHolder, originComponent, "mock"); - + Component result = testInstance.mergeDataAfterCreate(user, dataForMergeHolder, originComponent, "mock"); + assertThat(result.getDeploymentArtifacts()).isEqualTo(originComponent.getDeploymentArtifacts()); } private Map buildDeploymentArtifacts() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabilitiesPropertiesMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabilitiesPropertiesMergeTest.java index d3bc590b42..3e64e52bad 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabilitiesPropertiesMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabilitiesPropertiesMergeTest.java @@ -42,7 +42,7 @@ import java.util.List; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) @@ -78,7 +78,7 @@ public class ComponentInstanceCapabilitiesPropertiesMergeTest { when(capabilitiesPropertiesMergeBL.mergeComponentInstanceCapabilities(currentComponent, origInstanceNode, "instId", origInstanceCapabilities)) .thenReturn(ActionStatus.OK); Component mergeResult = testInstance.mergeDataAfterCreate(new User(), mergeHolder, currentComponent, "instId"); - assertTrue(mergeResult != null); + assertThat(mergeResult).isNotNull(); } @Test(expected = ComponentException.class) @@ -96,5 +96,7 @@ public class ComponentInstanceCapabilitiesPropertiesMergeTest { ComponentInstance currentResourceInstance = new ComponentInstance(); Component originComponent = new Resource(); testInstance.saveDataBeforeMerge(dataHolder, containerComponent, currentResourceInstance, originComponent); + assertThat(dataHolder.getOrigInstanceCapabilities().size()).isEqualTo(originComponent.getCapabilities().size()); + assertThat(dataHolder.getOrigInstanceNode()).isEqualTo(originComponent); } } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java index f5317bba6e..5f70d9d01f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java @@ -34,6 +34,7 @@ import org.openecomp.sdc.be.components.utils.ComponentInstanceBuilder; import org.openecomp.sdc.be.components.utils.ResourceBuilder; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; @@ -45,6 +46,7 @@ import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.when; @@ -80,7 +82,8 @@ public class ComponentInstanceHeatEnvMergeTest { when(heatEnvArtifactsMergeBusinessLogicMock.mergeInstanceHeatEnvArtifacts(dataHolder.getOrigComponentInstanceHeatEnvArtifacts(), resource.safeGetComponentInstanceHeatArtifacts(instanceId))) .thenReturn(mergedArtifacts); expectMergedArtifactsToBePersisted(mergedArtifacts, instanceId, resource); - testInstance.mergeDataAfterCreate(USER, dataHolder, resource, instanceId); + Component result = testInstance.mergeDataAfterCreate(USER, dataHolder, resource, instanceId); + assertThat(result.getDeploymentArtifacts()).isEqualTo(resource.getDeploymentArtifacts()); } private void expectMergedArtifactsToBePersisted(List mergedArtifacts, String instanceId, Resource resource) { -- cgit 1.2.3-korg