aboutsummaryrefslogtreecommitdiffstats
path: root/models-sim/policy-models-sim-pdp/src/test
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2021-04-15 10:35:00 +0100
committeradheli.tavares <adheli.tavares@est.tech>2021-04-19 09:41:25 +0100
commita250c0c7a4a680c15cc4cb158f8f3cff53619f1b (patch)
tree675a8b10876f0d19abad12d86e1c67688682bf3a /models-sim/policy-models-sim-pdp/src/test
parent0b7b94b17340406b34817d6088daa97d965d5c2c (diff)
Refactor CommandLineArguments classes
All CMD Args simulator classes to extend from CMD class on Common. Fix all unit tests accordingly. Issue-ID: POLICY-3129 Change-Id: If69e432679772df15b06ce7e316c7c876b69773d Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-sim/policy-models-sim-pdp/src/test')
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java27
1 files changed, 18 insertions, 9 deletions
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 e7d41a545..3ac99f407 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,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +28,7 @@ import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import org.junit.Test;
+import org.onap.policy.common.utils.cmd.CommandLineException;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.sim.pdp.PdpSimulatorCommandLineArguments;
import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException;
@@ -40,7 +41,7 @@ import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException;
public class TestPdpSimulatorParameterHandler {
@Test
- public void testParameterHandlerNoParameterFile() throws PdpSimulatorException {
+ public void testParameterHandlerNoParameterFile() throws PdpSimulatorException, CommandLineException {
final String[] emptyArgumentString = { "-c", "src/test/resources/NoParametersFile.json" };
final PdpSimulatorCommandLineArguments emptyArguments = new PdpSimulatorCommandLineArguments();
@@ -56,7 +57,7 @@ public class TestPdpSimulatorParameterHandler {
}
@Test
- public void testParameterHandlerEmptyParameters() throws PdpSimulatorException {
+ public void testParameterHandlerEmptyParameters() throws PdpSimulatorException, CommandLineException {
final String[] noArgumentString = { "-c", "src/test/resources/NoParameters.json" };
final PdpSimulatorCommandLineArguments noArguments = new PdpSimulatorCommandLineArguments();
@@ -67,7 +68,7 @@ public class TestPdpSimulatorParameterHandler {
}
@Test
- public void testParameterHandlerInvalidParameters() throws PdpSimulatorException {
+ public void testParameterHandlerInvalidParameters() throws PdpSimulatorException, CommandLineException {
final String[] invalidArgumentString = { "-c", "src/test/resources/InvalidParameters.json" };
final PdpSimulatorCommandLineArguments invalidArguments = new PdpSimulatorCommandLineArguments();
@@ -79,7 +80,7 @@ public class TestPdpSimulatorParameterHandler {
}
@Test
- public void testParameterHandlerNoParameters() throws PdpSimulatorException {
+ public void testParameterHandlerNoParameters() throws PdpSimulatorException, CommandLineException {
final String[] noArgumentString = { "-c", "src/test/resources/EmptyConfigParameters.json" };
final PdpSimulatorCommandLineArguments noArguments = new PdpSimulatorCommandLineArguments();
@@ -90,7 +91,7 @@ public class TestPdpSimulatorParameterHandler {
}
@Test
- public void testPdpSimulatorParameterGroup() throws PdpSimulatorException {
+ public void testPdpSimulatorParameterGroup() throws PdpSimulatorException, CommandLineException {
final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" };
final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments();
@@ -102,7 +103,7 @@ public class TestPdpSimulatorParameterHandler {
}
@Test
- public void testPdpSimulatorParameterGroup_InvalidName() throws PdpSimulatorException {
+ public void testPdpSimulatorParameterGroup_InvalidName() throws PdpSimulatorException, CommandLineException {
final String[] pdpSimulatorConfigParameters = {"-c",
"src/test/resources/PdpSimulatorConfigParameters_InvalidName.json"};
@@ -114,7 +115,7 @@ public class TestPdpSimulatorParameterHandler {
}
@Test
- public void testPdpSimulatorVersion() throws PdpSimulatorException {
+ public void testPdpSimulatorVersion() throws PdpSimulatorException, CommandLineException {
final String[] pdpSimulatorConfigParameters = { "-v" };
final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments();
final String version = arguments.parse(pdpSimulatorConfigParameters);
@@ -122,7 +123,7 @@ public class TestPdpSimulatorParameterHandler {
}
@Test
- public void testPdpSimulatorHelp() throws PdpSimulatorException {
+ public void testPdpSimulatorHelp() throws PdpSimulatorException, CommandLineException {
final String[] pdpSimulatorConfigParameters = { "-h" };
final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments();
final String help = arguments.parse(pdpSimulatorConfigParameters);
@@ -137,4 +138,12 @@ public class TestPdpSimulatorParameterHandler {
assertThatThrownBy(() -> arguments.parse(pdpSimulatorConfigParameters))
.hasMessageStartingWith("invalid command line arguments specified");
}
+
+ @Test
+ public void testPdpSimulatorProperty() throws PdpSimulatorException, CommandLineException {
+ final String[] pdpSimulatorConfigParameters = { "-p", "dummyProperties.json" };
+ final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments();
+ arguments.parse(pdpSimulatorConfigParameters);
+ assertTrue(arguments.checkSetPropertyFilePath());
+ }
}