aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java12
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java176
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CommonImportManagerTest.java35
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java103
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java33
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java20
7 files changed, 253 insertions, 134 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
index c01f5eaccc..e401df3920 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
@@ -73,8 +73,6 @@ import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import org.openecomp.sdc.common.impl.ExternalConfiguration;
-import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
import java.io.IOException;
@@ -84,7 +82,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
@@ -537,8 +535,9 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{
, any(String.class), eq(true))).thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK);
when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat());
- artifactBL.generateAndSaveHeatEnvArtifact(artifactDefinition, String.valueOf(PAYLOAD), ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME,
+ Either<ArtifactDefinition, ResponseFormat> result = artifactBL.generateAndSaveHeatEnvArtifact(artifactDefinition, String.valueOf(PAYLOAD), ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME,
USER, INSTANCE_ID, true, true);
+ assertThat(result.isLeft()).isTrue();
}
private ArtifactsBusinessLogic getArtifactsBusinessLogic() {
@@ -567,9 +566,10 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{
, any(String.class), eq(true))).thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK);
when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat());
- artifactBL.generateAndSaveHeatEnvArtifact(artifactDefinition, String.valueOf(PAYLOAD), ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME,
+ Either<ArtifactDefinition, ResponseFormat> result = artifactBL.generateAndSaveHeatEnvArtifact(artifactDefinition, String.valueOf(PAYLOAD), ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME,
USER, INSTANCE_ID, true, false);
verify(janusGraphDao, times(1)).commit();
+ assertThat(result.isLeft()).isTrue();
}
@Test
@@ -597,7 +597,7 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{
result = artifactBL.handleDelete("parentId", "artifactId", USER, AuditingActionEnum.ARTIFACT_DELETE,
ComponentTypeEnum.RESOURCE, resource,
true, false);
- assertThat(result.isRight());
+ assertThat(result.isRight()).isTrue();
}
private void verifyHeatParam(HeatParameterDefinition heatEnvParam, HeatParameterDefinition heatYamlParam) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
index ab4c662d35..edf561b717 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
@@ -32,6 +32,8 @@ import com.google.gson.JsonElement;
import fj.data.Either;
import mockit.Deencapsulation;
import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Assert;
import org.junit.Before;
@@ -117,8 +119,9 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -148,6 +151,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
private static final String RESOURCE_SUBCATEGORY = "Router";
public static final String RESOURCE_CATEGORY = "Network Layer 2-3/Router";
+ private static final String ARTIFACT_PLACEHOLDER_FILE_EXTENSION = "fileExtension";
public static final Resource resource = Mockito.mock(Resource.class);
@InjectMocks
@@ -666,10 +670,10 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
.getConfiguration().getResourceDeploymentArtifacts();
Map<String, ArtifactTypeConfig> componentInstanceDeploymentArtifacts = ConfigurationManager
.getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts();
- assertTrue(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType()));
- assertTrue(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType()));
- assertTrue(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType()));
- assertTrue(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType()));
+ assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue();
+ assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue();
+ assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue();
+ assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue();
}
@Test
@@ -708,8 +712,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
when(toscaOperationFacade.getBySystemName(ComponentTypeEnum.SERVICE, serviceName)).thenReturn(getServiceRes);
byte[] downloadServiceArtifactByNamesRes = artifactBL
.downloadServiceArtifactByNames(serviceName, serviceVersion, artifactName);
- assertTrue(downloadServiceArtifactByNamesRes != null
- && downloadServiceArtifactByNamesRes.length == payload.length);
+ assertThat(downloadServiceArtifactByNamesRes != null
+ && downloadServiceArtifactByNamesRes.length == payload.length).isTrue();
}
@Test
@@ -1521,6 +1525,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
result = Deencapsulation.invoke(testSubject, "validateUserRole",
new Object[]{user, auditingAction, componentId, artifactId, componentType,
operation});
+ assertNull(result);
}
@Test
@@ -1535,8 +1540,23 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "detectAuditingType",
new Object[]{operation, origMd5});
+ assertNotNull(result);
}
+ @Test
+ public void testDetectNoAuditingType() throws Exception {
+ ArtifactsBusinessLogic testSubject;
+ ArtifactsBusinessLogic arb = getTestSubject();
+ ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.LINK);
+ String origMd5 = "";
+ AuditingActionEnum result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "detectAuditingType",
+ new Object[]{operation, origMd5});
+ assertNull(result);
+ }
@Test
public void testCreateEsArtifactData() throws Exception {
@@ -1548,11 +1568,25 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
// default test
testSubject = createTestSubject();
result = testSubject.createEsArtifactData(artifactInfo, artifactPayload);
+ assertNotNull(result);
}
@Test
- public void testIsArtifactMetadataUpdate() throws Exception {
+ public void testIsArtifactMetadataUpdateTrue() throws Exception {
+ ArtifactsBusinessLogic testSubject;
+ AuditingActionEnum auditingActionEnum = AuditingActionEnum.ARTIFACT_METADATA_UPDATE;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "isArtifactMetadataUpdate",
+ new Object[]{auditingActionEnum});
+ assertThat(result).isTrue();
+ }
+
+ @Test
+ public void testIsArtifactMetadataUpdateFalse() throws Exception {
ArtifactsBusinessLogic testSubject;
AuditingActionEnum auditingActionEnum = AuditingActionEnum.ACTIVATE_SERVICE_BY_API;
boolean result;
@@ -1561,24 +1595,38 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "isArtifactMetadataUpdate",
new Object[]{auditingActionEnum});
+ assertThat(result).isFalse();
}
@Test
- public void testIsDeploymentArtifact() throws Exception {
+ public void testIsDeploymentArtifactTrue() throws Exception {
ArtifactsBusinessLogic testSubject;
ArtifactDefinition artifactInfo = buildArtifactPayload();
+ artifactInfo.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
boolean result;
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "isDeploymentArtifact", new Object[]{artifactInfo});
+ assertThat(result).isTrue();
}
+ @Test
+ public void testIsDeploymentArtifactFalse() throws Exception {
+ ArtifactsBusinessLogic testSubject;
+ ArtifactDefinition artifactInfo = buildArtifactPayload(); // artifactGroupType == ArtifactGroupTypeEnum.TOSCA
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "isDeploymentArtifact", new Object[]{artifactInfo});
+ assertThat(result).isFalse();
+ }
@Test
public void testSetArtifactPlaceholderCommonFields() throws Exception {
ArtifactsBusinessLogic testSubject;
- String resourceId = "";
+ String resourceId = ES_ARTIFACT_ID;
ArtifactDefinition artifactInfo = buildArtifactPayload();
@@ -1586,7 +1634,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
Deencapsulation.invoke(testSubject, "setArtifactPlaceholderCommonFields",
resourceId, user, artifactInfo);
-
+ assertEquals(resourceId + "." +ARTIFACT_LABEL, artifactInfo.getUniqueId());
+ assertEquals(user.getFullName(), artifactInfo.getCreatorFullName());
}
@@ -1601,6 +1650,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "createEsHeatEnvArtifactDataFromString",
new Object[]{artifactDefinition, payloadStr});
+ assertThat(result.isLeft()).isTrue();
}
@Test
@@ -1615,7 +1665,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
// test 1
testSubject = createTestSubject();
- testSubject.updateArtifactOnGroupInstance(component, instanceId, prevUUID, artifactInfo, artifactInfo);
+ result = testSubject.updateArtifactOnGroupInstance(component, instanceId, prevUUID, artifactInfo, artifactInfo);
+ assertThat(result.isLeft()).isTrue();
}
@Test
@@ -1628,6 +1679,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "generateHeatEnvPayload",
new Object[]{artifactDefinition});
+ assertThat(result.isEmpty()).isFalse();
}
@@ -1642,6 +1694,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
// default test
testSubject = createTestSubject();
result = testSubject.buildJsonForUpdateArtifact(artifactInfo, artifactGroupType, updatedRequiredArtifacts);
+ assertThat(MapUtils.isNotEmpty(result)).isTrue();
}
@Test
@@ -1664,11 +1717,12 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
artifactId = "";
result = testSubject.buildJsonForUpdateArtifact(artifactId, artifactName, artifactType, artifactGroupType,
label, displayName, description, artifactContent, updatedRequiredArtifacts, heatParameters);
+ assertThat(MapUtils.isNotEmpty(result)).isTrue();
}
@Test
- public void testReplaceCurrHeatValueWithUpdatedValue() throws Exception {
+ public void testNotReplaceCurrHeatValueWithUpdatedValue() throws Exception {
ArtifactsBusinessLogic testSubject;
List<HeatParameterDefinition> currentHeatEnvParams = new ArrayList<>();
List<HeatParameterDefinition> updatedHeatEnvParams = new ArrayList<>();
@@ -1676,7 +1730,33 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
// default test
testSubject = createTestSubject();
- Deencapsulation.invoke(testSubject, "replaceCurrHeatValueWithUpdatedValue", new Object[]{currentHeatEnvParams, updatedHeatEnvParams});
+ boolean result = Deencapsulation.invoke(testSubject, "replaceCurrHeatValueWithUpdatedValue", new Object[]{currentHeatEnvParams, updatedHeatEnvParams});
+ assertThat(result).isFalse();
+ }
+
+
+ @Test
+ public void testReplaceCurrHeatValueWithUpdatedValue() throws Exception {
+ ArtifactsBusinessLogic testSubject;
+ HeatParameterDefinition hpdOrig = new HeatParameterDefinition();
+ hpdOrig.setName("param1");
+ hpdOrig.setCurrentValue("value1");
+
+ HeatParameterDefinition hpdUpd = new HeatParameterDefinition();
+ hpdUpd.setName("param1");
+ hpdUpd.setCurrentValue("value2");
+
+ List<HeatParameterDefinition> currentHeatEnvParams = new ArrayList<>();
+ currentHeatEnvParams.add(hpdOrig);
+
+ List<HeatParameterDefinition> updatedHeatEnvParams = new ArrayList<>();
+ updatedHeatEnvParams.add(hpdUpd);
+
+ // default test
+ testSubject = createTestSubject();
+ boolean result = Deencapsulation.invoke(testSubject, "replaceCurrHeatValueWithUpdatedValue", new Object[]{currentHeatEnvParams, updatedHeatEnvParams});
+ assertThat(result).isTrue();
+ assertEquals(hpdUpd.getCurrentValue(), hpdOrig.getCurrentValue());
}
@@ -1690,44 +1770,85 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
// default test
testSubject = createTestSubject();
result = testSubject.extractArtifactDefinition(eitherArtifact);
+ assertNotNull(result);
+ assertEquals(artifactDefinition, result);
}
@Test
public void testSetHeatCurrentValuesOnHeatEnvDefaultValues() throws Exception {
ArtifactsBusinessLogic testSubject;
- ArtifactDefinition artifact = null;
- ArtifactDefinition artifactInfo = buildArtifactPayload();
+ ArtifactDefinition artifact = buildArtifactPayload();
+ ArtifactDefinition artifactInfo = new ArtifactDefinition();
+
+ HeatParameterDefinition hpdOrig = new HeatParameterDefinition();
+ hpdOrig.setName("param1");
+ hpdOrig.setCurrentValue("value1");
+ List<HeatParameterDefinition> currentHeatEnvParams = new ArrayList<>();
+ currentHeatEnvParams.add(hpdOrig);
+ artifact.setListHeatParameters(currentHeatEnvParams);
// default test
testSubject = createTestSubject();
Deencapsulation.invoke(testSubject, "setHeatCurrentValuesOnHeatEnvDefaultValues",
- artifactInfo, artifactInfo);
+ artifact, artifactInfo);
+
+ assertNotEquals(artifact, artifactInfo);
+ assertEquals(1, artifact.getListHeatParameters().size());
+ assertEquals(1, artifactInfo.getListHeatParameters().size());
+
+ String hpdOrigCurrValue = artifact.getListHeatParameters().get(0).getCurrentValue();
+ String hpdNewDefaultValue = artifactInfo.getListHeatParameters().get(0).getDefaultValue();
+
+ assertEquals(hpdOrigCurrValue, hpdNewDefaultValue);
}
@Test
- public void testBuildHeatEnvFileName() throws Exception {
+ public void testBuildHeatEnvFileNameArtifactNameNotNull() throws Exception {
+ String heatEnvExt = "zip";
ArtifactsBusinessLogic testSubject;
- ArtifactDefinition heatArtifact = null;
- ArtifactDefinition artifactInfo = buildArtifactPayload();
+ ArtifactDefinition heatArtifact = buildArtifactPayload();
+ ArtifactDefinition heatEnvArtifact = new ArtifactDefinition();
Map<String, Object> placeHolderData = new HashMap<>();
+ placeHolderData.put(ARTIFACT_PLACEHOLDER_FILE_EXTENSION, heatEnvExt);
+ String artName = ARTIFACT_NAME.split("\\.")[0];
+
+ // default test
+ testSubject = createTestSubject();
+ Deencapsulation.invoke(testSubject, "buildHeatEnvFileName", new Object[]{heatArtifact, heatEnvArtifact, placeHolderData});
+ assertThat(heatEnvArtifact.getArtifactName().startsWith(artName)).isTrue();
+ assertThat(heatEnvArtifact.getArtifactName().endsWith(heatEnvExt)).isTrue();
+ }
+ @Test
+ public void testBuildHeatEnvFileNameArtifactNameIsNull() throws Exception {
+ String heatEnvExt = "zip";
+ ArtifactsBusinessLogic testSubject;
+ ArtifactDefinition heatArtifact = buildArtifactPayload();
+ heatArtifact.setArtifactName(null);
+ ArtifactDefinition heatEnvArtifact = new ArtifactDefinition();
+ Map<String, Object> placeHolderData = new HashMap<>();
+ placeHolderData.put(ARTIFACT_PLACEHOLDER_FILE_EXTENSION, heatEnvExt);
// default test
testSubject = createTestSubject();
- Deencapsulation.invoke(testSubject, "buildHeatEnvFileName", new Object[]{artifactInfo, artifactInfo, placeHolderData});
+ Deencapsulation.invoke(testSubject, "buildHeatEnvFileName", new Object[]{heatArtifact, heatEnvArtifact, placeHolderData});
+ assertThat(heatEnvArtifact.getArtifactName().startsWith(ARTIFACT_LABEL)).isTrue();
+ assertThat(heatEnvArtifact.getArtifactName().endsWith(heatEnvExt)).isTrue();
}
@Test
public void testHandleEnvArtifactVersion() throws Exception {
ArtifactsBusinessLogic testSubject;
+ String existingVersion = "1.0";
ArtifactDefinition artifactInfo = buildArtifactPayload();
Map<String, String> existingEnvVersions = new HashMap<>();
-
+ existingEnvVersions.put(artifactInfo.getArtifactName(), existingVersion);
// test 1
testSubject = createTestSubject();
Deencapsulation.invoke(testSubject, "handleEnvArtifactVersion", artifactInfo, existingEnvVersions);
+ assertEquals(existingVersion, artifactInfo.getArtifactVersion());
}
@Test
@@ -1747,16 +1868,19 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
result = testSubject.handleArtifactsForInnerVfcComponent(artifactsToHandle, component, user,
vfcsNewCreatedArtifacts, operation, shouldLock, inTransaction);
+
+ assertThat(CollectionUtils.isEmpty(result)).isTrue();
}
@Test
public void testSetNodeTemplateOperation() throws Exception {
ArtifactsBusinessLogic testSubject;
- NodeTemplateOperation nodeTemplateOperation = null;
+ NodeTemplateOperation nodeTemplateOperation = new NodeTemplateOperation();
// default test
testSubject = createTestSubject();
- Deencapsulation.invoke(testSubject, "setNodeTemplateOperation", NodeTemplateOperation.class);
+ Deencapsulation.invoke(testSubject, "setNodeTemplateOperation", nodeTemplateOperation);
+ assertEquals(Deencapsulation.getField(testSubject, "nodeTemplateOperation"), nodeTemplateOperation);
}
@Test
@@ -1841,7 +1965,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
, operationInfo, artifactDefinition.getUniqueId(), artifactDefinition, requestMd5, "data", "iuuid",
null, componentId, "resources");
- assertTrue(result.isLeft());
+ assertThat(result.isLeft()).isTrue();
ArtifactDefinition leftValue = result.left().value();
assertEquals(artifactDefinition.getArtifactName(), leftValue.getArtifactName());
}
@@ -2020,7 +2144,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
componentInstance.setDeploymentArtifacts(deploymentArtifacts);
List<ArtifactDefinition> result = artifactBL.getDeploymentArtifacts(resource, parentType, ciId);
- Assert.assertTrue(result.size() == 1);
+ assertThat(result.size() == 1).isTrue();
Assert.assertEquals(artifactDefinition.getArtifactName(), result.get(0).getArtifactName());
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CommonImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CommonImportManagerTest.java
index 429d8f848d..0527f372d4 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CommonImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CommonImportManagerTest.java
@@ -43,6 +43,7 @@ import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -87,16 +88,17 @@ public class CommonImportManagerTest {
ResponseFormat responseFormat = new ResponseFormat();
responseFormat.setServiceException(new ServiceException());
when(validator.apply(type1)).thenReturn(Either.right(responseFormat));
-
-
- commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
+
+
+ Either<List<ImmutablePair<Object, Boolean>>, ResponseFormat> result = commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
verify(elementAdder, never()).apply(Mockito.any());
verify(elementUpgrader, never()).apply(Mockito.any(), Mockito.any());
verify(janusGraphGenericDao).rollback();
+ assertThat(result.isRight()).isTrue();
}
- @Test
+ @Test(expected = RuntimeException.class)
public void testCreateElementTypesByDao_RuntTimeExceptionInValidation() {
Object type1 = new Object();
List<Object> elementTypesToCreate = Arrays.asList(type1);
@@ -105,11 +107,7 @@ public class CommonImportManagerTest {
when(elementInfoGetter.apply(type1)).thenReturn(elementInfo);
when(validator.apply(type1)).thenThrow(new RuntimeException("Test Exception"));
- try {
- commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
- }
- catch(Exception skip) {
- }
+ commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
verify(elementAdder, never()).apply(Mockito.any());
verify(elementUpgrader, never()).apply(Mockito.any(), Mockito.any());
@@ -130,13 +128,14 @@ public class CommonImportManagerTest {
responseFormat.setServiceException(new ServiceException());
when(componentsUtils.convertFromStorageResponseForCapabilityType(Mockito.any())).thenCallRealMethod();
when(componentsUtils.getResponseFormatByCapabilityType(ActionStatus.INVALID_CONTENT, type1)).thenReturn(responseFormat);
-
-
- commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
+
+
+ Either<List<ImmutablePair<Object, Boolean>>, ResponseFormat> result = commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
verify(elementAdder, never()).apply(Mockito.any());
verify(elementUpgrader, never()).apply(Mockito.any(), Mockito.any());
verify(janusGraphGenericDao).rollback();
+ assertThat(result.isRight()).isTrue();
}
@Test
@@ -156,12 +155,13 @@ public class CommonImportManagerTest {
when(componentsUtils.convertFromStorageResponseForCapabilityType(Mockito.any())).thenCallRealMethod();
when(componentsUtils.getResponseFormatByCapabilityType(ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST, type1)).thenReturn(responseFormat);
-
- commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
+
+ Either<List<ImmutablePair<Object, Boolean>>, ResponseFormat> result = commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
verify(elementAdder).apply(type1);
verify(elementUpgrader, never()).apply(Mockito.any(), Mockito.any());
verify(janusGraphGenericDao).rollback();
+ assertThat(result.isRight()).isTrue();
}
@@ -206,12 +206,13 @@ public class CommonImportManagerTest {
when(componentsUtils.convertFromStorageResponseForCapabilityType(Mockito.any())).thenCallRealMethod();
when(componentsUtils.getResponseFormatByCapabilityType(ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST, type1_1)).thenReturn(responseFormat);
-
- commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
+
+ Either<List<ImmutablePair<Object, Boolean>>, ResponseFormat> result = commonImportManager.createElementTypesByDao(elementTypesToCreate , validator , elementInfoGetter, elementFetcher, elementAdder, elementUpgrader);
verify(elementAdder, never()).apply(Mockito.any());
verify(elementUpgrader).apply(type1_1, type1);
verify(janusGraphGenericDao).rollback();
+ assertThat(result.isRight()).isTrue();
}
@Test
@@ -259,6 +260,4 @@ public class CommonImportManagerTest {
assertEquals(type1_1, result.left().value().get(0).getLeft());
assertEquals(false, result.left().value().get(0).getRight());
}
-
-
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
index 1bbe0fac88..4408b3c1ce 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -22,9 +22,8 @@ package org.openecomp.sdc.be.components.impl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anySet;
@@ -216,11 +215,11 @@ public class ComponentInstanceBusinessLogicTest {
@Test
public void testIsCloudSpecificArtifact() {
- assertTrue(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_1));
- assertTrue(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_2));
- assertTrue(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_3));
- assertFalse(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_4));
- assertFalse(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_5));
+ assertThat(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_1)).isTrue();
+ assertThat(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_2)).isTrue();
+ assertThat(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_3)).isTrue();
+ assertThat(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_4)).isFalse();
+ assertThat(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_5)).isFalse();
}
private void getforwardingPathOnVersionChange() {
@@ -636,7 +635,7 @@ public class ComponentInstanceBusinessLogicTest {
.getRelationById(COMPONENT_ID,
RELATION_ID, USER_ID,
component.getComponentType());
- assertTrue(response.isLeft());
+ assertThat(response.isLeft()).isTrue();
}
private void getServiceRelationByIdUserValidationFailure(Component component) {
@@ -660,7 +659,7 @@ public class ComponentInstanceBusinessLogicTest {
.getRelationById(COMPONENT_ID,
RELATION_ID, USER_ID,
component.getComponentType());
- assertTrue(response.isRight());
+ assertThat(response.isRight()).isTrue();
}
private void stubMethods() {
@@ -768,7 +767,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
componentInstanceBusinessLogic = createTestSubject();
result = componentInstanceBusinessLogic.changeServiceProxyVersion();
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -779,7 +778,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.createServiceProxy();
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -791,7 +790,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.deleteServiceProxy();
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -804,7 +803,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.getComponentInstanceInputsByInputId(component, inputId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -817,7 +816,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.getComponentInstancePropertiesByInputId(component, inputId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -832,7 +831,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.getRelationById(componentId, relationId, userId, componentTypeEnum);
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -845,7 +844,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "validateParent", new Object[]{resource, nodeTemplateId});
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -856,7 +855,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "getComponentType", new Object[]{ComponentTypeEnum.class});
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -871,7 +870,7 @@ public class ComponentInstanceBusinessLogicTest {
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "getNewGroupName",
new Object[]{oldPrefix, newNormailzedPrefix, qualifiedGroupInstanceName});
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -885,7 +884,7 @@ public class ComponentInstanceBusinessLogicTest {
testSubject = createTestSubject();
result = Deencapsulation
.invoke(testSubject, "updateComponentInstanceMetadata", new Object[]{toInstance, toInstance});
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -920,18 +919,18 @@ public class ComponentInstanceBusinessLogicTest {
result = testSubject
.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
componentTypeEnum = null;
result = testSubject
.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
result = testSubject
.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -970,17 +969,17 @@ public class ComponentInstanceBusinessLogicTest {
result = testSubject
.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
componentTypeEnum = null;
result = testSubject
.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
result = testSubject
.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -1003,17 +1002,17 @@ public class ComponentInstanceBusinessLogicTest {
result = testSubject
.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
groupInstanceId, property, userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
componentTypeEnum = null;
result = testSubject
.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
groupInstanceId, property, userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
result = testSubject
.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
groupInstanceId, property, userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -1034,15 +1033,15 @@ public class ComponentInstanceBusinessLogicTest {
testSubject = createTestSubject();
result = testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
componentTypeEnum = null;
result = testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
result = testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -1053,7 +1052,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "getComponentParametersViewForForwardingPath");
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -1066,7 +1065,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "getResourceInstanceById", new Object[]{resource, instanceId});
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -1088,11 +1087,11 @@ public class ComponentInstanceBusinessLogicTest {
testSubject = createTestSubject();
result = testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId,
componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.left(resource));
result = testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId,
componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
}
@Test
@@ -1118,10 +1117,10 @@ public class ComponentInstanceBusinessLogicTest {
result = componentInstanceBusinessLogic
.copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId,
USER_ID);
- Assert.assertNotNull(result);
+ assertNotNull(result);
service.setLastUpdaterUserId(oldLastUpdatedUserId);
- assertThat(result.isRight());
+ assertThat(result.isRight()).isTrue();
}
@Test
@@ -1145,9 +1144,9 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> getComponentRes = Either.left(resource);
result = componentInstanceBusinessLogic
.copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId, USER_ID);
- Assert.assertNotNull(result);
+ assertNotNull(result);
service.setLastUpdaterUserId(oldServiceLastUpdatedUserId);
- assertThat(result.isRight());
+ assertThat(result.isRight()).isTrue();
}
@Test
@@ -1179,7 +1178,7 @@ public class ComponentInstanceBusinessLogicTest {
result = componentInstanceBusinessLogic
.copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId,
USER_ID);
- Assert.assertNotNull(result);
+ assertNotNull(result);
service.setLastUpdaterUserId(oldServiceLastUpdatedUserId);
resource.setLifecycleState(oldResourceLifeCycle);
@@ -1225,12 +1224,12 @@ public class ComponentInstanceBusinessLogicTest {
.getUniqueId(),
toInstance.getUniqueId(), attribute,
USER_ID);
- Assert.assertNotNull(result);
+ assertNotNull(result);
service.setLastUpdaterUserId(oldLastUpdatedUserId);
service.setLifecycleState(oldLifeCycleState);
- assertTrue(result.isLeft());
+ assertThat(result.isLeft()).isTrue();
ComponentInstanceProperty resultProp = result.left().value();
assertEquals(resultProp.getPath().size(), 1);
assertEquals(resultProp.getPath().get(0), toInstance.getUniqueId());
@@ -1254,8 +1253,8 @@ public class ComponentInstanceBusinessLogicTest {
Either<String, ResponseFormat> result = Deencapsulation.invoke(componentInstanceBusinessLogic,
"updateComponentInstanceProperty", containerComponentId, componentInstanceId, property);
- Assert.assertNotNull(result);
- assertTrue(result.isLeft());
+ assertNotNull(result);
+ assertThat(result.isLeft()).isTrue();
}
@Test
@@ -1302,7 +1301,7 @@ public class ComponentInstanceBusinessLogicTest {
result = componentInstanceBusinessLogic
.batchDeleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceIdList,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
assertEquals(deleteErrorMap, result);
} catch (ComponentException e) {
assertEquals(e.getActionStatus().toString(), StorageOperationStatus.GENERAL_ERROR.toString());
@@ -1331,7 +1330,7 @@ public class ComponentInstanceBusinessLogicTest {
result = componentInstanceBusinessLogic
.batchDeleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceIdList,
userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
assertEquals(deleteErrorMap, result);
} catch (ComponentException e) {
assertEquals(e.getActionStatus().toString(), StorageOperationStatus.GENERAL_ERROR.toString());
@@ -1371,7 +1370,7 @@ public class ComponentInstanceBusinessLogicTest {
result = componentInstanceBusinessLogic
.batchDeleteComponentInstance(containerComponentParam, containerComponentId,
componentInstanceIdList, userId);
- Assert.assertNotNull(result);
+ assertNotNull(result);
service.setLastUpdaterUserId(oldLastUpdatedUserId);
service.setLifecycleState(oldLifeCycleState);
@@ -1418,7 +1417,7 @@ public class ComponentInstanceBusinessLogicTest {
try {
result = componentInstanceBusinessLogic
.batchDissociateRIFromRI(componentId, userId, requirementDefList, componentTypeEnum);
- Assert.assertNotNull(result);
+ assertNotNull(result);
assertEquals(new ArrayList<>(), result);
} catch (ComponentException e) {
assertEquals(e.getActionStatus().toString(), StorageOperationStatus.GENERAL_ERROR.toString());
@@ -1457,7 +1456,7 @@ public class ComponentInstanceBusinessLogicTest {
result = componentInstanceBusinessLogic
.batchDissociateRIFromRI(componentId, userId, requirementDefList, componentTypeEnum);
- Assert.assertNotNull(result);
+ assertNotNull(result);
service.setLastUpdaterUserId(oldLastUpdatedUserId);
service.setLifecycleState(oldLifeCycleState);
@@ -1470,8 +1469,8 @@ public class ComponentInstanceBusinessLogicTest {
Optional<ComponentInstanceProperty> propertyCandidate =
getComponentInstanceProperty(PROP_NAME);
- Assert.assertTrue(propertyCandidate.isPresent());
- Assert.assertEquals(propertyCandidate.get().getName(), PROP_NAME);
+ assertThat(propertyCandidate.isPresent()).isTrue();
+ assertEquals(propertyCandidate.get().getName(), PROP_NAME);
}
@Test
@@ -1479,7 +1478,7 @@ public class ComponentInstanceBusinessLogicTest {
Optional<ComponentInstanceProperty> propertyCandidate =
getComponentInstanceProperty(NON_EXIST_NAME);
- Assert.assertEquals(propertyCandidate, Optional.empty());
+ assertEquals(propertyCandidate, Optional.empty());
}
private Optional<ComponentInstanceProperty> getComponentInstanceProperty(String propertyName) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
index aee08af2a8..cd0b1c9656 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
@@ -134,7 +134,7 @@ public class GroupBusinessLogicTest {
groupDefinitions.add(groupDefinition);
when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
result = test.createGroups(component, groupDefinitions, true);
- Assert.assertTrue(result.isRight());
+ assertThat(result.isRight()).isTrue();
}
@Test
@@ -154,7 +154,7 @@ public class GroupBusinessLogicTest {
when(groupsOperation.createGroups(any(Component.class), anyMap())).thenReturn(Either.left(groupDefinitions));
when(groupsOperation.addCalculatedCapabilitiesWithProperties(anyString(), anyMap(), anyMap())).thenReturn(StorageOperationStatus.OK);
result = test.createGroups(component, groupDefinitions, true);
- Assert.assertTrue(result.isLeft());
+ assertThat(result.isLeft()).isTrue();
}
@Test
@@ -171,7 +171,7 @@ public class GroupBusinessLogicTest {
groupDefinitions.add(groupDefinition);
result = test.validateUpdateVfGroupNamesOnGraph(groupDefinitions, component);
- Assert.assertTrue(result.isLeft());
+ assertThat(result.isLeft()).isTrue();
}
@Test
@@ -224,7 +224,7 @@ public class GroupBusinessLogicTest {
when(groupsOperation.addGroups(any(Resource.class), any())).thenReturn(Either.left(groupDefList));
when(groupsOperation.addCalculatedCapabilitiesWithProperties(anyString(), anyMap(), anyMap())).thenReturn(StorageOperationStatus.OK);
result = test.createGroup(componentId, compTypeEnum, grpType, userId);
- assertThat(result.getClass().isInstance(GroupDefinition.class));
+ assertThat(result.getClass()).isAssignableFrom(GroupDefinition.class);
}
private PropertyDefinition buildProperty(String name, String defaultValue, String description) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
index 21b85bcc4e..66e6cd3e81 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
@@ -74,8 +74,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
@@ -182,7 +183,7 @@ public class InputsBusinessLogicTest {
public void getComponentInstanceInputs_ComponentInstanceNotExist() {
when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
Either<List<ComponentInstanceInput>, ResponseFormat> componentInstanceInputs = testInstance.getComponentInstanceInputs(USER_ID, COMPONENT_ID, "nonExisting");
- assertTrue(componentInstanceInputs.isRight());
+ assertThat(componentInstanceInputs.isRight()).isTrue();
verify(componentsUtilsMock).getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND);
}
@@ -218,7 +219,7 @@ public class InputsBusinessLogicTest {
Component component = new Resource();
when(toscaOperationFacadeMock.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(component));
testInstance.getInputs(userId, componentId);
- assertEquals(null, component.getInputs());
+ assertNull(component.getInputs());
}
@Test
@@ -234,7 +235,7 @@ public class InputsBusinessLogicTest {
component.setInputs(listDef);
when(toscaOperationFacadeMock.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(component));
result = testInstance.getComponentInstancePropertiesByInputId(userId, componentId, componentId, componentId);
- assertTrue(result.isLeft());
+ assertThat(result.isLeft()).isTrue();
}
@Test
@@ -252,10 +253,10 @@ public class InputsBusinessLogicTest {
Either<List<InputDefinition>, ResponseFormat> declaredPropertiesEither =
testInstance.declareProperties(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, componentInstInputsMap);
- assertTrue(declaredPropertiesEither.isLeft());
+ assertThat(declaredPropertiesEither.isLeft()).isTrue();
List<InputDefinition> declaredProperties = declaredPropertiesEither.left().value();
- assertTrue(CollectionUtils.isNotEmpty(declaredProperties));
+ assertThat(CollectionUtils.isNotEmpty(declaredProperties)).isTrue();
assertEquals(1, declaredProperties.size());
assertEquals(declaredProperties, declaredPropertiesToInputs);
}
@@ -284,7 +285,7 @@ public class InputsBusinessLogicTest {
when(componentsUtilsMock.convertFromStorageResponse(StorageOperationStatus.ARTIFACT_NOT_FOUND)).thenReturn(ActionStatus.ARTIFACT_NOT_FOUND);
when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
Either<List<InputDefinition>, ResponseFormat> responseFormatEither = testInstance.getInputs("USR01", COMPONENT_ID);
- assertEquals(true,responseFormatEither.isRight());
+ assertThat(responseFormatEither.isRight()).isTrue();
}
@@ -311,7 +312,7 @@ public class InputsBusinessLogicTest {
component.setInputs(inputlist);
when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
Either<List<ComponentInstanceProperty>, ResponseFormat> responseFormatEither = testInstance.getComponentInstancePropertiesByInputId("USR01", COMPONENT_ID,"INST0.1", "INPO1");
- assertEquals(true,responseFormatEither.isRight());
+ assertThat(responseFormatEither.isRight()).isTrue();
}
@Test
@@ -331,7 +332,7 @@ public class InputsBusinessLogicTest {
when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(component));
when(toscaOperationFacadeMock.getToscaElement(eq("RES0.1"), any(ComponentParametersView.class))).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
Either<List<ComponentInstanceProperty>, ResponseFormat> responseFormatEither = testInstance.getComponentInstancePropertiesByInputId("USR01", COMPONENT_ID,"INST0.1", "INPO1");
- assertEquals(true,responseFormatEither.isRight());
+ assertThat(responseFormatEither.isRight()).isTrue();
}
@Test
@@ -362,7 +363,7 @@ public class InputsBusinessLogicTest {
{
when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
Either<List<ComponentInstanceInput>, ResponseFormat> result = testInstance.getInputsForComponentInput("USR01", COMPONENT_ID,"INPO1");
- assertEquals(true,result.isRight());
+ assertThat(result.isRight()).isTrue();
}
@Test
@@ -383,7 +384,7 @@ public class InputsBusinessLogicTest {
when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(component));
when(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(any(Component.class),eq("INPO1"))).thenReturn(compinstancelist);
Either<List<ComponentInstanceInput>, ResponseFormat> result = testInstance.getInputsForComponentInput("USR01", COMPONENT_ID,"INPO1");
- assertEquals(true,result.isLeft());
+ assertThat(result.isLeft()).isTrue();
}
private List<ComponentInstancePropInput> getPropertiesListForDeclaration() {
@@ -478,13 +479,13 @@ public class InputsBusinessLogicTest {
Either<List<InputDefinition>, ResponseFormat> result =
testInstance.createListInput(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, createListInputParams, true, false);
// validate result
- assertEquals(true, result.isLeft());
+ assertThat(result.isLeft()).isTrue();
List<InputDefinition> resultInputList = result.left().value();
assertEquals(1, resultInputList.size());
//InputDefinition resultInput = resultInputList.get(0);
Map<String, DataTypeDefinition> captoredDataTypeMap = dataTypesMapCaptor.getValue();
assertEquals(1, captoredDataTypeMap.size());
- assertEquals(true, captoredDataTypeMap.containsKey(LISTINPUT_SCHEMA_TYPE));
+ assertThat(captoredDataTypeMap.containsKey(LISTINPUT_SCHEMA_TYPE)).isTrue();
DataTypeDefinition captoredDataType = captoredDataTypeMap.get(LISTINPUT_SCHEMA_TYPE);
assertEquals("tosca.datatypes.Root", captoredDataType.getDerivedFromName());
assertEquals( propInputsList.size(), captoredDataType.getProperties().size());
@@ -492,7 +493,7 @@ public class InputsBusinessLogicTest {
captoredDataType.getProperties().forEach(dataTypeProp -> {
Optional<ComponentInstancePropInput> find = propInputsList.stream()
.filter(propInput -> propInput.getName().equals(dataTypeProp.getName())).findAny();
- assertEquals(true, find.isPresent());
+ assertThat(find.isPresent()).isTrue();
});
}
@@ -565,7 +566,7 @@ public class InputsBusinessLogicTest {
Either<List<InputDefinition>, ResponseFormat> result =
testInstance.createListInput(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, createListInputParams, true, false);
- assertEquals(true, result.isRight());
+ assertThat(result.isRight()).isTrue();
verify(propertyOperation, times(1)).isPropertyTypeValid(any());
}
@@ -588,7 +589,7 @@ public class InputsBusinessLogicTest {
Either<List<InputDefinition>, ResponseFormat> result =
testInstance.createListInput(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, createListInputParams, true, false);
- assertEquals(true, result.isRight());
+ assertThat(result.isRight()).isTrue();
verify(toscaOperationFacadeMock, times(1)).addInputsToComponent(anyMap(), eq(COMPONENT_ID));
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
index b8bb4a775b..abdef47182 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
@@ -19,7 +19,6 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import java.util.ArrayList;
-import java.util.Optional;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -78,14 +77,11 @@ import java.util.Map;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
@@ -180,7 +176,7 @@ public class PolicyBusinessLogicTest {
when(toscaOperationFacade.associatePolicyToComponent(eq(COMPONENT_ID), any(PolicyDefinition.class), eq(0))).thenReturn(policySuccessEither);
stubUnlockAndCommit();
PolicyDefinition response = businessLogic.createPolicy(ComponentTypeEnum.RESOURCE, COMPONENT_ID, POLICY_TYPE_NAME, USER_ID, true);
- assertTrue(!response.isEmpty());
+ assertThat(response.isEmpty()).isFalse();
}
@Test
@@ -215,7 +211,7 @@ public class PolicyBusinessLogicTest {
Map<String, PolicyDefinition> createdPolicy = businessLogic.createPoliciesFromParsedCsar(newResource, policies);
- assertFalse(createdPolicy.isEmpty());
+ assertThat(createdPolicy.isEmpty()).isFalse();
PolicyDefinition newPolicy = createdPolicy.get(POLICY_NAME);
assertNotNull(newPolicy);
assertNotNull(newPolicy.getTargets());
@@ -237,7 +233,7 @@ public class PolicyBusinessLogicTest {
}
private void assertNotFound(Either<PolicyDefinition, ResponseFormat> response) {
- assertTrue(response.isRight() && response.right().value().getStatus().equals(404));
+ assertThat(response.isRight() && response.right().value().getStatus().equals(404)).isTrue();
}
@Test(expected = ComponentException.class)
@@ -277,7 +273,7 @@ public class PolicyBusinessLogicTest {
when(toscaOperationFacade.updatePolicyOfComponent(eq(COMPONENT_ID), any(PolicyDefinition.class), any(PromoteVersionEnum.class))).thenReturn(policySuccessEither);
stubUnlockAndCommit();
PolicyDefinition response = businessLogic.updatePolicy(ComponentTypeEnum.RESOURCE, COMPONENT_ID, otherPolicy, USER_ID, true);
- assertTrue(!response.isEmpty());
+ assertThat(response.isEmpty()).isFalse();
}
@Test(expected = ComponentException.class)
@@ -292,7 +288,7 @@ public class PolicyBusinessLogicTest {
stubValidationSuccess(CREATE_POLICY);
stubCommit();
PolicyDefinition response = businessLogic.getPolicy(ComponentTypeEnum.RESOURCE, COMPONENT_ID, POLICY_ID, USER_ID);
- assertTrue(!response.isEmpty());
+ assertThat(response.isEmpty()).isFalse();
}
@Test(expected = ComponentException.class)
@@ -308,7 +304,7 @@ public class PolicyBusinessLogicTest {
stubCommit();
when(toscaOperationFacade.removePolicyFromComponent(eq(COMPONENT_ID),eq(POLICY_ID))).thenReturn(StorageOperationStatus.OK);
PolicyDefinition response = businessLogic.deletePolicy(ComponentTypeEnum.RESOURCE, COMPONENT_ID, POLICY_ID, USER_ID, true);
- assertTrue(!response.isEmpty());
+ assertThat(response.isEmpty()).isFalse();
}
@Test(expected = ComponentException.class)
@@ -398,10 +394,10 @@ public class PolicyBusinessLogicTest {
ComponentTypeEnum.RESOURCE,
getInputForPropertyToPolicyDeclaration());
- assertTrue(declaredPoliciesEither.isLeft());
+ assertThat(declaredPoliciesEither.isLeft()).isTrue();
List<PolicyDefinition> declaredPolicies = declaredPoliciesEither.left().value();
- assertTrue(CollectionUtils.isNotEmpty(declaredPolicies));
+ assertThat(CollectionUtils.isNotEmpty(declaredPolicies)).isTrue();
assertEquals(1, declaredPolicies.size());
}