summaryrefslogtreecommitdiffstats
path: root/models-sim/policy-models-simulators/src/test/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-10-05 11:31:40 -0400
committerJim Hahn <jrh3@att.com>2020-10-05 11:37:56 -0400
commit66cce3f7afce095871b339440f7816389ddc614a (patch)
treebe135336b8e87f63d2f14cb3a669e5bf97630afa /models-sim/policy-models-simulators/src/test/java
parentc48e63f81e072c3cdf3f3fe84983285c0b8f1439 (diff)
Make simulator parameters optional
Modified the simulator to make the DMaaP and GRPC parameters optional so that a simulator can be started without them. Also added parameter validation, as that was not being performed on the DMaaP or GRPC parameters. Also modified the validation so-as not to require the rest server parameter field contained within the DMaaP parameter class. Issue-ID: POLICY-2858 Change-Id: I85dde93c7baf863eca2cb10eab37806f3e08a087 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.java11
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/SimulatorParametersTest.java18
2 files changed, 23 insertions, 6 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 e9e8cbdec..abc27f428 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("invalidSimParameters.json"))
+ assertThatIllegalArgumentException().isThrownBy(() -> new Main("invalidDmaapParameters.json"))
.withMessage("invalid simulator parameters");
}
@@ -125,7 +125,7 @@ public class MainTest {
Main.main(new String[] {PARAMETER_FILE});
// don't need to wait long, because buildXxx() does the wait for us
- for (int port = 6666; port <= 6670; ++port) {
+ for (int port : new int[] {6666, 6667, 6668, 6669, 6670, 6680}) {
assertTrue("simulator on port " + port, NetworkUtil.isTcpPortOpen(HOST, port, 1, 100));
}
@@ -133,6 +133,13 @@ public class MainTest {
checkAai();
}
+ @Test
+ public void testMainMinimalParameters() {
+ Main.main(new String[] {"minParameters.json"});
+ assertNotNull(Main.getInstance());
+ assertTrue(Main.getInstance().isAlive());
+ }
+
private void checkAai() throws HttpClientConfigException {
BusTopicParams params = BusTopicParams.builder().clientName("client").hostname(HOST).port(6666).useHttps(true)
.allowSelfSignedCerts(true).basePath("aai").build();
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 5294ca483..f8d7433d2 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
@@ -34,14 +34,24 @@ public class SimulatorParametersTest {
@Test
public void testValidate() throws CoderException {
- // some fields missing
- BeanValidationResult result = new SimulatorParameters().validate("InvalidParams");
- assertFalse(result.isValid());
- assertNotNull(result.getResult());
// 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);
+ 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");
+ assertFalse(result.isValid());
+ assertNotNull(result.getResult());
}
}