summaryrefslogtreecommitdiffstats
path: root/models-sim/policy-models-simulators/src/test/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-10-06 13:50:36 -0400
committerJim Hahn <jrh3@att.com>2020-10-06 14:26:11 -0400
commite54ce7a34fe5ae1425336aa461d70eee9386d90a (patch)
tree1dbe13fef3df207df1c99a31f240eddbe4d9d1c7 /models-sim/policy-models-simulators/src/test/java
parent9591e2dd26eacd9fd44ac72c325b83ca3d3534f9 (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/test/java')
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java2
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java46
2 files changed, 38 insertions, 10 deletions
diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
index abc27f428..f5598e2e1 100644
--- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
+++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
@@ -109,7 +109,7 @@ public class MainTest {
@Test
public void testConstructor() throws Exception {
- assertThatIllegalArgumentException().isThrownBy(() -> new Main("invalidDmaapParameters.json"))
+ assertThatIllegalArgumentException().isThrownBy(() -> new Main("invalidDmaapProvider.json"))
.withMessage("invalid simulator parameters");
}
diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java
index f8d7433d2..8094ca419 100644
--- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java
+++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.models.simulators;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -34,23 +35,50 @@ public class SimulatorParametersTest {
@Test
public void testValidate() throws CoderException {
-
- // everything populated
SimulatorParameters params = new StandardCoder().decode(new File("src/test/resources/simParameters.json"),
SimulatorParameters.class);
assertNull(params.validate("ValidParams").getResult());
+ }
- // invalid dmaap provider
- params = new StandardCoder().decode(new File("src/test/resources/invalidDmaapParameters.json"),
- SimulatorParameters.class);
+ @Test
+ public void testValidateEmptyRestServer() throws CoderException {
+ SimulatorParameters params = new StandardCoder()
+ .decode(new File("src/test/resources/emptyRestServer.json"), SimulatorParameters.class);
+ assertNull(params.validate("ValidParams").getResult());
+ }
+
+ @Test
+ public void testValidateInvalidDmaapProvider() throws CoderException {
+ SimulatorParameters params = new StandardCoder()
+ .decode(new File("src/test/resources/invalidDmaapProvider.json"), SimulatorParameters.class);
BeanValidationResult result = params.validate("InvalidDmaapParams");
assertFalse(result.isValid());
assertNotNull(result.getResult());
+ }
- // invalid grpc server
- params = new StandardCoder().decode(new File("src/test/resources/invalidGrpcParameters.json"),
- SimulatorParameters.class);
- result = params.validate("InvalidGrpcParams");
+ @Test
+ public void testValidateInvalidDmaapName() throws CoderException {
+ SimulatorParameters params = new StandardCoder().decode(
+ new File("src/test/resources/invalidDmaapName.json"), SimulatorParameters.class);
+ BeanValidationResult result = params.validate("InvalidDmaapParams");
+ assertFalse(result.isValid());
+ assertThat(result.getResult()).contains("item \"name\" value \"null\"");
+ }
+
+ @Test
+ public void testValidateInvalidTopicSweep() throws CoderException {
+ SimulatorParameters params = new StandardCoder().decode(
+ new File("src/test/resources/invalidTopicSweep.json"), SimulatorParameters.class);
+ BeanValidationResult result = params.validate("InvalidDmaapParams");
+ assertFalse(result.isValid());
+ assertThat(result.getResult()).contains("topicSweepSec");
+ }
+
+ @Test
+ public void testValidateInvalidGrpcServer() throws CoderException {
+ SimulatorParameters params = new StandardCoder()
+ .decode(new File("src/test/resources/invalidGrpcServer.json"), SimulatorParameters.class);
+ BeanValidationResult result = params.validate("InvalidGrpcParams");
assertFalse(result.isValid());
assertNotNull(result.getResult());
}