summaryrefslogtreecommitdiffstats
path: root/models-sim/policy-models-sim-pdp
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 /models-sim/policy-models-sim-pdp
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>
Diffstat (limited to 'models-sim/policy-models-sim-pdp')
-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
5 files changed, 28 insertions, 24 deletions
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());
}