diff options
author | Jim Hahn <jrh3@att.com> | 2020-10-06 13:50:36 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-10-06 14:26:11 -0400 |
commit | e54ce7a34fe5ae1425336aa461d70eee9386d90a (patch) | |
tree | 1dbe13fef3df207df1c99a31f240eddbe4d9d1c7 /models-sim/policy-models-simulators/src/main/java | |
parent | 9591e2dd26eacd9fd44ac72c325b83ca3d3534f9 (diff) |
Don't always validate restServerParameters
Restored original validation code to DmaapSimParameterGroup so it works
as it originally worked (i.e., required "restServerParameters").
However, modified SimulatorParameters to validate the relevant fields
directly, rather than relying on DmaapSimParameterGroup.validate(), thus
eliminating all checks on "restServerParameters" when used within
SimulatorParameters.
Issue-ID: POLICY-2858
Change-Id: I9a09431ce3056a874bf2dba1c5bd6c418f37f69b
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-sim/policy-models-simulators/src/main/java')
-rw-r--r-- | models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java | 14 |
1 files changed, 13 insertions, 1 deletions
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 c22527165..4b60d5e45 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 @@ -27,6 +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.models.sim.dmaap.parameters.DmaapSimParameterGroup; /** @@ -76,7 +78,17 @@ public class SimulatorParameters { BeanValidationResult result = new BeanValidator().validateTop(containerName, this); if (dmaapProvider != null) { - result.addResult(dmaapProvider.validate()); + // do not want full validation of the provider, so validate the relevant + // fields ourselves + 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); + } + result.addResult(subResult); } if (grpcServer != null) { |