summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorDmitry Puzikov <d.puzikov2@partner.samsung.com>2020-03-24 18:22:03 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-03-25 13:58:20 +0000
commitbca8dd9ac181bde35c9f89766e86855d9ddd2102 (patch)
tree678cda121c50186eab5c2493c86724f27e0fde78 /catalog-be
parentcb10a6cc9f65ef69c3c8a29a9ea3312adfe814e4 (diff)
Fix unit tests
Add asserts where required, fix tiny issues. Replace getters-setters with Lombok annotations. Change-Id: Icb1a20f400fd8732a3d0ae23b8fe88bc693df1f5 Issue-ID: SDC-2853 Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/impl/ServletUtils.java18
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java512
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/ForwardingPathUtilsTest.java45
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java59
-rw-r--r--catalog-be/src/test/resources/application-context-test.xml38
5 files changed, 440 insertions, 232 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ServletUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ServletUtils.java
index 9687a4084a..70bfd60751 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ServletUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ServletUtils.java
@@ -21,28 +21,20 @@
package org.openecomp.sdc.be.impl;
import com.google.gson.Gson;
+import lombok.Getter;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component("servletUtils")
+@Getter
public class ServletUtils {
@Resource
private ComponentsUtils componentsUtils;
- private Gson gson = new Gson();
- @Resource
- private UserBusinessLogic adminManager;
-
- public ComponentsUtils getComponentsUtils() {
- return componentsUtils;
- }
- public Gson getGson() {
- return gson;
- }
+ private Gson gson = new Gson();
- public UserBusinessLogic getUserAdmin() {
- return adminManager;
- }
+ @Resource
+ private UserBusinessLogic userAdmin;
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
index 9e738ca81a..a01831e70c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
@@ -22,7 +22,7 @@
package org.openecomp.sdc.be.impl;
import fj.data.Either;
-import junit.framework.Assert;
+import java.util.ArrayList;
import org.apache.tinkerpop.gremlin.structure.T;
import org.junit.Before;
import org.junit.Test;
@@ -44,6 +44,7 @@ import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.GroupTypeDefinition;
import org.openecomp.sdc.be.model.PolicyTypeDefinition;
+import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -59,6 +60,7 @@ import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import java.util.List;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -78,18 +80,19 @@ public class ComponentsUtilsTest {
}
@Test
- public void testGetAuditingManager() throws Exception {
+ public void testGetAuditingManager() {
ComponentsUtils testSubject;
AuditingManager result;
// default test
testSubject = createTestSubject();
result = testSubject.getAuditingManager();
+ assertThat(result).isInstanceOf(AuditingManager.class);
}
@Test
- public void testGetResponseFormat() throws Exception {
+ public void testGetResponseFormat() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
String[] params = new String[] { "" };
@@ -98,11 +101,13 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.getResponseFormat(actionStatus, params);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus().toString().startsWith("2")).isTrue();
}
@Test
- public void testGetResponseFormat_1() throws Exception {
+ public void testGetResponseFormat_1() {
ComponentsUtils testSubject;
StorageOperationStatus storageStatus = null;
String[] params = new String[] { "" };
@@ -111,11 +116,13 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.getResponseFormat(storageStatus, params);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus().toString().startsWith("5")).isTrue();
}
@Test
- public void testConvertToResponseFormatOrNotFoundErrorToEmptyList() throws Exception {
+ public void testConvertToResponseFormatOrNotFoundErrorToEmptyList() {
ComponentsUtils testSubject;
StorageOperationStatus storageOperationStatus = StorageOperationStatus.ARTIFACT_NOT_FOUND;
Either<List<T>, ResponseFormat> result;
@@ -123,11 +130,24 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertToResponseFormatOrNotFoundErrorToEmptyList(storageOperationStatus);
+ assertThat(result.isRight()).isTrue();
+ }
+
+ @Test
+ public void testConvertToResponseFormatOrNotFoundErrorToEmptyList_1() {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageOperationStatus = StorageOperationStatus.NOT_FOUND;
+ Either<List<T>, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertToResponseFormatOrNotFoundErrorToEmptyList(storageOperationStatus);
+ assertThat(result.isLeft()).isTrue();
}
@Test
- public void testGetResponseFormatByResource() throws Exception {
+ public void testGetResponseFormatByResource() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
ResponseFormat result;
@@ -135,17 +155,35 @@ public class ComponentsUtilsTest {
// test 1
testSubject = createTestSubject();
result = testSubject.getResponseFormatByResource(actionStatus, resource);
+
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
+
resource = new Resource();
result = testSubject.getResponseFormatByResource(actionStatus, resource);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
+
result = testSubject.getResponseFormatByResource(ActionStatus.COMPONENT_VERSION_ALREADY_EXIST, resource);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
+
result = testSubject.getResponseFormatByResource(ActionStatus.RESOURCE_NOT_FOUND, resource);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(404);
+
result = testSubject.getResponseFormatByResource(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, resource);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
+
result = testSubject.getResponseFormatByResource(ActionStatus.COMPONENT_IN_USE, resource);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(403);
}
@Test
- public void testGetResponseFormatByResource_1() throws Exception {
+ public void testGetResponseFormatByResource_1() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
String resourceName = "";
@@ -155,12 +193,19 @@ public class ComponentsUtilsTest {
testSubject = createTestSubject();
resourceName = null;
result = testSubject.getResponseFormatByResource(actionStatus, resourceName);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
// test 2
testSubject = createTestSubject();
- resourceName = "";
+ resourceName = "mock-name";
result = testSubject.getResponseFormatByResource(actionStatus, resourceName);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
+
result = testSubject.getResponseFormatByResource(ActionStatus.RESOURCE_NOT_FOUND, resourceName);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(404);
}
@@ -173,8 +218,16 @@ public class ComponentsUtilsTest {
// test 1
testSubject = createTestSubject();
result = testSubject.getResponseFormatByCapabilityType(ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST, null);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
+
result = testSubject.getResponseFormatByCapabilityType(ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST, capabilityType);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
+
result = testSubject.getResponseFormatByCapabilityType(ActionStatus.AAI_ARTIFACT_GENERATION_FAILED, capabilityType);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(500);
}
@@ -187,16 +240,28 @@ public class ComponentsUtilsTest {
// test 1
testSubject = createTestSubject();
+
obj = null;
result = testSubject.getResponseFormatByElement(actionStatus, obj);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
+
obj = new Object();
+
result = testSubject.getResponseFormatByElement(actionStatus, obj);
- result = testSubject.getResponseFormatByElement(ActionStatus.MISSING_CAPABILITY_TYPE, obj);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
+
+ List<Object> obj1 = new ArrayList<>();
+ obj1.add(new RequirementDefinition());
+
+ result = testSubject.getResponseFormatByElement(ActionStatus.MISSING_CAPABILITY_TYPE, obj1);
+ assertThat(result.getStatus()).isEqualTo(400);
}
@Test
- public void testGetResponseFormatByUser() throws Exception {
+ public void testGetResponseFormatByUser() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
User user = null;
@@ -206,17 +271,34 @@ public class ComponentsUtilsTest {
testSubject = createTestSubject();
user = null;
result = testSubject.getResponseFormatByUser(actionStatus, user);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
+
user = new User();
result = testSubject.getResponseFormatByUser(ActionStatus.INVALID_USER_ID, user);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
+
result = testSubject.getResponseFormatByUser(ActionStatus.INVALID_EMAIL_ADDRESS, user);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
+
result = testSubject.getResponseFormatByUser(ActionStatus.INVALID_ROLE, user);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
+
result = testSubject.getResponseFormatByUser(ActionStatus.USER_NOT_FOUND, user);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(404);
+
result = testSubject.getResponseFormatByUser(ActionStatus.ADDITIONAL_INFORMATION_EMPTY_STRING_NOT_ALLOWED, user);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
}
@Test
- public void testGetResponseFormatByUserId() throws Exception {
+ public void testGetResponseFormatByUserId() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
String userId = "";
@@ -225,34 +307,50 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.getResponseFormatByUserId(actionStatus, userId);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
}
@Test
- public void testGetResponseFormatByDE() throws Exception {
+ public void testGetResponseFormatByDE() {
ComponentsUtils testSubject;
- ActionStatus actionStatus = ActionStatus.ACCEPTED;
String serviceId = "";
String envName = "";
ResponseFormat result;
// default test
testSubject = createTestSubject();
- result = testSubject.getResponseFormatByDE(actionStatus, serviceId);
+ result = testSubject.getResponseFormatByDE(ActionStatus.ACCEPTED, serviceId);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
+
+ result = testSubject.getResponseFormatByDE(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE, serviceId);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(500);
+
+ result = testSubject.getResponseFormatByDE(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_FOUND, serviceId);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
}
@Test
public void testGetResponseFormatByArtifactId() throws Exception {
ComponentsUtils testSubject;
- ActionStatus actionStatus = ActionStatus.ACCEPTED;
String artifactId = "";
ResponseFormat result;
// default test
testSubject = createTestSubject();
- result = testSubject.getResponseFormatByArtifactId(actionStatus, artifactId);
+
+ result = testSubject.getResponseFormatByArtifactId(ActionStatus.ACCEPTED, artifactId);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
+
result = testSubject.getResponseFormatByArtifactId(ActionStatus.RESOURCE_NOT_FOUND, artifactId);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(404);
}
@Test
@@ -305,7 +403,7 @@ public class ComponentsUtilsTest {
}
@Test
- public void testConvertFromStorageResponse() throws Exception {
+ public void testConvertFromStorageResponse() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = null;
ActionStatus result;
@@ -313,11 +411,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponse(storageResponse);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testConvertFromStorageResponse_1() throws Exception {
+ public void testConvertFromStorageResponse_1() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = null;
ComponentTypeEnum type = null;
@@ -327,11 +428,14 @@ public class ComponentsUtilsTest {
testSubject = createTestSubject();
storageResponse = null;
result = testSubject.convertFromStorageResponse(storageResponse, type);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);;
}
@Test
- public void testConvertFromToscaError() throws Exception {
+ public void testConvertFromToscaError() {
ComponentsUtils testSubject;
ToscaError toscaError = null;
ActionStatus result;
@@ -340,11 +444,14 @@ public class ComponentsUtilsTest {
testSubject = createTestSubject();
toscaError = null;
result = testSubject.convertFromToscaError(toscaError);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testConvertFromStorageResponseForCapabilityType() throws Exception {
+ public void testConvertFromStorageResponseForCapabilityType() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.CANNOT_UPDATE_EXISTING_ENTITY;
ActionStatus result;
@@ -352,11 +459,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponseForCapabilityType(storageResponse);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testConvertFromStorageResponseForLifecycleType() throws Exception {
+ public void testConvertFromStorageResponseForLifecycleType() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
ActionStatus result;
@@ -364,11 +474,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponseForLifecycleType(storageResponse);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testConvertFromStorageResponseForResourceInstance() throws Exception {
+ public void testConvertFromStorageResponseForResourceInstance() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
boolean isRelation = false;
@@ -377,11 +490,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponseForResourceInstance(storageResponse, isRelation);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testGetResponseFormatForResourceInstance() throws Exception {
+ public void testGetResponseFormatForResourceInstance() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
String serviceName = "";
@@ -391,11 +507,13 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.getResponseFormatForResourceInstance(actionStatus, serviceName, resourceInstanceName);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
}
@Test
- public void testGetResponseFormatForResourceInstanceProperty() throws Exception {
+ public void testGetResponseFormatForResourceInstanceProperty() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
String resourceInstanceName = "";
@@ -404,11 +522,13 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.getResponseFormatForResourceInstanceProperty(actionStatus, resourceInstanceName);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
}
@Test
- public void testConvertFromStorageResponseForResourceInstanceProperty() throws Exception {
+ public void testConvertFromStorageResponseForResourceInstanceProperty() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
ActionStatus result;
@@ -416,6 +536,9 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponseForResourceInstanceProperty(storageResponse);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@@ -454,7 +577,7 @@ public class ComponentsUtilsTest {
@Test
- public void testValidateStringNotEmpty() throws Exception {
+ public void testValidateStringNotEmpty() {
ComponentsUtils testSubject;
String value = "";
boolean result;
@@ -462,11 +585,12 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.validateStringNotEmpty(value);
+ assertThat(result).isFalse();
}
@Test
- public void testConvertFromStorageResponseForAdditionalInformation() throws Exception {
+ public void testConvertFromStorageResponseForAdditionalInformation() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
ActionStatus result;
@@ -474,11 +598,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponseForAdditionalInformation(storageResponse);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testConvertFromResultStatusEnum() throws Exception {
+ public void testConvertFromResultStatusEnum() {
ComponentsUtils testSubject;
ResultStatusEnum resultStatus = ResultStatusEnum.ELEMENT_NOT_FOUND;
JsonPresentationFields elementType = null;
@@ -487,11 +614,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromResultStatusEnum(resultStatus, elementType);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testGetResponseFormatAdditionalProperty() throws Exception {
+ public void testGetResponseFormatAdditionalProperty() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
AdditionalInfoParameterInfo additionalInfoParameterInfo = null;
@@ -504,17 +634,21 @@ public class ComponentsUtilsTest {
additionalInfoParameterInfo = null;
result = testSubject.getResponseFormatAdditionalProperty(actionStatus, additionalInfoParameterInfo, nodeType,
labelOrValue);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
// test 2
testSubject = createTestSubject();
labelOrValue = null;
result = testSubject.getResponseFormatAdditionalProperty(actionStatus, additionalInfoParameterInfo, nodeType,
labelOrValue);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
}
@Test
- public void testGetResponseFormatAdditionalProperty_1() throws Exception {
+ public void testGetResponseFormatAdditionalProperty_1() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
ResponseFormat result;
@@ -522,11 +656,13 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.getResponseFormatAdditionalProperty(actionStatus);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
}
@Test
- public void testConvertFromStorageResponseForConsumer() throws Exception {
+ public void testConvertFromStorageResponseForConsumer() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
ActionStatus result;
@@ -534,11 +670,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponseForConsumer(storageResponse);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testConvertFromStorageResponseForGroupType() throws Exception {
+ public void testConvertFromStorageResponseForGroupType() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
ActionStatus result;
@@ -546,11 +685,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponseForGroupType(storageResponse);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testConvertFromStorageResponseForDataType() throws Exception {
+ public void testConvertFromStorageResponseForDataType() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
ActionStatus result;
@@ -558,11 +700,14 @@ public class ComponentsUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertFromStorageResponseForDataType(storageResponse);
+ assertThat(result)
+ .isInstanceOf(ActionStatus.class)
+ .isEqualTo(ActionStatus.GENERAL_ERROR);
}
@Test
- public void testGetResponseFormatByGroupType() throws Exception {
+ public void testGetResponseFormatByGroupType() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
GroupTypeDefinition groupType = null;
@@ -572,11 +717,13 @@ public class ComponentsUtilsTest {
testSubject = createTestSubject();
groupType = null;
result = testSubject.getResponseFormatByGroupType(actionStatus, groupType);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
}
@Test
- public void testGetResponseFormatByPolicyType() throws Exception {
+ public void testGetResponseFormatByPolicyType() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.ACCEPTED;
PolicyTypeDefinition policyType = new PolicyTypeDefinition();
@@ -585,11 +732,13 @@ public class ComponentsUtilsTest {
// test 1
testSubject = createTestSubject();
result = testSubject.getResponseFormatByPolicyType(actionStatus, policyType);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
}
@Test
- public void testGetResponseFormatByDataType() throws Exception {
+ public void testGetResponseFormatByDataType() {
ComponentsUtils testSubject;
ActionStatus actionStatus = ActionStatus.AAI_ARTIFACT_GENERATION_FAILED;
DataTypeDefinition dataType = null;
@@ -600,10 +749,12 @@ public class ComponentsUtilsTest {
testSubject = createTestSubject();
dataType = null;
result = testSubject.getResponseFormatByDataType(actionStatus, dataType, properties);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(500);
}
@Test
- public void testconvertJsonToObject() throws Exception {
+ public void testconvertJsonToObject() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
@@ -616,11 +767,12 @@ public class ComponentsUtilsTest {
Either<User,ResponseFormat> response=compUtils.convertJsonToObject(data,user,User.class,AuditingActionEnum.ADD_USER);
User assertuser = new User("xyz","xyz","12","demo.z@ymail.com","123",null);
- Assert.assertEquals(assertuser,response.left().value());
+ assertThat(response.isLeft()).isTrue();
+ assertThat(response.left().value()).isEqualTo(assertuser);
}
@Test
- public void testconvertJsonToObject_NllData() throws Exception {
+ public void testconvertJsonToObject_NllData() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
@@ -629,11 +781,11 @@ public class ComponentsUtilsTest {
String data=null;
Either<User,ResponseFormat> response=compUtils.convertJsonToObject(data,user,User.class,AuditingActionEnum.ADD_USER);
- Assert.assertEquals(true,response.isRight());
+ assertThat(response.isRight()).isTrue();
}
@Test
- public void testconvertJsonToObjectInvalidData() throws Exception {
+ public void testconvertJsonToObjectInvalidData() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
@@ -645,8 +797,7 @@ public class ComponentsUtilsTest {
Either<User,ResponseFormat> response=compUtils.convertJsonToObject(data,user,User.class,AuditingActionEnum.ADD_USER);
-
- Assert.assertEquals(true,response.isRight());
+ assertThat(response.isRight()).isTrue();
}
@Test
@@ -654,11 +805,11 @@ public class ComponentsUtilsTest {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(StorageOperationStatus.OK,compUtils.convertToStorageOperationStatus(CassandraOperationStatus.OK));
- Assert.assertEquals(StorageOperationStatus.NOT_FOUND,compUtils.convertToStorageOperationStatus(CassandraOperationStatus.NOT_FOUND));
- Assert.assertEquals(StorageOperationStatus.GENERAL_ERROR,compUtils.convertToStorageOperationStatus(CassandraOperationStatus.GENERAL_ERROR));
- Assert.assertEquals(StorageOperationStatus.CONNECTION_FAILURE,compUtils.convertToStorageOperationStatus(CassandraOperationStatus.CLUSTER_NOT_CONNECTED));
- Assert.assertEquals(StorageOperationStatus.CONNECTION_FAILURE,compUtils.convertToStorageOperationStatus(CassandraOperationStatus.KEYSPACE_NOT_CONNECTED));
+ assertThat(compUtils.convertToStorageOperationStatus(CassandraOperationStatus.OK)).isEqualTo(StorageOperationStatus.OK);
+ assertThat(compUtils.convertToStorageOperationStatus(CassandraOperationStatus.NOT_FOUND)).isEqualTo(StorageOperationStatus.NOT_FOUND);
+ assertThat(compUtils.convertToStorageOperationStatus(CassandraOperationStatus.GENERAL_ERROR)).isEqualTo(StorageOperationStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertToStorageOperationStatus(CassandraOperationStatus.CLUSTER_NOT_CONNECTED)).isEqualTo(StorageOperationStatus.CONNECTION_FAILURE);
+ assertThat(compUtils.convertToStorageOperationStatus(CassandraOperationStatus.KEYSPACE_NOT_CONNECTED)).isEqualTo(StorageOperationStatus.CONNECTION_FAILURE);
}
@Test
@@ -669,98 +820,104 @@ public class ComponentsUtilsTest {
DataTypeDefinition dataType = new DataTypeDefinition();
dataType.setName("demo");
List<String> properties;
- ResponseFormat responseFormat = compUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_ALREADY_EXIST, dataType, null);
- Assert.assertNotNull(responseFormat);
- Assert.assertEquals((Integer) 409,responseFormat.getStatus());
+ ResponseFormat result = compUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_ALREADY_EXIST, dataType, null);
+
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
}
@Test
- public void testGetResponseFormatByPolicyType_POLICY_TYPE_ALREADY_EXIST() throws Exception {
+ public void testGetResponseFormatByPolicyType_POLICY_TYPE_ALREADY_EXIST() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
PolicyTypeDefinition policyType = new PolicyTypeDefinition();
policyType.setType("Demo");
- ResponseFormat responseFormat = compUtils.getResponseFormatByPolicyType(ActionStatus.POLICY_TYPE_ALREADY_EXIST, policyType);
- Assert.assertNotNull(responseFormat);
- Assert.assertEquals((Integer) 409,responseFormat.getStatus());
+ ResponseFormat result = compUtils.getResponseFormatByPolicyType(ActionStatus.POLICY_TYPE_ALREADY_EXIST, policyType);
+
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
}
@Test
- public void testGetResponseFormatByPolicyType_PolicyID_NULL() throws Exception {
+ public void testGetResponseFormatByPolicyType_PolicyID_NULL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- ResponseFormat responseFormat = compUtils.getResponseFormatByPolicyType(ActionStatus.POLICY_TYPE_ALREADY_EXIST, null);
- Assert.assertNotNull(responseFormat);
- Assert.assertEquals((Integer) 409,responseFormat.getStatus());
+ ResponseFormat result = compUtils.getResponseFormatByPolicyType(ActionStatus.POLICY_TYPE_ALREADY_EXIST, null);
+
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
}
@Test
- public void testGetResponseFormatByGroupType_GROUP_MEMBER_EMPTY() throws Exception {
+ public void testGetResponseFormatByGroupType_GROUP_MEMBER_EMPTY() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
GroupTypeDefinition groupType = new GroupTypeDefinition();
groupType.setType("Demo");
- ResponseFormat responseFormat = compUtils.getResponseFormatByGroupType(ActionStatus.GROUP_MEMBER_EMPTY, groupType);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatByGroupType(ActionStatus.GROUP_TYPE_ALREADY_EXIST, groupType);
- Assert.assertNotNull(responseFormat);
+
+ ResponseFormat result = compUtils.getResponseFormatByGroupType(ActionStatus.GROUP_MEMBER_EMPTY, groupType);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
+
+ result = compUtils.getResponseFormatByGroupType(ActionStatus.GROUP_TYPE_ALREADY_EXIST, groupType);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
}
@Test
- public void testConvertFromStorageResponseForDataType_ALL() throws Exception {
+ public void testConvertFromStorageResponseForDataType_ALL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(ActionStatus.OK,compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.OK));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.CONNECTION_FAILURE));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.GRAPH_IS_LOCK));
- Assert.assertEquals(ActionStatus.INVALID_CONTENT,compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.BAD_REQUEST));
- Assert.assertEquals(ActionStatus.DATA_TYPE_ALREADY_EXIST,compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.ENTITY_ALREADY_EXISTS));
- Assert.assertEquals(ActionStatus.DATA_TYPE_ALREADY_EXIST,compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.SCHEMA_VIOLATION));
- Assert.assertEquals(ActionStatus.DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST,compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.CANNOT_UPDATE_EXISTING_ENTITY));
-
+ assertThat(compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.OK)).isEqualTo(ActionStatus.OK);
+ assertThat(compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.CONNECTION_FAILURE)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.GRAPH_IS_LOCK)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.BAD_REQUEST)).isEqualTo(ActionStatus.INVALID_CONTENT);
+ assertThat(compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.ENTITY_ALREADY_EXISTS)).isEqualTo(ActionStatus.DATA_TYPE_ALREADY_EXIST);
+ assertThat(compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.SCHEMA_VIOLATION)).isEqualTo(ActionStatus.DATA_TYPE_ALREADY_EXIST);
+ assertThat(compUtils.convertFromStorageResponseForDataType(StorageOperationStatus.CANNOT_UPDATE_EXISTING_ENTITY)).isEqualTo(ActionStatus.DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST);
}
@Test
- public void testConvertFromStorageResponseForGroupType_ALL() throws Exception {
+ public void testConvertFromStorageResponseForGroupType_ALL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(ActionStatus.OK,compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.OK));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.CONNECTION_FAILURE));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.GRAPH_IS_LOCK));
- Assert.assertEquals(ActionStatus.INVALID_CONTENT,compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.BAD_REQUEST));
- Assert.assertEquals(ActionStatus.GROUP_TYPE_ALREADY_EXIST,compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.ENTITY_ALREADY_EXISTS));
- Assert.assertEquals(ActionStatus.GROUP_TYPE_ALREADY_EXIST,compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.SCHEMA_VIOLATION));
+ assertThat(compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.OK)).isEqualTo(ActionStatus.OK);
+ assertThat(compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.CONNECTION_FAILURE)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.GRAPH_IS_LOCK)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.BAD_REQUEST)).isEqualTo(ActionStatus.INVALID_CONTENT);
+ assertThat(compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.ENTITY_ALREADY_EXISTS)).isEqualTo(ActionStatus.GROUP_TYPE_ALREADY_EXIST);
+ assertThat(compUtils.convertFromStorageResponseForGroupType(StorageOperationStatus.SCHEMA_VIOLATION)).isEqualTo(ActionStatus.GROUP_TYPE_ALREADY_EXIST);
}
@Test
- public void testConvertFromStorageResponseForConsumer_ALL() throws Exception {
+ public void testConvertFromStorageResponseForConsumer_ALL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(ActionStatus.OK,compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.OK));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.CONNECTION_FAILURE));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.GRAPH_IS_LOCK));
- Assert.assertEquals(ActionStatus.INVALID_CONTENT,compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.BAD_REQUEST));
- Assert.assertEquals(ActionStatus.CONSUMER_ALREADY_EXISTS,compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.ENTITY_ALREADY_EXISTS));
- Assert.assertEquals(ActionStatus.CONSUMER_ALREADY_EXISTS,compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.SCHEMA_VIOLATION));
- Assert.assertEquals(ActionStatus.ECOMP_USER_NOT_FOUND,compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.NOT_FOUND));
+ assertThat(compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.OK)).isEqualTo(ActionStatus.OK);
+ assertThat(compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.CONNECTION_FAILURE)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.GRAPH_IS_LOCK)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.BAD_REQUEST)).isEqualTo(ActionStatus.INVALID_CONTENT);
+ assertThat(compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.ENTITY_ALREADY_EXISTS)).isEqualTo(ActionStatus.CONSUMER_ALREADY_EXISTS);
+ assertThat(compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.SCHEMA_VIOLATION)).isEqualTo(ActionStatus.CONSUMER_ALREADY_EXISTS);
+ assertThat(compUtils.convertFromStorageResponseForConsumer(StorageOperationStatus.NOT_FOUND)).isEqualTo(ActionStatus.ECOMP_USER_NOT_FOUND);
}
@Test
- public void testGetResponseFormatAdditionalProperty_ALL() throws Exception {
+ public void testGetResponseFormatAdditionalProperty_ALL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
@@ -769,128 +926,155 @@ public class ComponentsUtilsTest {
NodeTypeEnum nodeType = null;
AdditionalInformationEnum labelOrValue = null;
- ResponseFormat responseFormat = compUtils.getResponseFormatAdditionalProperty(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, additionalInfoParameterInfo, nodeType,
+ ResponseFormat result = compUtils.getResponseFormatAdditionalProperty(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, additionalInfoParameterInfo, nodeType,
labelOrValue);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_EXCEEDS_LIMIT, additionalInfoParameterInfo, nodeType,
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
+
+ result = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_EXCEEDS_LIMIT, additionalInfoParameterInfo, nodeType,
labelOrValue);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_MAX_NUMBER_REACHED, additionalInfoParameterInfo, NodeTypeEnum.Group,
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
+
+ result = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_MAX_NUMBER_REACHED, additionalInfoParameterInfo, NodeTypeEnum.Group,
labelOrValue);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_EMPTY_STRING_NOT_ALLOWED, additionalInfoParameterInfo, nodeType,
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
+
+ result = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_EMPTY_STRING_NOT_ALLOWED, additionalInfoParameterInfo, nodeType,
labelOrValue);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_KEY_NOT_ALLOWED_CHARACTERS, additionalInfoParameterInfo, nodeType,
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
+
+ result = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_KEY_NOT_ALLOWED_CHARACTERS, additionalInfoParameterInfo, nodeType,
labelOrValue);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_VALUE_NOT_ALLOWED_CHARACTERS, additionalInfoParameterInfo, nodeType,
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
+
+ result = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_VALUE_NOT_ALLOWED_CHARACTERS, additionalInfoParameterInfo, nodeType,
labelOrValue);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_NOT_FOUND, additionalInfoParameterInfo, nodeType,
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(400);
+
+ result = compUtils.getResponseFormatAdditionalProperty(ActionStatus.ADDITIONAL_INFORMATION_NOT_FOUND, additionalInfoParameterInfo, nodeType,
labelOrValue);
- Assert.assertNotNull(responseFormat);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
}
@Test
- public void testConvertFromResultStatusEnum_ALL() throws Exception {
+ public void testConvertFromResultStatusEnum_ALL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(ActionStatus.OK,compUtils.convertFromResultStatusEnum(ResultStatusEnum.OK, null));
- Assert.assertEquals(ActionStatus.INVALID_PROPERTY,compUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_DEFAULT_VALUE, null));
- Assert.assertEquals(ActionStatus.INVALID_PROPERTY,compUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_TYPE, null));
- Assert.assertEquals(ActionStatus.INVALID_PROPERTY,compUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_VALUE, null));
- Assert.assertEquals(ActionStatus.INVALID_PROPERTY,compUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME, null));
- Assert.assertEquals(ActionStatus.INVALID_PROPERTY,compUtils.convertFromResultStatusEnum(ResultStatusEnum.MISSING_ENTRY_SCHEMA_TYPE, null));
+ assertThat(compUtils.convertFromResultStatusEnum(ResultStatusEnum.OK, null)).isEqualTo(ActionStatus.OK);
+ assertThat(compUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_DEFAULT_VALUE, null)).isEqualTo(ActionStatus.INVALID_PROPERTY);
+ assertThat(compUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_TYPE, null)).isEqualTo(ActionStatus.INVALID_PROPERTY);
+ assertThat(compUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_VALUE, null)).isEqualTo(ActionStatus.INVALID_PROPERTY);
+ assertThat(compUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME, null)).isEqualTo(ActionStatus.INVALID_PROPERTY);
+ assertThat(compUtils.convertFromResultStatusEnum(ResultStatusEnum.MISSING_ENTRY_SCHEMA_TYPE, null)).isEqualTo(ActionStatus.INVALID_PROPERTY);
}
@Test
- public void testconvertFromStorageResponseForAdditionalInformation() throws Exception{
+ public void testconvertFromStorageResponseForAdditionalInformation() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(ActionStatus.OK,compUtils.convertFromStorageResponseForAdditionalInformation(StorageOperationStatus.OK));
- Assert.assertEquals(ActionStatus.COMPONENT_NAME_ALREADY_EXIST,compUtils.convertFromStorageResponseForAdditionalInformation(StorageOperationStatus.ENTITY_ALREADY_EXISTS));
- Assert.assertEquals(ActionStatus.ADDITIONAL_INFORMATION_NOT_FOUND,compUtils.convertFromStorageResponseForAdditionalInformation(StorageOperationStatus.INVALID_ID));
+ assertThat(compUtils.convertFromStorageResponseForAdditionalInformation(StorageOperationStatus.OK)).isEqualTo(ActionStatus.OK);
+ assertThat(compUtils.convertFromStorageResponseForAdditionalInformation(StorageOperationStatus.ENTITY_ALREADY_EXISTS)).isEqualTo(ActionStatus.COMPONENT_NAME_ALREADY_EXIST);
+ assertThat(compUtils.convertFromStorageResponseForAdditionalInformation(StorageOperationStatus.INVALID_ID)).isEqualTo(ActionStatus.ADDITIONAL_INFORMATION_NOT_FOUND);
}
@Test
- public void testgetResponseFormatByComponent() throws Exception{
+ public void testgetResponseFormatByComponent() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
Component component = new Resource();
- ResponseFormat responseFormat = compUtils.getResponseFormatByComponent(ActionStatus.COMPONENT_VERSION_ALREADY_EXIST, component, ComponentTypeEnum.RESOURCE);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatByComponent(ActionStatus.RESOURCE_NOT_FOUND, component, ComponentTypeEnum.RESOURCE);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatByComponent(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, component, ComponentTypeEnum.RESOURCE);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatByComponent(ActionStatus.COMPONENT_IN_USE, component, ComponentTypeEnum.RESOURCE);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatByComponent(ActionStatus.SERVICE_DEPLOYMENT_ARTIFACT_NOT_FOUND, component, ComponentTypeEnum.RESOURCE);
- Assert.assertNotNull(responseFormat);
- responseFormat = compUtils.getResponseFormatByComponent(ActionStatus.ACCEPTED, component, ComponentTypeEnum.RESOURCE);
- Assert.assertNotNull(responseFormat);
+ ResponseFormat result = compUtils.getResponseFormatByComponent(ActionStatus.COMPONENT_VERSION_ALREADY_EXIST, component, ComponentTypeEnum.RESOURCE);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
+
+ result = compUtils.getResponseFormatByComponent(ActionStatus.RESOURCE_NOT_FOUND, component, ComponentTypeEnum.RESOURCE);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(404);
+
+ result = compUtils.getResponseFormatByComponent(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, component, ComponentTypeEnum.RESOURCE);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(409);
+
+ result = compUtils.getResponseFormatByComponent(ActionStatus.COMPONENT_IN_USE, component, ComponentTypeEnum.RESOURCE);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(403);
+
+ result = compUtils.getResponseFormatByComponent(ActionStatus.SERVICE_DEPLOYMENT_ARTIFACT_NOT_FOUND, component, ComponentTypeEnum.RESOURCE);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(403);
+
+ result = compUtils.getResponseFormatByComponent(ActionStatus.ACCEPTED, component, ComponentTypeEnum.RESOURCE);
+ assertThat(result).isInstanceOf(ResponseFormat.class);
+ assertThat(result.getStatus()).isEqualTo(202);
}
@Test
- public void testConvertFromStorageResponseForResourceInstanceProperty_ALL() throws Exception {
+ public void testConvertFromStorageResponseForResourceInstanceProperty_ALL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(ActionStatus.OK,compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.OK));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_BAD_REQUEST,compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.INVALID_ID));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.GRAPH_IS_LOCK));
- Assert.assertEquals(ActionStatus.INVALID_CONTENT,compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.BAD_REQUEST));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND,compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.MATCH_NOT_FOUND));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_ALREADY_EXIST,compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.SCHEMA_VIOLATION));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND,compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.NOT_FOUND));
+
+ assertThat(compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.OK)).isEqualTo(ActionStatus.OK);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.INVALID_ID)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_BAD_REQUEST);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.GRAPH_IS_LOCK)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.BAD_REQUEST)).isEqualTo(ActionStatus.INVALID_CONTENT);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.MATCH_NOT_FOUND)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.SCHEMA_VIOLATION)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_ALREADY_EXIST);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.NOT_FOUND)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND);
}
@Test
- public void testConvertFromStorageResponseForResourceInstance_ALL() throws Exception {
+ public void testConvertFromStorageResponseForResourceInstance_ALL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.ARTIFACT_NOT_FOUND, false));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_BAD_REQUEST,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.INVALID_ID, false));
- Assert.assertEquals(ActionStatus.INVALID_PROPERTY,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.INVALID_PROPERTY, false));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.GRAPH_IS_LOCK, false));
- Assert.assertEquals(ActionStatus.INVALID_CONTENT,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.BAD_REQUEST, false));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.MATCH_NOT_FOUND, false));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_ALREADY_EXIST,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.SCHEMA_VIOLATION, false));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.NOT_FOUND, true));
- Assert.assertEquals(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.NOT_FOUND, false));
+
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.ARTIFACT_NOT_FOUND, false)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.INVALID_ID, false)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_BAD_REQUEST);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.INVALID_PROPERTY, false)).isEqualTo(ActionStatus.INVALID_PROPERTY);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.GRAPH_IS_LOCK, false)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.BAD_REQUEST, false)).isEqualTo(ActionStatus.INVALID_CONTENT);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.MATCH_NOT_FOUND, false)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.SCHEMA_VIOLATION, false)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_ALREADY_EXIST);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.NOT_FOUND, true)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND);
+ assertThat(compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.NOT_FOUND, false)).isEqualTo(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND);
}
@Test
- public void testConvertFromStorageResponse_ALL() throws Exception {
+ public void testConvertFromStorageResponse_ALL() {
AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponse(StorageOperationStatus.CONNECTION_FAILURE, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponse(StorageOperationStatus.GRAPH_IS_LOCK, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.INVALID_CONTENT,compUtils.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.COMPONENT_NAME_ALREADY_EXIST,compUtils.convertFromStorageResponse(StorageOperationStatus.ENTITY_ALREADY_EXISTS, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.PARENT_RESOURCE_NOT_FOUND,compUtils.convertFromStorageResponse(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.MULTIPLE_PARENT_RESOURCE_FOUND,compUtils.convertFromStorageResponse(StorageOperationStatus.MULTIPLE_PARENT_RESOURCE_FOUND, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.COMPONENT_IN_USE,compUtils.convertFromStorageResponse(StorageOperationStatus.FAILED_TO_LOCK_ELEMENT, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE,compUtils.convertFromStorageResponse(StorageOperationStatus.DISTR_ENVIRONMENT_NOT_AVAILABLE, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_FOUND,compUtils.convertFromStorageResponse(StorageOperationStatus.DISTR_ENVIRONMENT_NOT_FOUND, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.DISTRIBUTION_ENVIRONMENT_INVALID,compUtils.convertFromStorageResponse(StorageOperationStatus.DISTR_ENVIRONMENT_SENT_IS_INVALID, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.INVALID_CONTENT,compUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_TYPE, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.INVALID_CONTENT,compUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.CSAR_NOT_FOUND,compUtils.convertFromStorageResponse(StorageOperationStatus.CSAR_NOT_FOUND, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.PROPERTY_NAME_ALREADY_EXISTS,compUtils.convertFromStorageResponse(StorageOperationStatus.PROPERTY_NAME_ALREADY_EXISTS, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY,compUtils.convertFromStorageResponse(StorageOperationStatus.MATCH_NOT_FOUND, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.COMPONENT_CATEGORY_NOT_FOUND,compUtils.convertFromStorageResponse(StorageOperationStatus.CATEGORY_NOT_FOUND, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.INVALID_PROPERTY,compUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_PROPERTY, ComponentTypeEnum.RESOURCE));
- Assert.assertEquals(ActionStatus.COMPONENT_IS_ARCHIVED,compUtils.convertFromStorageResponse(StorageOperationStatus.COMPONENT_IS_ARCHIVED, ComponentTypeEnum.RESOURCE));
+
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.CONNECTION_FAILURE, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.GRAPH_IS_LOCK, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.GENERAL_ERROR);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.INVALID_CONTENT);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.ENTITY_ALREADY_EXISTS, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.COMPONENT_NAME_ALREADY_EXIST);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.PARENT_RESOURCE_NOT_FOUND);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.MULTIPLE_PARENT_RESOURCE_FOUND, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.MULTIPLE_PARENT_RESOURCE_FOUND);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.FAILED_TO_LOCK_ELEMENT, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.COMPONENT_IN_USE);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.DISTR_ENVIRONMENT_NOT_AVAILABLE, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.DISTR_ENVIRONMENT_NOT_FOUND, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_FOUND);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.DISTR_ENVIRONMENT_SENT_IS_INVALID, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.DISTRIBUTION_ENVIRONMENT_INVALID);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_TYPE, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.INVALID_CONTENT);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.INVALID_CONTENT);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.CSAR_NOT_FOUND, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.CSAR_NOT_FOUND);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.PROPERTY_NAME_ALREADY_EXISTS, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.PROPERTY_NAME_ALREADY_EXISTS);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.MATCH_NOT_FOUND, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.CATEGORY_NOT_FOUND, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.COMPONENT_CATEGORY_NOT_FOUND);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_PROPERTY, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.INVALID_PROPERTY);
+ assertThat(compUtils.convertFromStorageResponse(StorageOperationStatus.COMPONENT_IS_ARCHIVED, ComponentTypeEnum.RESOURCE)).isEqualTo(ActionStatus.COMPONENT_IS_ARCHIVED);
}
} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ForwardingPathUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ForwardingPathUtilsTest.java
index e5450b2f95..ee374878e9 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ForwardingPathUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ForwardingPathUtilsTest.java
@@ -20,6 +20,8 @@
package org.openecomp.sdc.be.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import mockit.Deencapsulation;
import org.javatuples.Pair;
import org.junit.Test;
@@ -49,7 +51,7 @@ public class ForwardingPathUtilsTest {
}
@Test
- public void testConvertServiceToServiceRelations() throws Exception {
+ public void testConvertServiceToServiceRelations() {
ForwardingPathUtils testSubject;
Service service = new Service();
ServiceRelations result;
@@ -57,6 +59,8 @@ public class ForwardingPathUtilsTest {
// default test
testSubject = createTestSubject();
result = testSubject.convertServiceToServiceRelations(service);
+ assertThat(result).isInstanceOf(ServiceRelations.class);
+
List<ComponentInstance> resourceInstances = new LinkedList<>();
ComponentInstance e = new ComponentInstance();
e.setCapabilities(new HashMap<>());
@@ -64,10 +68,11 @@ public class ForwardingPathUtilsTest {
service.setComponentInstances(resourceInstances);
result = testSubject.convertServiceToServiceRelations(service);
+ assertThat(result).isInstanceOf(ServiceRelations.class);
}
@Test
- public void testCreateWrapper() throws Exception {
+ public void testCreateWrapper() {
ForwardingPathUtils testSubject;
NameIdPair cpOption = new NameIdPair("mock", "mock");
NameIdPairWrapper result;
@@ -75,16 +80,19 @@ public class ForwardingPathUtilsTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "createWrapper", cpOption);
+ assertThat(result).isInstanceOf(NameIdPairWrapper.class);
+ assertThat(result.getId()).isEqualTo(cpOption.getId());
}
@Test
- public void testGetResponseFormatManager() throws Exception {
+ public void testGetResponseFormatManager() {
ForwardingPathUtils testSubject;
ResponseFormatManager result;
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "getResponseFormatManager");
+ assertThat(result).isInstanceOf(ResponseFormatManager.class);
}
@Test
@@ -99,10 +107,11 @@ public class ForwardingPathUtilsTest {
testSubject = createTestSubject();
result = testSubject.findForwardingPathNamesToDeleteOnComponentInstanceDeletion(containerService,
componentInstanceId);
+ assertThat(result).isInstanceOf(Set.class);
}
@Test
- public void testFindForwardingPathToDeleteOnCIDeletion() throws Exception {
+ public void testFindForwardingPathToDeleteOnCIDeletion() {
ForwardingPathUtils testSubject;
Service containerService = new Service();
containerService.setForwardingPaths(new HashMap<>());
@@ -113,10 +122,11 @@ public class ForwardingPathUtilsTest {
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "findForwardingPathToDeleteOnCIDeletion", containerService,
componentInstanceId);
+ assertThat(result).isInstanceOf(Map.class);
}
@Test
- public void testElementContainsCI_1() throws Exception {
+ public void testElementContainsCI_1() {
ForwardingPathUtils testSubject;
ForwardingPathElementDataDefinition elementDataDefinitions = new ForwardingPathElementDataDefinition();
elementDataDefinitions.setFromNode("mock");
@@ -126,10 +136,11 @@ public class ForwardingPathUtilsTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "elementContainsCI", elementDataDefinitions, componentInstanceId);
+ assertThat(result).isTrue();
}
@Test
- public void testUpdateForwardingPathOnVersionChange() throws Exception {
+ public void testUpdateForwardingPathOnVersionChange() {
ForwardingPathUtils testSubject;
Service containerService = new Service();
containerService.setForwardingPaths(new HashMap<>());
@@ -142,10 +153,11 @@ public class ForwardingPathUtilsTest {
testSubject = createTestSubject();
result = testSubject.updateForwardingPathOnVersionChange(containerService, dataHolder,
updatedContainerComponent, newInstanceId);
+ assertThat((Iterable<?>) result).isInstanceOf(Pair.class);
}
@Test
- public void testGetForwardingPathsToBeDeletedOnVersionChange() throws Exception {
+ public void testGetForwardingPathsToBeDeletedOnVersionChange() {
ForwardingPathUtils testSubject;
Service containerService = new Service();
containerService.setForwardingPaths(new HashMap<>());
@@ -157,10 +169,11 @@ public class ForwardingPathUtilsTest {
testSubject = createTestSubject();
result = testSubject.getForwardingPathsToBeDeletedOnVersionChange(containerService, dataHolder,
updatedContainerComponent);
+ assertThat(result).isInstanceOf(Set.class);
}
@Test
- public void testUpdateCI() throws Exception {
+ public void testUpdateCI() {
ForwardingPathUtils testSubject;
ForwardingPathDataDefinition inFP = new ForwardingPathDataDefinition();
inFP.setPathElements(new ListDataDefinition<>());
@@ -171,10 +184,13 @@ public class ForwardingPathUtilsTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "updateCI", inFP, oldCI, newCI);
+ assertThat(result)
+ .isInstanceOf(ForwardingPathDataDefinition.class)
+ .isNotSameAs(inFP);
}
@Test
- public void testUpdateElement() throws Exception {
+ public void testUpdateElement() {
ForwardingPathUtils testSubject;
ForwardingPathElementDataDefinition element = new ForwardingPathElementDataDefinition();
element.setFromNode("mock");
@@ -187,10 +203,13 @@ public class ForwardingPathUtilsTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "updateElement", element, oldCI, newCI);
+ assertThat(result)
+ .isInstanceOf(ForwardingPathElementDataDefinition.class)
+ .isNotSameAs(element);
}
@Test
- public void testElementContainsCIAndForwarder_1() throws Exception {
+ public void testElementContainsCIAndForwarder_1() {
ForwardingPathUtils testSubject;
ForwardingPathElementDataDefinition elementDataDefinitions = new ForwardingPathElementDataDefinition();
elementDataDefinitions.setFromNode("mock");
@@ -204,10 +223,11 @@ public class ForwardingPathUtilsTest {
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "elementContainsCIAndForwarder", elementDataDefinitions, oldCIId,
newCI);
+ assertThat(result).isFalse();
}
@Test
- public void testCiContainsForwarder() throws Exception {
+ public void testCiContainsForwarder() {
ForwardingPathUtils testSubject;
Component newCI = new Resource();
String capabilityID = "mock";
@@ -218,6 +238,7 @@ public class ForwardingPathUtilsTest {
result = Deencapsulation.invoke(testSubject, "ciContainsForwarder", newCI, capabilityID);
newCI.setCapabilities(new HashMap<>());
result = Deencapsulation.invoke(testSubject, "ciContainsForwarder", newCI, capabilityID);
+ assertThat(result).isFalse();
}
@Test
@@ -234,6 +255,7 @@ public class ForwardingPathUtilsTest {
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "elementContainsCIAndDoesNotContainForwarder",
forwardingPathDataDefinition, oldCIId, newCI);
+ assertThat(result).isFalse();
}
@Test
@@ -251,5 +273,6 @@ public class ForwardingPathUtilsTest {
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "elementContainsCIAndDoesNotContainForwarder",
elementDataDefinitions, oldCIId, newCI);
+ assertThat(result).isFalse();
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java
index cf0ec68bad..c9983183a7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java
@@ -20,43 +20,46 @@
package org.openecomp.sdc.be.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import com.google.gson.Gson;
+
+import mockit.Deencapsulation;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:application-context-test.xml"})
public class ServletUtilsTest {
-
- private ServletUtils createTestSubject() {
- return new ServletUtils();
- }
+ @Autowired
+ ServletUtils servletUtils;
@Test
- public void testGetComponentsUtils() throws Exception {
- ServletUtils testSubject;
- ComponentsUtils result;
-
+ public void testCtrServletUtils() {
// default test
- testSubject = createTestSubject();
- result = testSubject.getComponentsUtils();
- }
+ assertThat(servletUtils)
+ .isNotNull()
+ .isInstanceOf(ServletUtils.class);
- @Test
- public void testGetGson() throws Exception {
- ServletUtils testSubject;
- Gson result;
+ ComponentsUtils componentsUtils = Deencapsulation.getField(servletUtils, "componentsUtils");
+ UserBusinessLogic userBusinessLogic = Deencapsulation.getField(servletUtils, "userAdmin");
+ Gson gson = Deencapsulation.getField(servletUtils, "gson");
- // default test
- testSubject = createTestSubject();
- result = testSubject.getGson();
- }
-
- @Test
- public void testGetUserAdmin() throws Exception {
- ServletUtils testSubject;
- UserBusinessLogic result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUserAdmin();
+ assertThat(gson)
+ .isNotNull()
+ .isInstanceOf(Gson.class)
+ .isEqualTo(servletUtils.getGson());
+ assertThat(componentsUtils)
+ .isNotNull()
+ .isInstanceOf(ComponentsUtils.class)
+ .isEqualTo(servletUtils.getComponentsUtils());
+ assertThat(userBusinessLogic)
+ .isNotNull()
+ .isInstanceOf(UserBusinessLogic.class)
+ .isEqualTo(servletUtils.getUserAdmin());
}
}
diff --git a/catalog-be/src/test/resources/application-context-test.xml b/catalog-be/src/test/resources/application-context-test.xml
index a9de54cd12..c45680ca90 100644
--- a/catalog-be/src/test/resources/application-context-test.xml
+++ b/catalog-be/src/test/resources/application-context-test.xml
@@ -7,20 +7,26 @@
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:annotation-config />
- <aop:aspectj-autoproxy proxy-target-class="true" />
- <bean id="fileChangeListener" class=" org.openecomp.sdc.common.impl.ConfigFileChangeListener" />
- <bean id="fsConfig" class="org.openecomp.sdc.common.impl.FSConfigurationSource">
- <constructor-arg ref="fileChangeListener" />
- <constructor-arg value="src/test/resources/config/catalog-be"/>
- </bean>
- <bean class="org.openecomp.sdc.be.config.ConfigurationManager">
- <constructor-arg ref="fsConfig"/>
- </bean>
- <bean class="org.openecomp.sdc.be.components.distribution.engine.DmaapConsumer"/>
- <bean class="org.openecomp.sdc.be.components.distribution.engine.DmaapClientFactory" />
- <bean class="org.openecomp.sdc.be.components.distribution.engine.ExecutorFactory" />
- <bean class="org.openecomp.sdc.be.components.distribution.engine.DmaapHealth" />
- <bean class="org.openecomp.sdc.be.catalog.impl.DmaapProducerHealth" />
- <bean class="org.openecomp.sdc.be.catalog.impl.DmaapProducer" />
-
+ <aop:aspectj-autoproxy proxy-target-class="true"/>
+ <bean id="fileChangeListener" class=" org.openecomp.sdc.common.impl.ConfigFileChangeListener"/>
+ <bean id="fsConfig" class="org.openecomp.sdc.common.impl.FSConfigurationSource">
+ <constructor-arg ref="fileChangeListener"/>
+ <constructor-arg value="src/test/resources/config/catalog-be"/>
+ </bean>
+ <bean class="org.openecomp.sdc.be.config.ConfigurationManager">
+ <constructor-arg ref="fsConfig"/>
+ </bean>
+ <bean class="org.openecomp.sdc.be.components.distribution.engine.DmaapConsumer"/>
+ <bean class="org.openecomp.sdc.be.components.distribution.engine.DmaapClientFactory"/>
+ <bean class="org.openecomp.sdc.be.components.distribution.engine.ExecutorFactory"/>
+ <bean class="org.openecomp.sdc.be.components.distribution.engine.DmaapHealth"/>
+ <bean class="org.openecomp.sdc.be.catalog.impl.DmaapProducerHealth"/>
+ <bean class="org.openecomp.sdc.be.catalog.impl.DmaapProducer"/>
+ <bean class="org.openecomp.sdc.be.impl.ServletUtils"/>
+ <bean id="componentUtils" class="org.mockito.Mockito" factory-method="mock">
+ <constructor-arg value="org.openecomp.sdc.be.impl.ComponentsUtils" />
+ </bean>
+ <bean id="userAdmin" class="org.mockito.Mockito" factory-method="mock">
+ <constructor-arg value="org.openecomp.sdc.be.user.UserBusinessLogic" />
+ </bean>
</beans>