diff options
author | Toine Siebelink <toine.siebelink@est.tech> | 2022-10-20 12:09:44 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-10-20 12:09:44 +0000 |
commit | 1377bf984e9d3ae97b1dc58c7d62ff1cafe60bb9 (patch) | |
tree | 41a2238c6beac0cd1c1d7e89b031d499c005f914 /cps-service/src/main | |
parent | b24639de32b2c89346d9888ba0acc9443babb2be (diff) | |
parent | abee011cb9437bf50e21a559c3d0176d2abbf011 (diff) |
Merge "Improve code coverage"
Diffstat (limited to 'cps-service/src/main')
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/utils/CmHandleQueryRestParametersValidator.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/utils/CmHandleQueryRestParametersValidator.java b/cps-service/src/main/java/org/onap/cps/utils/CmHandleQueryRestParametersValidator.java index 7fe47be2da..4d0eb7d412 100644 --- a/cps-service/src/main/java/org/onap/cps/utils/CmHandleQueryRestParametersValidator.java +++ b/cps-service/src/main/java/org/onap/cps/utils/CmHandleQueryRestParametersValidator.java @@ -42,16 +42,16 @@ public class CmHandleQueryRestParametersValidator { cmHandleQueryServiceParameters.getCmHandleQueryParameters().forEach( conditionApiProperty -> { if (Strings.isNullOrEmpty(conditionApiProperty.getConditionName())) { - throwDataValidationException("Missing 'conditionName' - please supply a valid name."); + throw createDataValidationException("Missing 'conditionName' - please supply a valid name."); } if (Arrays.stream(ValidQueryProperties.values()).noneMatch(validQueryProperty -> validQueryProperty.getQueryProperty().equals(conditionApiProperty.getConditionName()))) { - throwDataValidationException( + throw createDataValidationException( String.format("Wrong 'conditionName': %s - please supply a valid name.", conditionApiProperty.getConditionName())); } if (conditionApiProperty.getConditionParameters().isEmpty()) { - throwDataValidationException( + throw createDataValidationException( "Empty 'conditionsParameters' - please supply a valid condition parameter."); } conditionApiProperty.getConditionParameters().forEach( @@ -63,16 +63,16 @@ public class CmHandleQueryRestParametersValidator { private static void validateConditionParameter(final Map<String, String> conditionParameter) { if (conditionParameter.isEmpty()) { - throwDataValidationException( + throw createDataValidationException( "Empty 'conditionsParameter' - please supply a valid condition parameter."); } if (conditionParameter.size() > 1) { - throwDataValidationException("Too many name in one 'conditionsParameter' -" + throw createDataValidationException("Too many name in one 'conditionsParameter' -" + " please supply one name in one condition parameter."); } conditionParameter.forEach((key, value) -> { if (Strings.isNullOrEmpty(key)) { - throwDataValidationException( + throw createDataValidationException( "Missing 'conditionsParameterName' - please supply a valid name."); } }); @@ -86,7 +86,8 @@ public class CmHandleQueryRestParametersValidator { if (conditionProperty.containsKey("moduleName") && !conditionProperty.get("moduleName").isEmpty()) { return; } - throwDataValidationException("Wrong module condition property. - please supply a valid condition property."); + throw createDataValidationException("Wrong module condition property. - " + + "please supply a valid condition property."); } /** @@ -98,15 +99,15 @@ public class CmHandleQueryRestParametersValidator { return true; } if (conditionProperty.size() > 1) { - throwDataValidationException("Only one condition property is allowed for the CPS path query."); + throw createDataValidationException("Only one condition property is allowed for the CPS path query."); } if (!conditionProperty.containsKey("cpsPath")) { - throwDataValidationException( + throw createDataValidationException( "Wrong CPS path condition property. - expecting \"cpsPath\" as the condition property."); } final String cpsPath = conditionProperty.get("cpsPath"); if (cpsPath.isBlank()) { - throwDataValidationException( + throw createDataValidationException( "Wrong CPS path. - please supply a valid CPS path."); } if (cpsPath.contains("/additional-properties")) { @@ -117,8 +118,8 @@ public class CmHandleQueryRestParametersValidator { return true; } - private static void throwDataValidationException(final String details) { - throw new DataValidationException("Invalid Query Parameter.", details); + private static DataValidationException createDataValidationException(final String details) { + return new DataValidationException("Invalid Query Parameter.", details); } } |