diff options
Diffstat (limited to 'models-sim/policy-models-simulators/src/test')
7 files changed, 52 insertions, 12 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()); } } diff --git a/models-sim/policy-models-simulators/src/test/resources/invalidDmaapParameters.json b/models-sim/policy-models-simulators/src/test/resources/invalidDmaapParameters.json new file mode 100644 index 000000000..ff6790144 --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/invalidDmaapParameters.json @@ -0,0 +1,7 @@ +{ + "dmaapProvider": {}, + "restServers": [], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/invalidGrpcParameters.json b/models-sim/policy-models-simulators/src/test/resources/invalidGrpcParameters.json new file mode 100644 index 000000000..86e425364 --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/invalidGrpcParameters.json @@ -0,0 +1,7 @@ +{ + "grpcServer": {}, + "restServers": [], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/invalidSimParameters.json b/models-sim/policy-models-simulators/src/test/resources/invalidSimParameters.json deleted file mode 100644 index 2c63c0851..000000000 --- a/models-sim/policy-models-simulators/src/test/resources/invalidSimParameters.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/models-sim/policy-models-simulators/src/test/resources/minParameters.json b/models-sim/policy-models-simulators/src/test/resources/minParameters.json new file mode 100644 index 000000000..c7ea49874 --- /dev/null +++ b/models-sim/policy-models-simulators/src/test/resources/minParameters.json @@ -0,0 +1,14 @@ +{ + "restServers": [ + { + "name": "A&AI simulator", + "providerClass": "org.onap.policy.simulators.AaiSimulatorJaxRs", + "host": "localhost", + "port": 6766, + "https": true + } + ], + "topicSinks": [], + "topicSources": [], + "topicServers": [] +} diff --git a/models-sim/policy-models-simulators/src/test/resources/simParameters.json b/models-sim/policy-models-simulators/src/test/resources/simParameters.json index 1d1c0aad7..df8de6ff7 100644 --- a/models-sim/policy-models-simulators/src/test/resources/simParameters.json +++ b/models-sim/policy-models-simulators/src/test/resources/simParameters.json @@ -1,10 +1,7 @@ { "dmaapProvider": { "name": "DMaaP simulator", - "topicSweepSec": 300, - "restServerParameters": { - - } + "topicSweepSec": 300 }, "restServers": [ { |