diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-11-06 12:02:46 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-11-07 12:41:09 +0000 |
commit | 53d8916cc60d97e2ce7ae345f8cc25f5602567da (patch) | |
tree | ee2f3a8e543c31993c51a58257354ccffb648dfe /services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java | |
parent | 9dc414a0cabc9074e87a7c9cd5c3e5ceee733e5a (diff) |
Refactor unit test data
There were many copies of test policies and examples
strewn through the Apex unit tests. This change cleans
up the unit tests so that a single version of all example
policies is used in all tests.
Also added a new relative file root command line parameter
to Apex to allow the root of relative paths in configuration
files to be set.
Apologies for the size of this review but unfortunately
all of this must be done in one shot.
Issue-ID: POLICY-1252
Change-Id: Ibbb18fbf18e3897a1c61301d0a65e62bc643a0e9
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java')
-rw-r--r-- | services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java index 7b71253b0..61518b84f 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java @@ -150,7 +150,7 @@ public class ParameterTests { + " field \"deploymentPort\" type \"int\" value \"65536\" INVALID, " + "deploymentPort [65536] invalid, must be specified as 1024 <= port <= 65535\n" + " field \"policyModelFileName\" type \"java.lang.String\" " - + "value \"/some/file/name.xml\" INVALID, not found or is not a plain file\n" + + "value \"/some/file/name.xml\" INVALID, not found\n" + " parameter group map \"eventOutputParameters\" INVALID, " + "parameter group has status INVALID\n" + " parameter group \"FirstProducer\" type " + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID" @@ -159,8 +159,7 @@ public class ParameterTests { + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, " + "parameter group has status INVALID\n" + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, " - + "fileName not specified or is blank or null, " - + "it must be specified as a valid file location\n" + + "\"null\" invalid, must be specified as a non-empty string\n" + " parameter group map \"eventInputParameters\" INVALID, " + "parameter group has status INVALID\n" + " parameter group \"TheFileConsumer1\" type " + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID" @@ -169,8 +168,29 @@ public class ParameterTests { + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, " + "parameter group has status INVALID\n" + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, " - + "fileName not specified or is blank or null, " - + "it must be specified as a valid file location\n", e.getMessage()); + + "\"null\" invalid, must be specified as a non-empty string\n", e.getMessage()); + } + } + + @Test + public void modelNotFileTest() { + final String[] args = + { "-c", "src/test/resources/parameters/badParamsModelNotFile.json" }; + final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); + + try { + new ApexParameterHandler().getParameters(arguments); + fail("This test should throw an exception"); + } catch (final ParameterException e) { + assertEquals("validation error(s) on parameters from " + + "\"src/test/resources/parameters/badParamsModelNotFile.json\"\n" + + "parameter group \"APEX_PARAMETERS\" type " + + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, " + + "parameter group has status INVALID\n" + " parameter group \"MyApexEngine\" type " + + "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" " + + "INVALID, parameter group has status INVALID\n" + " field \"policyModelFileName\" " + + "type \"java.lang.String\" value \"src/test\" INVALID, is not a plain file\n", + e.getMessage()); } } @@ -257,8 +277,8 @@ public class ParameterTests { assertTrue(prodCarrierTech instanceof SuperDooperCarrierTechnologyParameters); - final SuperDooperCarrierTechnologyParameters superDooperParameters = - (SuperDooperCarrierTechnologyParameters) prodCarrierTech; + final SuperDooperCarrierTechnologyParameters superDooperParameters + = (SuperDooperCarrierTechnologyParameters) prodCarrierTech; assertEquals("somehost:12345", superDooperParameters.getBootstrapServers()); assertEquals("0", superDooperParameters.getAcks()); assertEquals(25, superDooperParameters.getRetries()); |