diff options
Diffstat (limited to 'common-app-api')
3 files changed, 14 insertions, 47 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java index a0403de8ff..7c5e5fc1eb 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java @@ -215,7 +215,7 @@ public class ValidationUtils { } public static boolean validateResourceInstanceNameLength(String resourceInstanceName) { - return resourceInstanceName.length() <= RSI_NAME_MAX_LENGTH; + return StringUtils.isEmpty(resourceInstanceName) || resourceInstanceName.length() <= RSI_NAME_MAX_LENGTH; } public static boolean validateResourceInstanceName(String resourceInstanceName) { @@ -223,7 +223,7 @@ public class ValidationUtils { } public static boolean validateUrlLength(String url) { - return url.length() <= API_URL_LENGTH; + return StringUtils.isEmpty(url) || url.length() <= API_URL_LENGTH; } public static boolean validateArtifactNameLength(String artifactName) { @@ -235,7 +235,7 @@ public class ValidationUtils { } public static boolean validateComponentNameLength(String componentName) { - return componentName.length() <= COMPONENT_NAME_MAX_LENGTH; + return StringUtils.isEmpty(componentName) || componentName.length() <= COMPONENT_NAME_MAX_LENGTH; } public static boolean validateIcon(String icon) { @@ -243,7 +243,7 @@ public class ValidationUtils { } public static boolean validateIconLength(String icon) { - return icon.length() <= ICON_MAX_LENGTH; + return StringUtils.isEmpty(icon) || icon.length() <= ICON_MAX_LENGTH; } public static boolean validateProjectCode(String projectCode) { @@ -251,7 +251,7 @@ public class ValidationUtils { } public static boolean validateProjectCodeLegth(String projectCode) { - return projectCode.length() <= PROJECT_CODE_MAX_LEGTH; + return StringUtils.isEmpty(projectCode) || projectCode.length() <= PROJECT_CODE_MAX_LEGTH; } public static boolean validateContactId(String contactId) { @@ -340,14 +340,7 @@ public class ValidationUtils { } public static boolean validateDescriptionLength(String description) { - return description.length() <= COMPONENT_DESCRIPTION_MAX_LENGTH; - } - - public static boolean validateStringNotEmpty(String value) { - if ((value == null) || (value.isEmpty())) { - return false; - } - return true; + return StringUtils.isEmpty(description) || description.length() <= COMPONENT_DESCRIPTION_MAX_LENGTH; } public static boolean validateListNotEmpty(List<?> list) { @@ -362,35 +355,35 @@ public class ValidationUtils { } public static boolean validateVendorNameLength(String vendorName) { - return vendorName.length() <= VENDOR_NAME_MAX_LENGTH; + return StringUtils.isEmpty(vendorName) || vendorName.length() <= VENDOR_NAME_MAX_LENGTH; } public static boolean validateResourceVendorModelNumberLength(String resourceVendorModelNumber) { - return resourceVendorModelNumber.length() <= RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH; + return StringUtils.isEmpty(resourceVendorModelNumber) || resourceVendorModelNumber.length() <= RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH; } public static boolean validateVendorRelease(String vendorRelease) { - return VENDOR_RELEASE_PATTERN.matcher(vendorRelease).matches(); + return StringUtils.isEmpty(vendorRelease) || VENDOR_RELEASE_PATTERN.matcher(vendorRelease).matches(); } public static boolean validateVendorReleaseLength(String vendorRelease) { - return vendorRelease.length() <= VENDOR_RELEASE_MAX_LENGTH; + return StringUtils.isEmpty(vendorRelease) || vendorRelease.length() <= VENDOR_RELEASE_MAX_LENGTH; } public static boolean validateServiceTypeLength(String serviceType) { - return serviceType.length() <= SERVICE_TYPE_MAX_LENGTH; + return StringUtils.isEmpty(serviceType) || serviceType.length() <= SERVICE_TYPE_MAX_LENGTH; } public static boolean validateServiceRoleLength(String serviceRole) { - return serviceRole.length() <= SERVICE_ROLE_MAX_LENGTH; + return StringUtils.isEmpty(serviceRole) || serviceRole.length() <= SERVICE_ROLE_MAX_LENGTH; } public static boolean validateServiceFunctionLength(String serviceFunction) { - return serviceFunction.length() <= SERVICE_FUNCTION_MAX_LENGTH; + return StringUtils.isEmpty(serviceFunction) || serviceFunction.length() <= SERVICE_FUNCTION_MAX_LENGTH; } public static boolean validateServiceNamingPolicyLength(String namingPolicy) { - return namingPolicy.length() <= SERVICE_NAMING_POLICY_MAX_SIZE; + return StringUtils.isEmpty(namingPolicy) || namingPolicy.length() <= SERVICE_NAMING_POLICY_MAX_SIZE; } public static boolean hasBeenCertified(String version) { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java index 73d8c116e2..ca9cc0b068 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java @@ -225,14 +225,6 @@ public class CommonUtilsTest { } @Test - public void validateStringNotEmptyTest() { - assertTrue(ValidationUtils.validateStringNotEmpty("fsdlfsdlk")); - assertFalse(ValidationUtils.validateStringNotEmpty("")); - assertFalse(!ValidationUtils.validateStringNotEmpty(" ")); - assertFalse(!ValidationUtils.validateStringNotEmpty(" ")); - } - - @Test public void validateVendorNameTest() { assertTrue(ValidationUtils.validateVendorName("fsdlfsdlk")); assertTrue(ValidationUtils.validateVendorName("fsdlfsdlk.sdsd;")); diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java index e7aad96f60..3408c684de 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java @@ -526,24 +526,6 @@ public class ValidationUtilsTest { } @Test - public void checkValidateStringNotEmptyReturnsFalseIfStringIsNotEmpty() { - final String testString = "test"; - - boolean result = ValidationUtils.validateStringNotEmpty(testString); - - assertTrue(result); - } - - @Test - public void checkValidateStringNotEmptyReturnsFTrueIfStringIsEmpty() { - final String testString = ""; - - boolean result = ValidationUtils.validateStringNotEmpty(testString); - - assertFalse(result); - } - - @Test public void checkValidateVendorNameReturnsTrueIfNameFitsPattern() { final String testVendorName = "testVendor"; |