diff options
Diffstat (limited to 'cps-service/src/main/java/org')
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/spi/model/CmHandleQueryServiceParameters.java (renamed from cps-service/src/main/java/org/onap/cps/spi/model/CmHandleQueryParameters.java) | 2 | ||||
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/utils/CmHandleQueryRestParametersValidator.java | 43 |
2 files changed, 24 insertions, 21 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/CmHandleQueryParameters.java b/cps-service/src/main/java/org/onap/cps/spi/model/CmHandleQueryServiceParameters.java index cf364db3a..8dcf88b0e 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/model/CmHandleQueryParameters.java +++ b/cps-service/src/main/java/org/onap/cps/spi/model/CmHandleQueryServiceParameters.java @@ -34,7 +34,7 @@ import lombok.Setter; @Getter @EqualsAndHashCode @JsonInclude(Include.NON_EMPTY) -public class CmHandleQueryParameters { +public class CmHandleQueryServiceParameters { @JsonProperty("cmHandleQueryParameters") @Valid private List<ConditionProperties> cmHandleQueryParameters = Collections.emptyList(); 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 c510a73af..c3811eb48 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 @@ -27,7 +27,7 @@ import java.util.Map; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.onap.cps.spi.exceptions.DataValidationException; -import org.onap.cps.spi.model.CmHandleQueryParameters; +import org.onap.cps.spi.model.CmHandleQueryServiceParameters; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class CmHandleQueryRestParametersValidator { @@ -36,10 +36,11 @@ public class CmHandleQueryRestParametersValidator { /** * Validate cm handle query parameters. - * @param cmHandleQueryParameters name of data to be validated + * @param cmHandleQueryServiceParameters name of data to be validated */ - public static void validateCmHandleQueryParameters(final CmHandleQueryParameters cmHandleQueryParameters) { - cmHandleQueryParameters.getCmHandleQueryParameters().forEach( + public static void validateCmHandleQueryParameters( + final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) { + cmHandleQueryServiceParameters.getCmHandleQueryParameters().forEach( conditionApiProperty -> { if (Strings.isNullOrEmpty(conditionApiProperty.getConditionName())) { throwDataValidationException("Missing 'conditionName' - please supply a valid name."); @@ -54,27 +55,29 @@ public class CmHandleQueryRestParametersValidator { "Empty 'conditionsParameters' - please supply a valid condition parameter."); } conditionApiProperty.getConditionParameters().forEach( - conditionParameter -> { - if (conditionParameter.isEmpty()) { - throwDataValidationException( - "Empty 'conditionsParameter' - please supply a valid condition parameter."); - } - if (conditionParameter.size() > 1) { - throwDataValidationException("Too many name in one 'conditionsParameter' -" - + " please supply one name in one condition parameter."); - } - conditionParameter.forEach((key, value) -> { - if (Strings.isNullOrEmpty(key)) { - throwDataValidationException( - "Missing 'conditionsParameterName' - please supply a valid name."); - } - }); - } + CmHandleQueryRestParametersValidator::validateConditionParameter ); } ); } + private static void validateConditionParameter(final Map<String, String> conditionParameter) { + if (conditionParameter.isEmpty()) { + throwDataValidationException( + "Empty 'conditionsParameter' - please supply a valid condition parameter."); + } + if (conditionParameter.size() > 1) { + throwDataValidationException("Too many name in one 'conditionsParameter' -" + + " please supply one name in one condition parameter."); + } + conditionParameter.forEach((key, value) -> { + if (Strings.isNullOrEmpty(key)) { + throwDataValidationException( + "Missing 'conditionsParameterName' - please supply a valid name."); + } + }); + } + /** * Validate module name condition properties. * @param conditionProperty name of data to be validated |