summaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org
diff options
context:
space:
mode:
authorleventecsanyi <levente.csanyi@est.tech>2022-10-19 11:52:44 +0200
committerleventecsanyi <levente.csanyi@est.tech>2022-10-19 16:04:37 +0200
commitabee011cb9437bf50e21a559c3d0176d2abbf011 (patch)
tree1b2127fb6d2d6e09dc6afb65c2386e77bba27c8e /cps-service/src/main/java/org
parent72c267e06b4a8e5ec52dcfdd10581ed732076c90 (diff)
Improve code coverage
- Fixed and refactored unit test to get over the 97% coverage baseline. - Removed unused exception. Issue-ID: CPS-475 Change-Id: I6dbcba58b880a584f6d9346e2aca6c763e5d2081 Signed-off-by: leventecsanyi <levente.csanyi@est.tech>
Diffstat (limited to 'cps-service/src/main/java/org')
-rw-r--r--cps-service/src/main/java/org/onap/cps/utils/CmHandleQueryRestParametersValidator.java25
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);
}
}