aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-04-26 18:16:36 -0400
committerJim Hahn <jrh3@att.com>2021-04-29 11:35:02 -0400
commit4fdecb037bd2609a6b977adba6d2f263c977d9e1 (patch)
treecac0861d73c073e33e2b677fc6c9356e3dcf3574
parent6e589fc31f69482d2cf5bf57c733094394439b0f (diff)
Remove GroupValidationResult
Removed GroupValidationResult, replacing it with BeanValidationResult. Modified the ParameterGroup subclasses to use BeanValidator, adding annotations where needed to trigger the validations that had been automatically performed by GroupValidationResult. Issue-ID: POLICY-2059 Change-Id: I245e4a647fcbb718faa63a7543f9f81c85da958c Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModel.java7
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfValidator.java10
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/Validated.java8
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java3
-rw-r--r--models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorGrpcClient.java6
-rw-r--r--models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java11
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java10
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java9
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java9
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java38
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java5
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java5
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java6
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java4
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java6
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java30
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java4
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java8
-rw-r--r--models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/CdsServerParameters.java11
-rw-r--r--models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java25
-rw-r--r--models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java27
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java6
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java9
23 files changed, 96 insertions, 161 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
index 8cdcb90b7..a73616df9 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
@@ -33,7 +33,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.utils.validation.Assertions;
@@ -236,14 +235,12 @@ public abstract class PfModel extends PfConcept {
if (usedKey.getKey() instanceof PfConceptKey) {
// PfConceptKey usage, check the key exists
if (!artifactKeySet.contains(usedKey.getKey())) {
- result.addResult(new ObjectValidationResult("artifact key", usedKey.getId(),
- ValidationStatus.INVALID, NOT_DEFINED));
+ result.addResult("artifact key", usedKey.getId(), ValidationStatus.INVALID, NOT_DEFINED);
}
} else {
// PfReferenceKey usage, check the key exists
if (!referenceKeySet.contains(usedKey.getKey())) {
- result.addResult(new ObjectValidationResult("reference key", usedKey.getId(),
- ValidationStatus.INVALID, NOT_DEFINED));
+ result.addResult("reference key", usedKey.getId(), ValidationStatus.INVALID, NOT_DEFINED);
}
}
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java b/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
index cbe9c2ca7..57cc3c81f 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
@@ -22,7 +22,6 @@ package org.onap.policy.models.base;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.BeanValidator;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.ValueValidator;
@@ -100,8 +99,7 @@ public class PfValidator extends BeanValidator {
PfKey pfkey = (PfKey) value;
if (annot.keyNotNull() && pfkey.isNullKey()) {
- result.addResult(new ObjectValidationResult(fieldName, xlate(pfkey), ValidationStatus.INVALID,
- Validated.IS_A_NULL_KEY));
+ result.addResult(fieldName, xlate(pfkey), ValidationStatus.INVALID, Validated.IS_A_NULL_KEY);
return false;
}
@@ -118,13 +116,11 @@ public class PfValidator extends BeanValidator {
PfKeyImpl keyimpl = (PfKeyImpl) pfkey;
if (annot.nameNotNull() && keyimpl.isNullName()) {
- result2.addResult(new ObjectValidationResult("name", pfkey.getName(), ValidationStatus.INVALID,
- Validated.IS_NULL));
+ result2.addResult("name", pfkey.getName(), ValidationStatus.INVALID, Validated.IS_NULL);
}
if (annot.versionNotNull() && keyimpl.isNullVersion()) {
- result2.addResult(new ObjectValidationResult("version", pfkey.getVersion(), ValidationStatus.INVALID,
- Validated.IS_NULL));
+ result2.addResult("version", pfkey.getVersion(), ValidationStatus.INVALID, Validated.IS_NULL);
}
if (!result2.isClean()) {
diff --git a/models-base/src/main/java/org/onap/policy/models/base/Validated.java b/models-base/src/main/java/org/onap/policy/models/base/Validated.java
index 5ec6ab7f7..6ed1a845a 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/Validated.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/Validated.java
@@ -61,8 +61,7 @@ public class Validated {
*/
public static void addResult(@NonNull BeanValidationResult result, @NonNull String fieldName, Object value,
@NonNull String errorMessage) {
- result.addResult(
- new ObjectValidationResult(fieldName, getKeyId(value), ValidationStatus.INVALID, errorMessage));
+ result.addResult(fieldName, getKeyId(value), ValidationStatus.INVALID, errorMessage);
}
/**
@@ -85,13 +84,12 @@ public class Validated {
*/
public static void validateKeyNotNull(BeanValidationResult result, @NonNull String fieldName, PfKey key) {
if (key == null) {
- result.addResult(new ObjectValidationResult(fieldName, key, ValidationStatus.INVALID, IS_A_NULL_KEY));
+ result.addResult(fieldName, key, ValidationStatus.INVALID, IS_A_NULL_KEY);
return;
}
if (key.isNullKey()) {
- result.addResult(new ObjectValidationResult(fieldName, key.getId(), ValidationStatus.INVALID,
- IS_A_NULL_KEY));
+ result.addResult(fieldName, key.getId(), ValidationStatus.INVALID, IS_A_NULL_KEY);
return;
}
diff --git a/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java b/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
index 8fa757a00..98dfe8919 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
@@ -30,7 +30,6 @@ import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.junit.Test;
import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.utils.coder.CoderException;
@@ -163,7 +162,7 @@ public class ValidatedTest {
}
BeanValidationResult result = new BeanValidationResult(fieldName, this);
- result.addResult(new ObjectValidationResult(fieldName, text, ValidationStatus.INVALID, NOT_SAME));
+ result.addResult(fieldName, text, ValidationStatus.INVALID, NOT_SAME);
return result;
}
}
diff --git a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorGrpcClient.java b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorGrpcClient.java
index 2dc128fd7..29fa687c0 100644
--- a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorGrpcClient.java
+++ b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorGrpcClient.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Bell Canada.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import java.util.concurrent.CountDownLatch;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
import org.onap.policy.cds.api.CdsProcessorListener;
import org.onap.policy.cds.properties.CdsServerProperties;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,7 +50,7 @@ public class CdsProcessorGrpcClient implements AutoCloseable {
* @param listener the listener to listen on
*/
public CdsProcessorGrpcClient(final CdsProcessorListener listener, CdsServerProperties props) {
- final GroupValidationResult validationResult = props.validate();
+ final ValidationResult validationResult = props.validate();
Preconditions.checkState(validationResult.getStatus().isValid(), "Error validating CDS server "
+ "properties: " + validationResult.getResult());
diff --git a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java
index 1b3149089..1c3eab805 100644
--- a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java
+++ b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +24,7 @@ import java.util.Base64;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.ParameterRuntimeException;
import org.onap.policy.common.parameters.annotations.Max;
import org.onap.policy.common.parameters.annotations.Min;
@@ -33,7 +33,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@Getter
@Setter
@ToString
-public class CdsServerProperties implements ParameterGroup {
+public class CdsServerProperties extends ParameterGroupImpl {
// Port range constants
private static final int MIN_USER_PORT = 1024;
@@ -71,11 +71,6 @@ public class CdsServerProperties implements ParameterGroup {
throw new ParameterRuntimeException("The name of this ParameterGroup implementation is always " + getName());
}
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
-
/**
* Generate base64-encoded Authorization header from username and password.
*
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java
index d98f6ed30..8746c0721 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.PfUtils;
@@ -70,8 +69,7 @@ public class DeploymentGroup {
result.validateNotNullList(SUBGROUP_FIELD, deploymentSubgroups, DeploymentSubGroup::validatePapRest);
if (deploymentSubgroups != null && deploymentSubgroups.isEmpty()) {
- result.addResult(new ObjectValidationResult(SUBGROUP_FIELD, deploymentSubgroups, ValidationStatus.INVALID,
- "is empty"));
+ result.addResult(SUBGROUP_FIELD, deploymentSubgroups, ValidationStatus.INVALID, "is empty");
}
checkDuplicateSubgroups(result);
@@ -102,8 +100,8 @@ public class DeploymentGroup {
if (curact != null && action == Action.PATCH) {
BeanValidationResult subResult = new BeanValidationResult(pdpType, pdpType);
- subResult.addResult(new ObjectValidationResult("action", action, ValidationStatus.INVALID,
- "incompatible with previous action: " + curact));
+ subResult.addResult("action", action, ValidationStatus.INVALID,
+ "incompatible with previous action: " + curact);
BeanValidationResult subResult2 = new BeanValidationResult(SUBGROUP_FIELD, subgrp);
subResult2.addResult(subResult);
result.addResult(subResult2);
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java
index b6886bef1..6d7607924 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,6 @@ import java.util.stream.Collectors;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.PfKey;
@@ -96,8 +95,7 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> {
(PdpSubGroup pdpSubGroup) -> pdpSubGroup.validatePapRest(updateGroupFlow));
if (pdpSubgroups != null && pdpSubgroups.isEmpty()) {
- result.addResult(new ObjectValidationResult(SUBGROUP_FIELD, pdpSubgroups, ValidationStatus.INVALID,
- "is empty"));
+ result.addResult(SUBGROUP_FIELD, pdpSubgroups, ValidationStatus.INVALID, "is empty");
}
checkDuplicateSubgroups(result);
@@ -122,8 +120,7 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> {
}
// different sizes implies duplicates
- result.addResult(new ObjectValidationResult(SUBGROUP_FIELD, pdpTypes, ValidationStatus.INVALID,
- "duplicate subgroups"));
+ result.addResult(SUBGROUP_FIELD, pdpTypes, ValidationStatus.INVALID, "duplicate subgroups");
}
@Override
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
index bfd9dac95..0e9554d03 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import java.util.Map;
import lombok.Data;
import lombok.NonNull;
import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.PfUtils;
@@ -91,14 +90,12 @@ public class PdpSubGroup {
ToscaConceptIdentifier::validatePapRest);
if (supportedPolicyTypes != null && supportedPolicyTypes.isEmpty()) {
- result.addResult(new ObjectValidationResult("supportedPolicyTypes", supportedPolicyTypes,
- ValidationStatus.INVALID, "empty list"));
+ result.addResult("supportedPolicyTypes", supportedPolicyTypes, ValidationStatus.INVALID, "empty list");
}
}
if (desiredInstanceCount <= 0) {
- result.addResult(new ObjectValidationResult("desiredInstanceCount", desiredInstanceCount,
- ValidationStatus.INVALID, "non-positive"));
+ result.addResult("desiredInstanceCount", desiredInstanceCount, ValidationStatus.INVALID, "non-positive");
}
return result;
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java
index 19345553b..bcd14c82b 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java
@@ -23,10 +23,11 @@
package org.onap.policy.models.provider;
import lombok.Data;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.BeanValidator;
import org.onap.policy.common.parameters.ParameterGroup;
-import org.onap.policy.common.parameters.ValidationStatus;
-import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl;
// @formatter:off
@@ -55,42 +56,25 @@ public class PolicyModelsProviderParameters implements ParameterGroup {
private static final String DEFAULT_IMPLEMENTATION = DatabasePolicyModelsProviderImpl.class.getName();
private String name;
+ @NotNull @NotBlank
private String implementation = DEFAULT_IMPLEMENTATION;
private String databaseType;
+ @NotNull @NotBlank
private String databaseDriver;
+ @NotNull @NotBlank
private String databaseUrl;
private String databaseUser;
private String databasePassword;
+ @NotNull @NotBlank
private String persistenceUnit;
/**
* Validate the model provider parameters.
*
*/
- @Override
- public GroupValidationResult validate() {
- final GroupValidationResult validationResult = new GroupValidationResult(this);
-
- if (!ParameterValidationUtils.validateStringParameter(implementation)) {
- validationResult.setResult("implementation", ValidationStatus.INVALID,
- "a PolicyModelsProvider implementation must be specified");
- }
-
- if (!ParameterValidationUtils.validateStringParameter(databaseDriver)) {
- validationResult.setResult("databaseUrl", ValidationStatus.INVALID,
- "a driver must be specified for the JDBC connection to the database");
- }
- if (!ParameterValidationUtils.validateStringParameter(databaseUrl)) {
- validationResult.setResult("databaseUrl", ValidationStatus.INVALID,
- "a URL must be specified for the JDBC connection to the database");
- }
-
- if (!ParameterValidationUtils.validateStringParameter(persistenceUnit)) {
- validationResult.setResult("persistenceUnit", ValidationStatus.INVALID,
- "a persistence unit must be specified for connecting to the database");
- }
-
- return validationResult;
+ @Override
+ public BeanValidationResult validate() {
+ return new BeanValidator().validateTop(getClass().getSimpleName(), this);
}
}
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
index 51771ff9a..b1ae2a876 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +25,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
/**
* Test of {@link PolicyModelsProviderParameters} class.
@@ -40,7 +41,7 @@ public class PolicyModelsProviderParametersTest {
pars.setDatabaseUrl("jdbc://www.acmecorp/roadrunner");
pars.setPersistenceUnit("WileECoyote");
- GroupValidationResult result = pars.validate();
+ ValidationResult result = pars.validate();
assertTrue(result.isValid());
pars.setImplementation(null);
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java
index 9719ae93f..af5e4fd46 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterGroup.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
/**
* Class to hold all parameters needed for the DMaaP simulator component.
@@ -34,7 +35,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@NotBlank
@Getter
public class DmaapSimParameterGroup extends ParameterGroupImpl {
- private RestServerParameters restServerParameters;
+ private @Valid RestServerParameters restServerParameters;
/**
* Frequency, in seconds, with which to sweep the topics of idle consumers. On each
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java
index 2ade27d83..4485defaa 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/parameters/DmaapSimParameterHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
package org.onap.policy.models.sim.dmaap.parameters;
import java.io.File;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -70,7 +70,7 @@ public class DmaapSimParameterHandler {
}
// validate the parameters
- final GroupValidationResult validationResult = dmaapSimParameterGroup.validate();
+ final ValidationResult validationResult = dmaapSimParameterGroup.validate();
if (!validationResult.isValid()) {
String returnMessage =
"validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java
index 1b4df7bc6..677d8a7d5 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
/**
* Class to hold all parameters needed for pdp simulator component.
@@ -35,7 +37,9 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@NotBlank
@Getter
public class PdpSimulatorParameterGroup extends ParameterGroupImpl {
+ @Valid
private PdpStatusParameters pdpStatusParameters;
+ @Valid
private TopicParameterGroup topicParameterGroup;
/**
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java
index 84ae53908..bf514f2e9 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
package org.onap.policy.models.sim.pdp.parameters;
import java.io.File;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -72,7 +72,7 @@ public class PdpSimulatorParameterHandler {
}
// validate the parameters
- final GroupValidationResult validationResult = pdpSimulatorParameterGroup.validate();
+ final ValidationResult validationResult = pdpSimulatorParameterGroup.validate();
if (!validationResult.isValid()) {
String returnMessage =
"validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java
index 524fd572e..b7d13ef79 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
package org.onap.policy.models.sim.pdp.parameters;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -27,7 +29,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Map;
import org.junit.Test;
import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
/**
* Class to perform unit test of {@link PdpSimulatorParameterGroup}.
@@ -50,7 +52,7 @@ public class TestPdpSimulatorParameterGroup {
PdpSimulatorParameterGroup.class);
final PdpStatusParameters pdpStatusParameters = pdpSimulatorParameters.getPdpStatusParameters();
final TopicParameterGroup topicParameterGroup = pdpSimulatorParameters.getTopicParameterGroup();
- final GroupValidationResult validationResult = pdpSimulatorParameters.validate();
+ final ValidationResult validationResult = pdpSimulatorParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.PDP_SIMULATOR_GROUP_NAME, pdpSimulatorParameters.getName());
assertEquals(CommonTestData.TIME_INTERVAL, pdpStatusParameters.getTimeIntervalMs());
@@ -65,7 +67,7 @@ public class TestPdpSimulatorParameterGroup {
public void testPdpSimulatorParameterGroup_NullName() {
final PdpSimulatorParameterGroup pdpSimulatorParameters = commonTestData
.toObject(commonTestData.getPdpSimulatorParameterGroupMap(null), PdpSimulatorParameterGroup.class);
- final GroupValidationResult validationResult = pdpSimulatorParameters.validate();
+ final ValidationResult validationResult = pdpSimulatorParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, pdpSimulatorParameters.getName());
assertTrue(validationResult.getResult().contains("is null"));
@@ -75,11 +77,11 @@ public class TestPdpSimulatorParameterGroup {
public void testPdpSimulatorParameterGroup_EmptyName() {
final PdpSimulatorParameterGroup pdpSimulatorParameters = commonTestData
.toObject(commonTestData.getPdpSimulatorParameterGroupMap(""), PdpSimulatorParameterGroup.class);
- final GroupValidationResult validationResult = pdpSimulatorParameters.validate();
+ final ValidationResult validationResult = pdpSimulatorParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", pdpSimulatorParameters.getName());
- assertTrue(validationResult.getResult().contains(
- "field \"name\" type \"java.lang.String\" value \"\" INVALID, " + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains(
+ "\"name\" value \"\" INVALID, " + "is blank");
}
@Test
@@ -88,7 +90,7 @@ public class TestPdpSimulatorParameterGroup {
commonTestData.getPdpSimulatorParameterGroupMap(CommonTestData.PDP_SIMULATOR_GROUP_NAME),
PdpSimulatorParameterGroup.class);
pdpSimulatorParameters.setName("PdpSimulatorNewGroup");
- final GroupValidationResult validationResult = pdpSimulatorParameters.validate();
+ final ValidationResult validationResult = pdpSimulatorParameters.validate();
assertTrue(validationResult.isValid());
assertEquals("PdpSimulatorNewGroup", pdpSimulatorParameters.getName());
}
@@ -100,11 +102,10 @@ public class TestPdpSimulatorParameterGroup {
map.put("pdpStatusParameters", commonTestData.getPdpStatusParametersMap(true));
final PdpSimulatorParameterGroup pdpSimulatorParameters =
commonTestData.toObject(map, PdpSimulatorParameterGroup.class);
- final GroupValidationResult validationResult = pdpSimulatorParameters.validate();
+ final ValidationResult validationResult = pdpSimulatorParameters.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.models.sim.pdp.parameters.PdpSimulatorParameterGroup\" INVALID, "
- + "parameter group has status INVALID"));
+ assertThat(validationResult.getResult())
+ .contains("\"PdpSimulatorParameterGroup\" INVALID, item has status INVALID");
}
@Test
@@ -115,11 +116,10 @@ public class TestPdpSimulatorParameterGroup {
final PdpSimulatorParameterGroup parGroup =
commonTestData.toObject(map, PdpSimulatorParameterGroup.class);
- final GroupValidationResult validationResult = parGroup.validate();
+ final ValidationResult validationResult = parGroup.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.common.endpoints.parameters.TopicParameterGroup\" INVALID, "
- + "parameter group has status INVALID"));
+ assertThat(validationResult.getResult())
+ .contains("\"TopicParameterGroup\" INVALID, item has status INVALID");
}
}
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java
index 3ac99f407..03c73cceb 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -111,7 +111,7 @@ public class TestPdpSimulatorParameterHandler {
arguments.parse(pdpSimulatorConfigParameters);
assertThatThrownBy(() -> new PdpSimulatorParameterHandler().getParameters(arguments)).hasMessageContaining(
- "field \"name\" type \"java.lang.String\" value \" \" INVALID, must be a non-blank string");
+ "\"name\" value \" \" INVALID, is blank");
}
@Test
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java
index 1798bb2f5..09ad29547 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
/**
* Class to perform unit test of {@link PdpStatusParameters}.
@@ -40,7 +40,7 @@ public class TestPdpStatusParameters {
public void test() {
final PdpStatusParameters pdpStatusParameters =
testData.toObject(testData.getPdpStatusParametersMap(false), PdpStatusParameters.class);
- final GroupValidationResult validationResult = pdpStatusParameters.validate();
+ final ValidationResult validationResult = pdpStatusParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.TIME_INTERVAL, pdpStatusParameters.getTimeIntervalMs());
assertEquals(CommonTestData.PDP_TYPE, pdpStatusParameters.getPdpType());
@@ -53,7 +53,7 @@ public class TestPdpStatusParameters {
public void testValidate() {
final PdpStatusParameters pdpStatusParameters =
testData.toObject(testData.getPdpStatusParametersMap(false), PdpStatusParameters.class);
- final GroupValidationResult result = pdpStatusParameters.validate();
+ final ValidationResult result = pdpStatusParameters.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
}
diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/CdsServerParameters.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/CdsServerParameters.java
index 97dc35449..5f4c18ffc 100644
--- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/CdsServerParameters.java
+++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/CdsServerParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +24,7 @@ import java.util.Base64;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.ParameterRuntimeException;
import org.onap.policy.common.parameters.annotations.Max;
import org.onap.policy.common.parameters.annotations.Min;
@@ -33,7 +33,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@Getter
@Setter
@ToString
-public class CdsServerParameters implements ParameterGroup {
+public class CdsServerParameters extends ParameterGroupImpl {
// Port range constants
private static final int MIN_USER_PORT = 1024;
@@ -78,11 +78,6 @@ public class CdsServerParameters implements ParameterGroup {
throw new ParameterRuntimeException("The name of this ParameterGroup implementation is always " + getName());
}
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
-
/**
* Generate base64-encoded Authorization header from username and password.
*
diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java
index 030d77449..65f94abe9 100644
--- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java
+++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,28 +21,11 @@
package org.onap.policy.models.simulators;
import lombok.Getter;
-import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
-import org.onap.policy.common.parameters.ObjectValidationResult;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.ClassName;
+import org.onap.policy.common.parameters.annotations.NotNull;
@Getter
public class ClassRestServerParameters extends RestServerParameters {
- private String providerClass;
-
- /**
- * Validates the parameters.
- *
- * @param containerName name of the parameter container
- * @return the validation result
- */
- public ValidationResult validate(String containerName) {
- // not using a BeanValidator because username and password are not required
- if (StringUtils.isBlank(providerClass)) {
- return new ObjectValidationResult("providerClass", providerClass, ValidationStatus.INVALID, "is empty");
- }
-
- return new ObjectValidationResult("providerClass", providerClass);
- }
+ private @NotNull @ClassName String providerClass;
}
diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java
index 4b60d5e45..491585e9c 100644
--- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java
+++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,8 +27,8 @@ import lombok.Getter;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.BeanValidator;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.Valid;
import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
/**
@@ -45,27 +45,27 @@ public class SimulatorParameters {
*/
private DmaapSimParameterGroup dmaapProvider;
- private CdsServerParameters grpcServer;
+ private @Valid CdsServerParameters grpcServer;
/**
* Parameters for the REST server simulators that are to be started.
*/
- private List<ClassRestServerParameters> restServers = new LinkedList<>();
+ private List<@Valid ClassRestServerParameters> restServers = new LinkedList<>();
/**
* Topic sinks that are used by {@link #topicServers}.
*/
- private List<TopicParameters> topicSinks = new LinkedList<>();
+ private List<@Valid TopicParameters> topicSinks = new LinkedList<>();
/**
* Topic sources that are used by {@link #topicServers}.
*/
- private List<TopicParameters> topicSources = new LinkedList<>();
+ private List<@Valid TopicParameters> topicSources = new LinkedList<>();
/**
* Parameters for the TOPIC server simulators that are to be started.
*/
- private List<TopicServerParameters> topicServers = new LinkedList<>();
+ private List<@Valid TopicServerParameters> topicServers = new LinkedList<>();
/**
@@ -83,21 +83,12 @@ public class SimulatorParameters {
BeanValidationResult subResult = new BeanValidationResult("dmaapProvider", dmaapProvider);
subResult.validateNotNull("name", dmaapProvider.getName());
if (dmaapProvider.getTopicSweepSec() < 1) {
- ObjectValidationResult fieldResult =
- new ObjectValidationResult("topicSweepSec", dmaapProvider.getTopicSweepSec(),
- ValidationStatus.INVALID, "is below the minimum value: 1");
- subResult.addResult(fieldResult);
+ subResult.addResult("topicSweepSec", dmaapProvider.getTopicSweepSec(),
+ ValidationStatus.INVALID, "is below the minimum value: 1");
}
result.addResult(subResult);
}
- if (grpcServer != null) {
- result.addResult(grpcServer.validate());
- }
-
- result.validateList("restServers", restServers, params -> params.validate("restServers"));
- result.validateList("topicServers", topicServers, params -> params.validate("topicServers"));
-
return result;
}
}
diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java
index 76637610c..0560e851c 100644
--- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java
+++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ public class ClassRestServerParametersTest {
@Test
public void testValidateString() throws CoderException {
// some fields missing
- ValidationResult result = new ClassRestServerParameters().validate("InvalidParams");
+ ValidationResult result = new ClassRestServerParameters().validate();
assertFalse(result.isValid());
assertNotNull(result.getResult());
@@ -43,6 +43,6 @@ public class ClassRestServerParametersTest {
SimulatorParameters simParams = new StandardCoder()
.decode(new File("src/test/resources/simParameters.json"), SimulatorParameters.class);
ClassRestServerParameters params = simParams.getRestServers().get(0);
- assertNull(params.validate("ValidParams").getResult());
+ assertNull(params.validate().getResult());
}
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
index 5dda6ecfc..2fa2a557a 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -229,8 +229,8 @@ public final class ToscaUtils {
}
if (entityType.getKey().equals(parentEntityTypeKey)) {
- result.addResult(new ObjectValidationResult("entity type", entityType.getKey().getId(),
- ValidationStatus.INVALID, "ancestor of itself"));
+ result.addResult("entity type", entityType.getKey().getId(),
+ ValidationStatus.INVALID, "ancestor of itself");
throw new PfModelRuntimeException(Response.Status.CONFLICT, result.getResult());
}
@@ -239,8 +239,7 @@ public final class ToscaUtils {
.getAll(parentEntityTypeKey.getName(), parentEntityTypeKey.getVersion());
Set<JpaToscaEntityType<ToscaEntity>> ancestorEntitySetToReturn = new HashSet<>(ancestorEntitySet);
if (ancestorEntitySet.isEmpty()) {
- result.addResult(new ObjectValidationResult("parent", parentEntityTypeKey.getId(), ValidationStatus.INVALID,
- Validated.NOT_FOUND));
+ result.addResult("parent", parentEntityTypeKey.getId(), ValidationStatus.INVALID, Validated.NOT_FOUND);
} else {
for (JpaToscaEntityType<?> filteredEntityType : ancestorEntitySet) {
ancestorEntitySetToReturn.addAll(getEntityTypeAncestors(entityTypes, filteredEntityType, result));