summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-08-29 15:29:59 +0100
committerMichael Morris <michael.morris@est.tech>2023-09-05 09:50:12 +0000
commit438650c3a958c9176db3720204ec1ff9af94fc3a (patch)
treef0dc5b6b5bd837a6f689245e8a41d36d0a488f9b /catalog-be/src/test
parent0c47a1b7118b45eecbbb0064b635efb026173ec4 (diff)
Improve handling 'empty'/null string in Service fields
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ib301280fe1be2896e2d80e208349ac3c4ff763ec Issue-ID: SDC-4608
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java17
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java12
4 files changed, 7 insertions, 26 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
index 049f8a5541..41dc5736c3 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
@@ -120,7 +120,7 @@ class ServiceBusinessLogicBaseTestSetup extends BaseBusinessLogicMock {
protected ResourceAdminEvent auditArchive2 = Mockito.mock(ResourceAdminEvent.class);
protected ResourceAdminEvent auditRestore = Mockito.mock(ResourceAdminEvent.class);
protected ModelOperation modelOperation = Mockito.mock(ModelOperation.class);
- protected ServiceTypeValidator serviceTypeValidator = new ServiceTypeValidator(componentsUtils);
+ protected ServiceTypeValidator serviceTypeValidator = new ServiceTypeValidator();
protected ServiceRoleValidator serviceRoleValidator = new ServiceRoleValidator(componentsUtils);
protected ServiceFunctionValidator serviceFunctionValidator = new ServiceFunctionValidator(componentsUtils);
protected ServiceInstantiationTypeValidator serviceInstantiationTypeValidator = new ServiceInstantiationTypeValidator(componentsUtils);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
index 416703637f..407956db0e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
@@ -154,7 +154,6 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
assertTrue(createResponse.isLeft());
}
-
@Test
void testCreateServiceWhenGenericTypeHasProperties() {
final Service service = createServiceObject(false);
@@ -255,8 +254,6 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
actualService.getProperties(), is(expectedService.getProperties()));
}
-
-
/* CREATE validations - start ***********************/
// Service name - start
@@ -644,7 +641,6 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
fail();
}
-
private void testProjectCodeTooShort() {
Service serviceExist = createServiceObject(false);
@@ -701,7 +697,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
eitherService.left().value().setArchived(false);
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
final ComponentException actualException = assertThrows(ComponentException.class, () -> bl.deleteServiceAllVersions(serviceId, user));
- assertEquals(actualException.getActionStatus(), ActionStatus.COMPONENT_NOT_ARCHIVED);
+ assertEquals(ActionStatus.COMPONENT_NOT_ARCHIVED, actualException.getActionStatus());
assertEquals(actualException.getParams()[0], serviceId);
}
@@ -893,16 +889,16 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
newService.setServiceType("");
resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
- //null is invalid
+ //null is valid
newService.setServiceType(null);
resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
- assertThat(resultOfUpdate.isRight()).isTrue();
+ assertThat(resultOfUpdate.isLeft()).isTrue();
}
@Test
void testCreateDefaultMetadataServiceFunction() {
Service currentService = createServiceObject(true);
- assertThat(currentService.getServiceFunction()).isEqualTo("");
+ assertThat(currentService.getServiceFunction()).isEmpty();
}
@Test
@@ -933,10 +929,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
newService.setServiceFunction(null);
resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
- assertThat(updatedService.getServiceFunction()).isEqualTo("");
+ assertThat(updatedService.getServiceFunction()).isEmpty();
}
-
@Test
void testServiceFunctionExceedLength() {
String serviceName = "Service";
@@ -1096,7 +1091,6 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
return propertyList;
}
-
@Test
void testCreateService_withMultitenancyValidTenant_Success() {
Assert.assertTrue(MULTITENANCY_ENABLED);
@@ -1113,7 +1107,6 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
assertEqualsServiceObject(createServiceObject(true), createResponse.left().value());
}
-
@Test
void testCreateService_withMultitenancyInvalidTenant_Failure() {
Service service = createServiceObject(false);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
index 45e7f4a7ad..df53faa3b7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
@@ -143,7 +143,7 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM
protected UserValidations userValidations = mock(UserValidations.class);
protected CatalogOperation catalogOperation = mock(CatalogOperation.class);
protected ServiceImportParseLogic serviceImportParseLogic = mock(ServiceImportParseLogic.class);
- protected ServiceTypeValidator serviceTypeValidator = new ServiceTypeValidator(componentsUtils);
+ protected ServiceTypeValidator serviceTypeValidator = new ServiceTypeValidator();
protected ServiceRoleValidator serviceRoleValidator = new ServiceRoleValidator(componentsUtils);
protected ServiceFunctionValidator serviceFunctionValidator = new ServiceFunctionValidator(componentsUtils);
protected ServiceInstantiationTypeValidator serviceInstantiationTypeValidator = new ServiceInstantiationTypeValidator(componentsUtils);
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 0fb88a531b..5acc1fd116 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
@@ -563,18 +563,6 @@ class ComponentsUtilsTest {
}
@Test
- void testValidateStringNotEmpty() {
- ComponentsUtils testSubject;
- String value = "";
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.validateStringNotEmpty(value);
- assertThat(result).isFalse();
- }
-
- @Test
void testConvertFromStorageResponseForAdditionalInformation() {
ComponentsUtils testSubject;
StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;