summaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org/onap
diff options
context:
space:
mode:
authorkissand <andras.zoltan.kiss@est.tech>2022-06-13 10:55:49 +0200
committerkissand <andras.zoltan.kiss@est.tech>2022-06-13 10:55:49 +0200
commitf696068ae5cced10c0fdf6a1686c4eadbdfdfff0 (patch)
treeaa43df1511e2635e0f7f3041a83a29ed21ff27a3 /cps-service/src/main/java/org/onap
parent708d2b566a8b8cdf48e1dfe337369c946cec0e02 (diff)
Fix sonar code smells
- https://sonarcloud.io/project/issues?resolved=false&types=CODE_SMELL&id=onap_cps&open=AYFC3OguDZ5Vb3SQMOU1 Issue-ID: CPS-1016 Change-Id: Ic8fdae78337da1ff2c239ae2dfae67e23e88a4bb Signed-off-by: kissand <andras.zoltan.kiss@est.tech>
Diffstat (limited to 'cps-service/src/main/java/org/onap')
-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.java43
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 cf364db3a8..8dcf88b0eb 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 c510a73af2..c3811eb485 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