Fix unit tests
Add asserts where required, fix tiny issues.
Change-Id: Ie88a39642fd574745d9fa1f0eeee301ff8e19e23
Issue-ID: SDC-2838
Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
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 07b2ca6..06b06b0 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 @@
.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 @@
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<String, ArtifactDefinition> 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 d3bc590..3e64e52 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 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 @@
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 @@
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 f5317bb..5f70d9d 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.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.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 @@
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<ArtifactDefinition> mergedArtifacts, String instanceId, Resource resource) {