summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'services/services-engine/src/test')
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java18
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java4
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java60
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java36
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java166
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java187
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java370
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java96
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java5
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java2
-rw-r--r--services/services-engine/src/test/resources/parameters/syncMismatchedTimeout.json74
11 files changed, 634 insertions, 384 deletions
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java
index decec767f..4f1089229 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java
@@ -32,9 +32,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -46,6 +47,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.utilities.TextFileUtils;
import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter;
import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -67,9 +69,17 @@ public class TestJSONEventHandler {
apexPolicyModel.register();
}
- @Before
- public void initializeDefaultSchemaParameters() {
- new SchemaParameters();
+ @BeforeClass
+ public static void initializeDefaultSchemaParameters() {
+ ParameterService.clear();
+ final SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.register(schemaParameters);
+ }
+
+ @AfterClass
+ public static void teardownDefaultSchemaParameters() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@Test
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java
index 8ecf9b745..db60b229d 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java
@@ -29,10 +29,10 @@ import org.onap.policy.apex.service.engine.event.impl.EventConsumerFactory;
import org.onap.policy.apex.service.engine.event.impl.EventProducerFactory;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test Plugin Factories.
@@ -42,7 +42,7 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParamete
public class TestPluginFactories {
@Test
- public void testEventConsumerFactory() throws ApexEventException, ApexParameterException {
+ public void testEventConsumerFactory() throws ApexEventException, ParameterException {
final String[] args = {"-c", "src/test/resources/parameters/factoryGoodParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java
index d22d528c8..37f15777b 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java
@@ -26,9 +26,9 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperDistributorParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -45,9 +45,9 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextNoParams.json\"\n"
- + "(ApexParameterRuntimeException):could not find field \"parameterClassName\" in "
+ + "(ParameterRuntimeException):could not find field \"parameterClassName\" in "
+ "\"contextParameters\" entry", e.getMessage());
}
}
@@ -60,9 +60,9 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextBadParams.json\""
- + "\n(ApexParameterRuntimeException):failed to deserialize the parameters for "
+ + "\n(ParameterRuntimeException):failed to deserialize the parameters for "
+ "\"contextParameters\" to parameter class \"hello\"\njava.lang.ClassNotFoundException: hello",
e.getMessage());
}
@@ -76,10 +76,10 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadPluginNameParams.json\"\n"
- + "(ApexParameterRuntimeException):could not find field \"parameterClassName\" in "
+ + "(ParameterRuntimeException):could not find field \"parameterClassName\" in "
+ "\"contextParameters\" entry", e.getMessage());
}
}
@@ -92,10 +92,10 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals(
"error reading parameters from \"src/test/resources/parameters/serviceContextBadClassParams.json\""
- + "\n(ApexParameterRuntimeException):failed to deserialize the parameters for \"contextParameters\""
+ + "\n(ParameterRuntimeException):failed to deserialize the parameters for \"contextParameters\""
+ " to parameter class \"java.lang.Integer\"\ncom.google.gson.JsonSyntaxException: "
+ "java.lang.IllegalStateException: Expected NUMBER but was BEGIN_OBJECT at path $",
e.getMessage());
@@ -110,7 +110,7 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadPluginClassParams.json\""
+ "\n(ClassCastException):org.onap.policy.apex.service.engine.parameters.dummyclasses."
@@ -127,10 +127,10 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals(123456, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
.getPersistorParameters().getFlushPeriod());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -143,10 +143,10 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals(300000, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
.getPersistorParameters().getFlushPeriod());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -159,11 +159,11 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.DistributorParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getDistributorParameters().getParameterClassName());
- } catch (final ApexParameterException e) {
+ .getDistributorParameters().getClass().getCanonicalName());
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -176,19 +176,19 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.DistributorParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getDistributorParameters().getParameterClassName());
+ .getDistributorParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.LockManagerParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getLockManagerParameters().getParameterClassName());
+ .getLockManagerParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.PersistorParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getPersistorParameters().getParameterClassName());
+ .getPersistorParameters().getClass().getCanonicalName());
assertEquals(300000, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
.getPersistorParameters().getFlushPeriod());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -201,13 +201,13 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.LockManagerParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getLockManagerParameters().getParameterClassName());
+ .getLockManagerParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.PersistorParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getPersistorParameters().getParameterClassName());
+ .getPersistorParameters().getClass().getCanonicalName());
assertEquals(123456, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
.getPersistorParameters().getFlushPeriod());
@@ -215,13 +215,13 @@ public class ContextParameterTests {
(SuperDooperDistributorParameters) parameters.getEngineServiceParameters().getEngineParameters()
.getContextParameters().getDistributorParameters();
assertEquals("org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperDistributorParameters",
- infinispanParameters.getParameterClassName());
+ infinispanParameters.getClass().getCanonicalName());
assertEquals("my/lovely/configFile.xml", infinispanParameters.getConfigFile());
assertEquals("holy/stone.xml", infinispanParameters.getJgroupsFile());
assertEquals(false, infinispanParameters.preferIPv4Stack());
assertEquals("fatherted", infinispanParameters.getjGroupsBindAddress());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -234,7 +234,7 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadClassDistParams.json\"\n"
+ "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to"
@@ -250,7 +250,7 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadClassLockParams.json\"\n"
+ "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to"
@@ -266,7 +266,7 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadClassPersistParams.json\"\n"
+ "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to"
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java
index aa106a695..5e42ede1a 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java
@@ -25,9 +25,9 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -45,7 +45,7 @@ public class ExecutorParameterTests {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals(0,
parameters.getEngineServiceParameters().getEngineParameters().getExecutorParameterMap().size());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -58,10 +58,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals(
"error reading parameters from \"src/test/resources/parameters/serviceExecutorBadParams.json\"\n"
- + "(ApexParameterRuntimeException):value of \"executorParameters:ZOOBY\" entry is not "
+ + "(ParameterRuntimeException):value of \"executorParameters:ZOOBY\" entry is not "
+ "a parameter JSON object",
e.getMessage());
}
@@ -75,10 +75,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorNoExecutorParams.json\"\n"
- + "(ApexParameterRuntimeException):no \"executorParameters\" entry found in parameters,"
+ + "(ParameterRuntimeException):no \"executorParameters\" entry found in parameters,"
+ " at least one executor parameter entry must be specified", e.getMessage());
}
}
@@ -91,10 +91,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorEmptyParams.json\"\n"
- + "(ApexParameterRuntimeException):could not find field \"parameterClassName\" "
+ + "(ParameterRuntimeException):could not find field \"parameterClassName\" "
+ "in \"executorParameters:ZOOBY\" entry", e.getMessage());
}
}
@@ -107,10 +107,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorBadPluginNameParams.json\"\n"
- + "(ApexParameterRuntimeException):could not find field \"parameterClassName\" "
+ + "(ParameterRuntimeException):could not find field \"parameterClassName\" "
+ "in \"executorParameters:ZOOBY\" entry", e.getMessage());
}
}
@@ -123,11 +123,11 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorBadPluginValueObjectParams.json\"\n"
- + "(ApexParameterRuntimeException):value for field \"parameterClassName\" "
- + "in \"executorParameters:LOOBY\" entry is not a plain string", e.getMessage());
+ + "(ParameterRuntimeException):value for field \"parameterClassName\" "
+ + "of \"executorParameters:LOOBY\" entry is not a plain string", e.getMessage());
}
}
@@ -139,10 +139,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorBadPluginValueBlankParams.json\"\n"
- + "(ApexParameterRuntimeException):value for field \"parameterClassName\" "
+ + "(ParameterRuntimeException):value for field \"parameterClassName\" "
+ "in \"executorParameters:LOOBY\" entry is not specified or is blank", e.getMessage());
}
}
@@ -156,10 +156,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from"
+ " \"src/test/resources/parameters/serviceExecutorBadPluginValueParams.json\"\n"
- + "(ApexParameterRuntimeException):failed to deserialize the parameters "
+ + "(ParameterRuntimeException):failed to deserialize the parameters "
+ "for \"executorParameters:LOOBY\" to parameter class \"helloworld\"\n"
+ "java.lang.ClassNotFoundException: helloworld", e.getMessage());
}
@@ -178,7 +178,7 @@ public class ExecutorParameterTests {
assertEquals(45, parameters.getEngineServiceParameters().getId());
assertEquals(19, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
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 6d3d7ee20..31ccd913f 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
@@ -34,11 +34,11 @@ import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventProducer;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventSubscriber;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -47,14 +47,14 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
*/
public class ParameterTests {
@Test
- public void invalidParametersNoFileTest() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/invalidNoFile.json"};
+ public void invalidParametersNoFileTest() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/invalidNoFile.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertTrue(e.getMessage().startsWith("error reading parameters from \"src"));
assertTrue(e.getMessage().contains("FileNotFoundException"));
}
@@ -62,79 +62,116 @@ public class ParameterTests {
@Test
public void invalidParametersEmptyTest() {
- final String[] args = {"-c", "src/test/resources/parameters/empty.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/empty.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
- assertTrue(e.getMessage()
- .startsWith("validation error(s) on parameters from \"src/test/resources/parameters/empty.json\""));
+ } catch (final ParameterException e) {
+ assertTrue(e.getMessage().startsWith(
+ "validation error(s) on parameters from \"src/test/resources/parameters/empty.json\""));
}
}
@Test
public void invalidParametersNoParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/noParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/noParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/noParams.json\"\n"
- + "Apex parameters invalid\n" + " engine service parameters are not specified\n"
- + " at least one event output and one event input must be specified", e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
+ + "engine service parameters are not specified\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "at least one event output must be specified\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "at least one event input must be specified\n", e.getMessage());
}
}
@Test
public void invalidParametersBlankParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/blankParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/blankParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/blankParams.json\"\n"
- + "Apex parameters invalid\n" + " engine service parameters invalid\n"
- + " id not specified or specified value [-1] invalid, must be specified as id >= 0\n"
- + " at least one event output and one event input must be specified", e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group \"ENGINE_SERVICE_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" "
+ + "INVALID, parameter group has status INVALID\n"
+ + " field \"id\" type \"int\" value \"-1\" INVALID, "
+ + "id not specified or specified value [-1] invalid, must be specified as id >= 0\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "at least one event output must be specified\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "at least one event input must be specified\n", e.getMessage());
}
}
@Test
public void invalidParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/badParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/badParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/badParams.json\"\n"
- + "Apex parameters invalid\n" + " engine service parameters invalid\n"
- + " name [hello there] and/or version [PA1] invalid\n"
- + " parameter \"name\": value \"hello there\","
- + " does not match regular expression \"[A-Za-z0-9\\-_\\.]+\"\n"
- + " id not specified or specified value [-45] invalid, must be specified as id >= 0\n"
- + " instanceCount [-345] invalid, must be specified as instanceCount >= 1\n"
- + " deploymentPort [65536] invalid, must be specified as 1024 <= port <= 65535\n"
- + " policyModelFileName [/some/file/name.xml] not found or is not a plain file\n"
- + " event input (TheFileConsumer1) parameters invalid\n"
- + " fileName not specified or is blank or null, it must be specified as a valid file location\n"
- + " event output (FirstProducer) parameters invalid\n"
- + " fileName not specified or is blank or null, it must be specified as a valid file location",
- e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"hello there\" type "
+ + "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" "
+ + "INVALID, parameter group has status INVALID\n"
+ + " field \"name\" type \"java.lang.String\" value \"hello there\" INVALID, "
+ + "name is invalid, it must match regular expression[A-Za-z0-9\\-_\\.]+\n"
+ + " field \"id\" type \"int\" value \"-45\" INVALID, id not specified or "
+ + "specified value [-45] invalid, must be specified as id >= 0\n"
+ + " field \"instanceCount\" type \"int\" value \"-345\" INVALID, "
+ + "instanceCount [-345] invalid, must be specified as instanceCount >= 1\n"
+ + " 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"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"FirstProducer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
+ + "\"org.onap.policy.apex.service.engine.event.impl."
+ + "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"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"TheFileConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
+ + "\"org.onap.policy.apex.service.engine.event.impl."
+ + "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());
}
}
@Test
public void goodParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/goodParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -146,44 +183,46 @@ public class ParameterTests {
assertTrue(parameters.getEventOutputParameters().containsKey("FirstProducer"));
assertTrue(parameters.getEventOutputParameters().containsKey("MyOtherProducer"));
assertEquals("FILE", parameters.getEventOutputParameters().get("FirstProducer")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("FILE", parameters.getEventOutputParameters().get("MyOtherProducer")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals(ApexFileEventProducer.class.getCanonicalName(), parameters.getEventOutputParameters()
- .get("MyOtherProducer").getCarrierTechnologyParameters().getEventProducerPluginClass());
+ .get("MyOtherProducer").getCarrierTechnologyParameters().getEventProducerPluginClass());
assertEquals(ApexFileEventConsumer.class.getCanonicalName(), parameters.getEventOutputParameters()
- .get("MyOtherProducer").getCarrierTechnologyParameters().getEventConsumerPluginClass());
- assertEquals("JSON",
- parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters().getLabel());
+ .get("MyOtherProducer").getCarrierTechnologyParameters().getEventConsumerPluginClass());
+ assertEquals("JSON", parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters()
+ .getLabel());
assertEquals("JSON", parameters.getEventOutputParameters().get("MyOtherProducer")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertTrue(parameters.getEventInputParameters().containsKey("TheFileConsumer1"));
assertTrue(parameters.getEventInputParameters().containsKey("MySuperDooperConsumer1"));
assertEquals("FILE", parameters.getEventInputParameters().get("TheFileConsumer1")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("SUPER_DOOPER", parameters.getEventInputParameters().get("MySuperDooperConsumer1")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("JSON", parameters.getEventInputParameters().get("TheFileConsumer1")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertEquals("SUPER_TOK_DEL", parameters.getEventInputParameters().get("MySuperDooperConsumer1")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertEquals(ApexFileEventProducer.class.getCanonicalName(), parameters.getEventInputParameters()
- .get("TheFileConsumer1").getCarrierTechnologyParameters().getEventProducerPluginClass());
+ .get("TheFileConsumer1").getCarrierTechnologyParameters().getEventProducerPluginClass());
assertEquals(ApexFileEventConsumer.class.getCanonicalName(), parameters.getEventInputParameters()
- .get("TheFileConsumer1").getCarrierTechnologyParameters().getEventConsumerPluginClass());
- assertEquals(SuperDooperEventProducer.class.getCanonicalName(), parameters.getEventInputParameters()
- .get("MySuperDooperConsumer1").getCarrierTechnologyParameters().getEventProducerPluginClass());
- assertEquals(SuperDooperEventSubscriber.class.getCanonicalName(), parameters.getEventInputParameters()
- .get("MySuperDooperConsumer1").getCarrierTechnologyParameters().getEventConsumerPluginClass());
- } catch (final ApexParameterException e) {
+ .get("TheFileConsumer1").getCarrierTechnologyParameters().getEventConsumerPluginClass());
+ assertEquals(SuperDooperEventProducer.class.getCanonicalName(),
+ parameters.getEventInputParameters().get("MySuperDooperConsumer1")
+ .getCarrierTechnologyParameters().getEventProducerPluginClass());
+ assertEquals(SuperDooperEventSubscriber.class.getCanonicalName(),
+ parameters.getEventInputParameters().get("MySuperDooperConsumer1")
+ .getCarrierTechnologyParameters().getEventConsumerPluginClass());
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
@Test
public void superDooperParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/superDooperParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/superDooperParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -195,14 +234,14 @@ public class ParameterTests {
assertEquals(345, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
- final CarrierTechnologyParameters prodCT =
- parameters.getEventOutputParameters().get("FirstProducer").getCarrierTechnologyParameters();
- final EventProtocolParameters prodEP =
- parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters();
- final CarrierTechnologyParameters consCT =
- parameters.getEventInputParameters().get("MySuperDooperConsumer1").getCarrierTechnologyParameters();
- final EventProtocolParameters consEP =
- parameters.getEventInputParameters().get("MySuperDooperConsumer1").getEventProtocolParameters();
+ final CarrierTechnologyParameters prodCT = parameters.getEventOutputParameters().get("FirstProducer")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters prodEP = parameters.getEventOutputParameters().get("FirstProducer")
+ .getEventProtocolParameters();
+ final CarrierTechnologyParameters consCT = parameters.getEventInputParameters()
+ .get("MySuperDooperConsumer1").getCarrierTechnologyParameters();
+ final EventProtocolParameters consEP = parameters.getEventInputParameters().get("MySuperDooperConsumer1")
+ .getEventProtocolParameters();
assertEquals("SUPER_DOOPER", prodCT.getLabel());
assertEquals("SUPER_TOK_DEL", prodEP.getLabel());
@@ -211,8 +250,7 @@ public class ParameterTests {
assertTrue(prodCT instanceof SuperDooperCarrierTechnologyParameters);
- final SuperDooperCarrierTechnologyParameters superDooperParameters =
- (SuperDooperCarrierTechnologyParameters) prodCT;
+ final SuperDooperCarrierTechnologyParameters superDooperParameters = (SuperDooperCarrierTechnologyParameters) prodCT;
assertEquals("somehost:12345", superDooperParameters.getBootstrapServers());
assertEquals("0", superDooperParameters.getAcks());
assertEquals(25, superDooperParameters.getRetries());
@@ -230,9 +268,9 @@ public class ParameterTests {
assertEquals("some.key.deserailizer", superDooperParameters.getKeyDeserializer());
assertEquals("some.value.deserailizer", superDooperParameters.getValueDeserializer());
- final String[] consumerTopics = {"consumer-out-0", "consumer-out-1", "consumer-out-2"};
+ final String[] consumerTopics = { "consumer-out-0", "consumer-out-1", "consumer-out-2" };
assertEquals(Arrays.asList(consumerTopics), superDooperParameters.getConsumerTopicList());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
index a476b84ca..8bcc1bd37 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
@@ -26,9 +26,9 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -38,7 +38,7 @@ import org.onap.policy.apex.service.parameters.ApexParameters;
public class ProducerConsumerTests {
@Test
public void goodParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/goodParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -50,220 +50,241 @@ public class ProducerConsumerTests {
assertEquals(19, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
assertEquals("FILE", parameters.getEventOutputParameters().get("FirstProducer")
- .getCarrierTechnologyParameters().getLabel());
- assertEquals("JSON",
- parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
+ assertEquals("JSON", parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters()
+ .getLabel());
assertEquals("FILE", parameters.getEventOutputParameters().get("MyOtherProducer")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("JSON", parameters.getEventOutputParameters().get("MyOtherProducer")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertEquals("FILE", parameters.getEventInputParameters().get("TheFileConsumer1")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("JSON", parameters.getEventInputParameters().get("TheFileConsumer1")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertEquals("SUPER_DOOPER", parameters.getEventInputParameters().get("MySuperDooperConsumer1")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("SUPER_TOK_DEL", parameters.getEventInputParameters().get("MySuperDooperConsumer1")
- .getEventProtocolParameters().getLabel());
- } catch (final ApexParameterException e) {
+ .getEventProtocolParameters().getLabel());
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
@Test
public void noCarrierTechnology() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsNoCT.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsNoCT.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/prodConsNoCT.json\"\n"
- + "Apex parameters invalid\n" + " event input (aConsumer) parameters invalid\n"
- + " event handler carrierTechnologyParameters not specified or blank", e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"aConsumer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
+ + "event handler carrierTechnologyParameters not specified or blank\n", e.getMessage());
}
}
@Test
public void noEventProcol() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsNoEP.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsNoEP.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/prodConsNoEP.json\"\n"
- + "Apex parameters invalid\n" + " event input (aConsumer) parameters invalid\n"
- + " fileName not specified or is blank or null, it must be specified as a valid file location\n"
- + " event output (aProducer) parameters invalid\n"
- + " event handler eventProtocolParameters not specified or blank", e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"aProducer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
+ + "event handler eventProtocolParameters not specified or blank\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"aConsumer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
+ + "\"org.onap.policy.apex.service.engine.event.impl."
+ + "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());
}
}
@Test
public void noCarrierTechnologyParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsNoCTParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsNoCTParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsNoCTParClass.json\"\n"
- + "(ApexParameterRuntimeException):carrier technology \"SUPER_DOOPER\" "
- + "does not match plugin \"FILE\" in "
- + "\"com.ericsson.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters"
- + "\", specify correct carrier technology parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ + "(ParameterRuntimeException):carrier technology \"SUPER_DOOPER\" "
+ + "parameter \"parameterClassName\" value \"null\" invalid in JSON file", e.getMessage());
}
}
@Test
public void mismatchCarrierTechnologyParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsMismatchCTParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsMismatchCTParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
- + "\"src/test/resources/parameters/prodConsMismatchCTParClass.json\"\n"
- + "(ApexParameterRuntimeException):carrier technology \"SUPER_LOOPER\" "
- + "does not match plugin \"SUPER_DOOPER\" in \""
- + "com.ericsson.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters"
- + "\", specify correct carrier technology parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ + "\"src/test/resources/parameters/prodConsMismatchCTParClass.json\"\n"
+ + "(ParameterRuntimeException):carrier technology \"SUPER_LOOPER\" "
+ + "does not match plugin \"SUPER_DOOPER\" in \"" + "org.onap.policy.apex.service.engine."
+ + "parameters.dummyclasses.SuperDooperCarrierTechnologyParameters"
+ + "\", specify correct carrier technology parameter plugin in parameter \"parameterClassName\"",
+ e.getMessage());
}
}
@Test
public void wrongTypeCarrierTechnologyParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsWrongTypeCTParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsWrongTypeCTParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
- + "\"src/test/resources/parameters/prodConsWrongTypeCTParClass.json\"\n"
- + "(ApexParameterRuntimeException):could not create default parameters for carrier technology "
- + "\"SUPER_DOOPER\"\ncom.ericsson.apex.service.engine.parameters.dummyclasses."
- + "SuperTokenDelimitedEventProtocolParameters cannot be cast to "
- + "com.ericsson.apex.service.parameters.carriertechnology.CarrierTechnologyParameters",
- e.getMessage());
+ + "\"src/test/resources/parameters/prodConsWrongTypeCTParClass.json\"\n"
+ + "(ParameterRuntimeException):could not create default parameters for carrier technology "
+ + "\"SUPER_DOOPER\"\n" + "org.onap.policy.apex.service.engine.parameters.dummyclasses."
+ + "SuperTokenDelimitedEventProtocolParameters cannot be cast to "
+ + "org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters",
+ e.getMessage());
}
}
@Test
public void okFileNameCarrierTechnology() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsOKFileName.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsOKFileName.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
final FILECarrierTechnologyParameters fileParams = (FILECarrierTechnologyParameters) parameters
- .getEventOutputParameters().get("aProducer").getCarrierTechnologyParameters();
+ .getEventOutputParameters().get("aProducer").getCarrierTechnologyParameters();
assertEquals("/tmp/aaa.json", fileParams.getFileName());
assertEquals(false, fileParams.isStandardError());
assertEquals(false, fileParams.isStandardIO());
assertEquals(false, fileParams.isStreamingMode());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
@Test
public void badFileNameCarrierTechnology() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsBadFileName.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsBadFileName.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
- assertEquals(
- "validation error(s) on parameters from \"src/test/resources/parameters/prodConsBadFileName.json\""
- + "\nApex parameters invalid\n" + " event output (aProducer) parameters invalid"
- + "\n fileName not specified or is blank or null, it must be specified as a valid file location",
- e.getMessage());
+ } catch (final ParameterException e) {
+ assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/prodConsBadFileName.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, parameter group has status INVALID\n"
+ + " parameter group \"aProducer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"FILE\" type "
+ + "\"org.onap.policy.apex.service.engine.event.impl."
+ + "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());
}
}
-
@Test
public void badEventProtocolParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsBadEPParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsBadEPParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsBadEPParClass.json\"\n"
- + "(ApexParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" does not match plugin \"JSON\" "
- + "in \"com.ericsson.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters"
- + "\", specify correct event protocol parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ + "(ParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" does not match plugin \"JSON\" in "
+ + "\"org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters"
+ + "\", specify correct event protocol parameter plugin in parameter \"parameterClassName\"",
+ e.getMessage());
}
}
@Test
public void noEventProtocolParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsNoEPParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsNoEPParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsNoEPParClass.json\"\n"
- + "(ApexParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" does not match plugin \"JSON\" "
- + "in \"com.ericsson.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters"
- + "\", specify correct event protocol parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ + "(ParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" parameter "
+ + "\"parameterClassName\" value \"null\" invalid in JSON file", e.getMessage());
}
}
@Test
public void mismatchEventProtocolParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsMismatchEPParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsMismatchEPParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
- assertEquals(
- "error reading parameters from \"src/test/resources/parameters/prodConsMismatchEPParClass.json\"\n"
- + "(ApexParameterRuntimeException):event protocol \"SUPER_TOK_BEL\" "
+ } catch (final ParameterException e) {
+ assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsMismatchEPParClass.json\"\n"
+ + "(ParameterRuntimeException):event protocol \"SUPER_TOK_BEL\" "
+ "does not match plugin \"SUPER_TOK_DEL\" in "
- + "\"com.ericsson.apex.service.engine.parameters.dummyclasses."
+ + "\"org.onap.policy.apex.service.engine.parameters.dummyclasses."
+ "SuperTokenDelimitedEventProtocolParameters\", "
+ "specify correct event protocol parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ e.getMessage());
}
}
@Test
public void wrongTypeEventProtocolParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsWrongTypeEPParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsWrongTypeEPParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
- + "\"src/test/resources/parameters/prodConsWrongTypeEPParClass.json\"\n"
- + "(ApexParameterRuntimeException):could not create default parameters for event protocol "
- + "\"SUPER_TOK_DEL\"\n"
- + "com.ericsson.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters "
- + "cannot be cast to com.ericsson.apex.service.parameters.eventprotocol.EventProtocolParameters",
- e.getMessage());
+ + "\"src/test/resources/parameters/prodConsWrongTypeEPParClass.json\"\n"
+ + "(ParameterRuntimeException):could not create default parameters for event protocol "
+ + "\"SUPER_TOK_DEL\"\n" + "org.onap.policy.apex.service.engine."
+ + "parameters.dummyclasses.SuperDooperCarrierTechnologyParameters "
+ + "cannot be cast to org.onap.policy.apex.service."
+ + "parameters.eventprotocol.EventProtocolParameters", e.getMessage());
}
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
index cc1d6d3dc..1c291786f 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
@@ -30,12 +30,12 @@ import org.junit.Test;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperTokenDelimitedEventProtocolParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -44,257 +44,362 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
*/
public class SyncParameterTests {
@Test
- public void syncBadNoSyncWithPeer() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json"};
+ public void syncBadNoSyncWithPeer() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json\"\n"
- + "Apex parameters invalid\n"
- + " parameter \\\"synchronousPeer\\\" is illegal on non synchronous event output "
- + "\"SyncProducer0\"", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", specified peered mode \"SYNCHRONOUS\" "
+ + "peer is illegal on eventOutputParameters \"SyncProducer0\" \n", e.getMessage());
}
}
@Test
- public void syncBadNotSyncWithPeer() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json"};
+ public void syncBadNotSyncWithPeer() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json\"\n"
- + "Apex parameters invalid\n"
- + " parameter \\\"synchronousPeer\\\" is illegal on non synchronous event output \"SyncProducer0\"",
- e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", specified peered mode \"SYNCHRONOUS\" peer is illegal "
+ + "on eventOutputParameters \"SyncProducer0\" \n", e.getMessage());
}
}
@Test
- public void syncBadSyncBadPeers() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsBadPeers.json"};
+ public void syncBadSyncBadPeers() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsBadPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsBadPeers.json\"" + "\nApex parameters invalid\n"
- + " specified \"synchronousPeer\" parameter value \"SyncConsumer1\" on event input "
- + "\"SyncConsumer0\" does not exist or is an invalid peer for this event handler\n"
- + " specified \"synchronousPeer\" parameter value \"SyncConsumer0\" on event input "
- + "\"SyncConsumer1\" does not exist or is an invalid peer for this event handler\n"
- + " specified \"synchronousPeer\" parameter value \"SyncProducer1\" on event output "
- + "\"SyncProducer0\" does not exist or is an invalid peer for this event handler\n"
- + " specified \"synchronousPeer\" parameter value \"SyncProducer0\" on event output "
- + "\"SyncProducer1\" does not exist or is an invalid peer for this event handler", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsBadPeers.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS does not exist "
+ + "or is not defined with the same peered mode\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS does not exist "
+ + "or is not defined with the same peered mode\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS does not exist "
+ + "or is not defined with the same peered mode\n"
+ + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS does not exist "
+ + "or is not defined with the same peered mode\n", e.getMessage());
}
}
@Test
- public void syncBadSyncInvalidTimeout() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsInvalidTimeout.json"};
+ public void syncBadSyncInvalidTimeout() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsInvalidTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsInvalidTimeout.json\"\n"
- + "Apex parameters invalid\n"
- + " parameter \\\"synchronousTimeout\\\" value \"-1\" is illegal on synchronous event input "
- + "\"SyncConsumer0\", specify a non-negative timeout value in milliseconds\n"
- + " parameter \\\"synchronousTimeout\\\" value \"-99999999\" is illegal on synchronous event input "
- + "\"SyncConsumer1\", specify a non-negative timeout value in milliseconds\n"
- + " parameter \\\"synchronousTimeout\\\" value \"-10\" is illegal on synchronous event output "
- + "\"SyncProducer0\", specify a non-negative timeout value in milliseconds\n"
- + " parameter \\\"synchronousTimeout\\\" value \"-3\" is illegal on synchronous event output "
- + "\"SyncProducer1\", specify a non-negative timeout value in milliseconds\n"
- + " synchronous timeout of event input \"SyncConsumer0\" and event output \"SyncProducer0\" "
- + "[-1/-10] do not match\n"
- + " synchronous timeout of event input \"SyncConsumer1\" and event output "
- + "\"SyncProducer1\" [-99999999/-3] do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsInvalidTimeout.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " specified peered mode \"SYNCHRONOUS\" timeout value \"-10\" is illegal, "
+ + "specify a non-negative timeout value in milliseconds\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
+ + "INVALID, specified peered mode \"SYNCHRONOUS\" timeout value \"-3\" is illegal, "
+ + "specify a non-negative timeout value in milliseconds\n"
+ + " parameter group map \"eventInputParameters\" INVALID, parameter group has status INVALID\n"
+ + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID, "
+ + "specified peered mode \"SYNCHRONOUS\" timeout value \"-1\" is illegal, "
+ + "specify a non-negative timeout value in milliseconds\n"
+ + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " specified peered mode \"SYNCHRONOUS\" timeout value \"-99999999\" is illegal, "
+ + "specify a non-negative timeout value in milliseconds\n", e.getMessage());
}
}
@Test
- public void syncBadSyncBadTimeout() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsBadTimeout.json"};
+ public void syncBadSyncBadTimeout() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsBadTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsBadTimeout.json\"\n" + "Apex parameters invalid\n"
- + " parameter \\\"synchronousTimeout\\\" is illegal on non synchronous event output "
- + "\"MyOtherProducer\"", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsBadTimeout.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" "
+ + "INVALID, parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"MyOtherProducer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
+ + "INVALID, specified peered mode \"SYNCHRONOUS\" "
+ + "timeout is illegal on eventOutputParameters \"MyOtherProducer\"\n", e.getMessage());
}
}
@Test
- public void syncBadSyncUnpairedTimeout() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsUnpairedTimeout.json"};
+ public void syncBadSyncUnpairedTimeout() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsUnpairedTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsUnpairedTimeout.json\"\n"
- + "Apex parameters invalid\n"
- + " synchronous timeout of event input \"SyncConsumer0\" and event output "
- + "\"SyncProducer0\" [1/10] do not match\n"
- + " synchronous timeout of event input \"SyncConsumer1\" and event output "
- + "\"SyncProducer1\" [99999999/3] do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsUnpairedTimeout.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS timeout 10 on event handler "
+ + "\"SyncProducer0\" does not equal timeout 1 on event handler \"SyncConsumer0\"\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS timeout 3 on event handler "
+ + "\"SyncProducer1\" does not equal timeout 99999999 on event handler \"SyncConsumer1\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS timeout 1 on event handler "
+ + "\"SyncConsumer0\" does not equal timeout 10 on event handler \"SyncProducer0\"\n"
+ + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS timeout 99999999 on event handler "
+ + "\"SyncConsumer1\" does not equal timeout 3 on event handler \"SyncProducer1\"\n" + "",
+ e.getMessage());
}
}
@Test
- public void syncGoodSyncGoodTimeoutProducer() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsProducerTimeout.json"};
+ public void syncGoodSyncGoodTimeoutProducer() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncGoodParamsProducerTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals(12345, parameters.getEventInputParameters().get("SyncConsumer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventInputParameters().get("SyncConsumer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(12345, parameters.getEventOutputParameters().get("SyncProducer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventOutputParameters().get("SyncProducer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
} catch (final Exception e) {
fail("This test should not throw an exception");
}
}
@Test
- public void syncGoodSyncGoodTimeoutConsumer() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsConsumerTimeout.json"};
+ public void syncGoodSyncGoodTimeoutConsumer() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncGoodParamsConsumerTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals(12345, parameters.getEventInputParameters().get("SyncConsumer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventInputParameters().get("SyncConsumer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(12345, parameters.getEventOutputParameters().get("SyncProducer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventOutputParameters().get("SyncProducer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
} catch (final Exception e) {
fail("This test should not throw an exception");
}
}
@Test
- public void syncGoodSyncGoodTimeoutBoth() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsBothTimeout.json"};
+ public void syncGoodSyncGoodTimeoutBoth() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncGoodParamsBothTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals(12345, parameters.getEventInputParameters().get("SyncConsumer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventInputParameters().get("SyncConsumer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(12345, parameters.getEventOutputParameters().get("SyncProducer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventOutputParameters().get("SyncProducer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
} catch (final Exception e) {
fail("This test should not throw an exception");
}
}
@Test
- public void syncUnusedConsumerPeers() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncUnusedConsumerPeers.json"};
+ public void syncUnusedConsumerPeers() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncUnusedConsumerPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncUnusedConsumerPeers.json\"\n" + "Apex parameters invalid\n"
- + " value of parameter \"synchronousPeer\" on event output \"SyncProducer1\" must be unique, "
- + "it s used on another event output\n"
- + " synchronous peers of event input \"SyncConsumer1\" and event output "
- + "\"SyncProducer1/SyncConsumer0\" do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncUnusedConsumerPeers.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
+ + "INVALID, peer \"SyncConsumer0 for peered mode SYNCHRONOUS, "
+ + "value \"SyncProducer0\" on peer \"SyncConsumer0\" "
+ + "does not equal event handler \"SyncProducer1\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
+ + "INVALID, peer \"SyncProducer1 for peered mode SYNCHRONOUS, "
+ + "value \"SyncConsumer0\" on peer \"SyncProducer1\" "
+ + "does not equal event handler \"SyncConsumer1\"\n", e.getMessage());
}
}
@Test
- public void syncMismatchedPeers() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncMismatchedPeers.json"};
+ public void syncMismatchedPeers() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncMismatchedPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncMismatchedPeers.json\"\nApex parameters invalid\n"
- + " synchronous peers of event input \"SyncConsumer0\" and event output "
- + "\"SyncProducer0/SyncConsumer1\" do not match\n"
- + " synchronous peers of event input \"SyncConsumer1\" and event output "
- + "\"SyncProducer1/SyncConsumer0\" do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncMismatchedPeers.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS, value \"SyncProducer1\" "
+ + "on peer \"SyncConsumer1\" does not equal event handler \"SyncProducer0\"\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS, value \"SyncProducer0\" "
+ + "on peer \"SyncConsumer0\" does not equal event handler \"SyncProducer1\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS, value \"SyncConsumer1\" "
+ + "on peer \"SyncProducer0\" does not equal event handler \"SyncConsumer0\"\n"
+ + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS, value \"SyncConsumer0\" "
+ + "on peer \"SyncProducer1\" does not equal event handler \"SyncConsumer1\"\n",
+ e.getMessage());
}
}
@Test
- public void syncUnusedProducerPeers() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncUnusedProducerPeers.json"};
+ public void syncUnusedProducerPeers() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncUnusedProducerPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncUnusedProducerPeers.json\"\nApex parameters invalid\n"
- + " value of parameter \"synchronousPeer\" on event input \"SyncConsumer1\" must be unique, "
- + "it is used on another event input\nsynchronous peers of event input \"SyncConsumer0\" and event"
- + " output \"SyncProducer1/SyncConsumer1\" do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncUnusedProducerPeers.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS, value \"SyncProducer1\" on peer "
+ + "\"SyncConsumer0\" does not equal event handler \"SyncProducer0\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, parameter group has status INVALID\n"
+ + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS, value \"SyncConsumer1\" on peer "
+ + "\"SyncProducer1\" does not equal event handler \"SyncConsumer0\"\n", e.getMessage());
}
}
@Test
- public void syncMismatchedTimeout() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncUnusedProducerPeers.json"};
+ public void syncMismatchedTimeout() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncMismatchedTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncUnusedProducerPeers.json\"\n" + "Apex parameters invalid\n"
- + " value of parameter \"synchronousPeer\" on event input \"SyncConsumer1\" "
- + "must be unique, it s used on another event input\n"
- + " synchronous peers of event input \"SyncConsumer0\" and event output "
- + "\"SyncProducer1/SyncConsumer1\" do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncMismatchedTimeout.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" "
+ + "INVALID, parameter group has status INVALID\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " peer \"SyncConsumer1 for peered mode SYNCHRONOUS timeout 456 "
+ + "on event handler \"SyncProducer1\" does not equal timeout 123 "
+ + "on event handler \"SyncConsumer1\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " peer \"SyncProducer1 for peered mode SYNCHRONOUS timeout 123 "
+ + "on event handler \"SyncConsumer1\" does not equal timeout 456 "
+ + "on event handler \"SyncProducer1\"\n", e.getMessage());
}
}
@Test
public void syncGoodParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/SyncGoodParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/syncGoodParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -306,22 +411,22 @@ public class SyncParameterTests {
assertEquals(19, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
- final CarrierTechnologyParameters prodCT0 =
- parameters.getEventOutputParameters().get("SyncProducer0").getCarrierTechnologyParameters();
- final EventProtocolParameters prodEP0 =
- parameters.getEventOutputParameters().get("SyncProducer0").getEventProtocolParameters();
- final CarrierTechnologyParameters consCT0 =
- parameters.getEventInputParameters().get("SyncConsumer0").getCarrierTechnologyParameters();
- final EventProtocolParameters consEP0 =
- parameters.getEventInputParameters().get("SyncConsumer0").getEventProtocolParameters();
- final CarrierTechnologyParameters prodCT1 =
- parameters.getEventOutputParameters().get("SyncProducer1").getCarrierTechnologyParameters();
- final EventProtocolParameters prodEP1 =
- parameters.getEventOutputParameters().get("SyncProducer1").getEventProtocolParameters();
- final CarrierTechnologyParameters consCT1 =
- parameters.getEventInputParameters().get("SyncConsumer1").getCarrierTechnologyParameters();
- final EventProtocolParameters consEP1 =
- parameters.getEventInputParameters().get("SyncConsumer1").getEventProtocolParameters();
+ final CarrierTechnologyParameters prodCT0 = parameters.getEventOutputParameters().get("SyncProducer0")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters prodEP0 = parameters.getEventOutputParameters().get("SyncProducer0")
+ .getEventProtocolParameters();
+ final CarrierTechnologyParameters consCT0 = parameters.getEventInputParameters().get("SyncConsumer0")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters consEP0 = parameters.getEventInputParameters().get("SyncConsumer0")
+ .getEventProtocolParameters();
+ final CarrierTechnologyParameters prodCT1 = parameters.getEventOutputParameters().get("SyncProducer1")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters prodEP1 = parameters.getEventOutputParameters().get("SyncProducer1")
+ .getEventProtocolParameters();
+ final CarrierTechnologyParameters consCT1 = parameters.getEventInputParameters().get("SyncConsumer1")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters consEP1 = parameters.getEventInputParameters().get("SyncConsumer1")
+ .getEventProtocolParameters();
assertEquals("FILE", prodCT0.getLabel());
assertEquals("JSON", prodEP0.getLabel());
@@ -335,8 +440,7 @@ public class SyncParameterTests {
assertTrue(consCT1 instanceof SuperDooperCarrierTechnologyParameters);
assertTrue(consEP1 instanceof SuperTokenDelimitedEventProtocolParameters);
- final SuperDooperCarrierTechnologyParameters superDooperParameters =
- (SuperDooperCarrierTechnologyParameters) consCT1;
+ final SuperDooperCarrierTechnologyParameters superDooperParameters = (SuperDooperCarrierTechnologyParameters) consCT1;
assertEquals("localhost:9092", superDooperParameters.getBootstrapServers());
assertEquals("all", superDooperParameters.getAcks());
assertEquals(0, superDooperParameters.getRetries());
@@ -350,17 +454,17 @@ public class SyncParameterTests {
assertEquals("apex-out", superDooperParameters.getProducerTopic());
assertEquals(100, superDooperParameters.getConsumerPollTime());
assertEquals("org.apache.superDooper.common.serialization.StringSerializer",
- superDooperParameters.getKeySerializer());
+ superDooperParameters.getKeySerializer());
assertEquals("org.apache.superDooper.common.serialization.StringSerializer",
- superDooperParameters.getValueSerializer());
+ superDooperParameters.getValueSerializer());
assertEquals("org.apache.superDooper.common.serialization.StringDeserializer",
- superDooperParameters.getKeyDeserializer());
+ superDooperParameters.getKeyDeserializer());
assertEquals("org.apache.superDooper.common.serialization.StringDeserializer",
- superDooperParameters.getValueDeserializer());
+ superDooperParameters.getValueDeserializer());
- final String[] consumerTopics = {"apex-in"};
+ final String[] consumerTopics = { "apex-in" };
assertEquals(Arrays.asList(consumerTopics), superDooperParameters.getConsumerTopicList());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
index 604849f31..3ec84b150 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
@@ -24,8 +24,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for SuperDooper as an event carrier technology.
@@ -46,14 +47,11 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar
private static final int DEFAULT_SESSION_TIMEOUT = 30000;
private static final String DEFAULT_PRODUCER_TOPIC = "apex-out";
private static final int DEFAULT_CONSUMER_POLL_TIME = 100;
- private static final String[] DEFAULT_CONSUMER_TOPIC_LIST = {"apex-in"};
+ private static final String[] DEFAULT_CONSUMER_TOPIC_LIST = { "apex-in" };
private static final String DEFAULT_KEY_SERIALIZER = "org.apache.superDooper.common.serialization.StringSerializer";
- private static final String DEFAULT_VALUE_SERIALIZER =
- "org.apache.superDooper.common.serialization.StringSerializer";
- private static final String DEFAULT_KEY_DESERIALIZER =
- "org.apache.superDooper.common.serialization.StringDeserializer";
- private static final String DEFAULT_VALUE_DESERIALIZER =
- "org.apache.superDooper.common.serialization.StringDeserializer";
+ private static final String DEFAULT_VALUE_SERIALIZER = "org.apache.superDooper.common.serialization.StringSerializer";
+ private static final String DEFAULT_KEY_DESERIALIZER = "org.apache.superDooper.common.serialization.StringDeserializer";
+ private static final String DEFAULT_VALUE_DESERIALIZER = "org.apache.superDooper.common.serialization.StringDeserializer";
// Parameter property map tokens
private static final String PROPERTY_BOOTSTRAP_SERVERS = "bootstrap.servers";
@@ -91,19 +89,18 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar
private String valueDeserializer = DEFAULT_VALUE_DESERIALIZER;
/**
- * Constructor to create a file carrier technology parameters instance and register the instance
- * with the parameter service.
+ * Constructor to create a file carrier technology parameters instance and register the instance with the parameter
+ * service.
*/
public SuperDooperCarrierTechnologyParameters() {
- super(SuperDooperCarrierTechnologyParameters.class.getCanonicalName());
- ParameterService.registerParameters(SuperDooperCarrierTechnologyParameters.class, this);
+ super();
// Set the carrier technology properties for the FILE carrier technology
this.setLabel("SUPER_DOOPER");
this.setEventProducerPluginClass(
- "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventProducer");
+ "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventProducer");
this.setEventConsumerPluginClass(
- "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventSubscriber");
+ "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventSubscriber");
}
/**
@@ -454,92 +451,103 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
+ * @see org.onap.policy.common.parameters.ParameterGroup#getName()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public String getName() {
+ return this.getLabel();
+ }
- errorMessageBuilder.append(super.validate());
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (bootstrapServers == null || bootstrapServers.trim().length() == 0) {
- errorMessageBuilder
- .append(" bootstrapServers not specified, must be specified as a string of form host:port\n");
+ result.setResult("bootstrapServers", ValidationStatus.INVALID,
+ "bootstrapServers not specified, must be specified as a string of form host:port");
}
if (acks == null || acks.trim().length() == 0) {
- errorMessageBuilder.append(" acks not specified, must be specified as a string with values [0|1|all]\n");
+ result.setResult("acks", ValidationStatus.INVALID,
+ "acks not specified, must be specified as a string with values [0|1|all]");
}
if (retries < 0) {
- errorMessageBuilder.append(" retries [" + retries + "] invalid, must be specified as retries >= 0\n");
+ result.setResult("retries", ValidationStatus.INVALID, "[" + retries + "] invalid, must be specified as retries >= 0");
}
if (batchSize < 0) {
- errorMessageBuilder
- .append(" batchSize [" + batchSize + "] invalid, must be specified as batchSize >= 0\n");
+ result.setResult("batchSize", ValidationStatus.INVALID, "[" + batchSize + "] invalid, must be specified as batchSize >= 0");
}
if (lingerTime < 0) {
- errorMessageBuilder
- .append(" lingerTime [" + lingerTime + "] invalid, must be specified as lingerTime >= 0\n");
+ result.setResult("lingerTime", ValidationStatus.INVALID, "[" + lingerTime + "] invalid, must be specified as lingerTime >= 0");
}
if (bufferMemory < 0) {
- errorMessageBuilder
- .append(" bufferMemory [" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0\n");
+ result.setResult("bufferMemory", ValidationStatus.INVALID, "[" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0");
}
if (groupId == null || groupId.trim().length() == 0) {
- errorMessageBuilder.append(" groupId not specified, must be specified as a string\n");
+ result.setResult("groupId", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
if (autoCommitTime < 0) {
- errorMessageBuilder.append(
- " autoCommitTime [" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0\n");
+ result.setResult("autoCommitTime", ValidationStatus.INVALID, "[" + autoCommitTime
+ + "] invalid, must be specified as autoCommitTime >= 0");
}
if (sessionTimeout < 0) {
- errorMessageBuilder.append(
- " sessionTimeout [" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0\n");
+ result.setResult("sessionTimeout", ValidationStatus.INVALID, "sessionTimeout [" + sessionTimeout
+ + "] invalid, must be specified as sessionTimeout >= 0");
}
if (producerTopic == null || producerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" producerTopic not specified, must be specified as a string\n");
+ result.setResult("producerTopic", ValidationStatus.INVALID, "producerTopic not specified, must be specified as a string");
}
if (consumerPollTime < 0) {
- errorMessageBuilder.append(" consumerPollTime [" + consumerPollTime
- + "] invalid, must be specified as consumerPollTime >= 0\n");
+ result.setResult("consumerPollTime", ValidationStatus.INVALID, "[" + consumerPollTime
+ + "] invalid, must be specified as consumerPollTime >= 0");
}
if (consumerTopicList == null || consumerTopicList.length == 0) {
- errorMessageBuilder.append(" consumerTopicList not specified, must be specified as a list of strings\n");
+ result.setResult("consumerTopicList", ValidationStatus.INVALID, "not specified, must be specified as a list of strings");
}
+ StringBuilder consumerTopicMessageBuilder = new StringBuilder();
for (final String consumerTopic : consumerTopicList) {
if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" invalid consumer topic \"" + consumerTopic
- + "\" specified on consumerTopicList, consumer topics must be specified as strings\n");
+ consumerTopicMessageBuilder.append(" invalid consumer topic \"" + consumerTopic
+ + "\" specified on consumerTopicList, consumer topics must be specified as strings");
}
}
+
+ if (consumerTopicMessageBuilder.length() > 0) {
+ result.setResult("consumerTopicList", ValidationStatus.INVALID, consumerTopicMessageBuilder.toString());
+ }
if (keySerializer == null || keySerializer.trim().length() == 0) {
- errorMessageBuilder.append(" keySerializer not specified, must be specified as a string\n");
+ result.setResult("keySerializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
if (valueSerializer == null || valueSerializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueSerializer not specified, must be specified as a string\n");
+ result.setResult("valueSerializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
if (keyDeserializer == null || keyDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" keyDeserializer not specified, must be specified as a string\n");
+ result.setResult("keyDeserializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
if (valueDeserializer == null || valueDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueDeserializer not specified, must be specified as a string\n");
+ result.setResult("valueDeserializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java
index 8d7d65977..72dbc57a6 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java
@@ -21,7 +21,6 @@
package org.onap.policy.apex.service.engine.parameters.dummyclasses;
import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
* Distributor parameters for the Super Dooper Distributor.
@@ -44,9 +43,7 @@ public class SuperDooperDistributorParameters extends DistributorParameters {
private String jGroupsBindAddress = DEFAULT_INFINSPAN_JGROUPS_BIND_ADDRESS;
public SuperDooperDistributorParameters() {
- super(SuperDooperDistributorParameters.class.getCanonicalName());
- ParameterService.registerParameters(SuperDooperDistributorParameters.class, this);
- ParameterService.registerParameters(DistributorParameters.class, this);
+ super();
}
public String getConfigFile() {
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
index bac271319..02d986186 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
@@ -20,7 +20,6 @@
package org.onap.policy.apex.service.engine.parameters.dummyclasses;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTokenDelimitedParameters;
@@ -40,7 +39,6 @@ public class SuperTokenDelimitedEventProtocolParameters extends EventProtocolTex
*/
public SuperTokenDelimitedEventProtocolParameters() {
super(JSONEventProtocolParameters.class.getCanonicalName());
- ParameterService.registerParameters(SuperTokenDelimitedEventProtocolParameters.class, this);
// Set the event protocol properties for the JSON carrier technology
this.setLabel(SUPER_TOKEN_EVENT_PROTOCOL_LABEL);
diff --git a/services/services-engine/src/test/resources/parameters/syncMismatchedTimeout.json b/services/services-engine/src/test/resources/parameters/syncMismatchedTimeout.json
new file mode 100644
index 000000000..378106825
--- /dev/null
+++ b/services/services-engine/src/test/resources/parameters/syncMismatchedTimeout.json
@@ -0,0 +1,74 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 19,
+ "deploymentPort": 65522,
+ "policyModelFileName": "src/test/resources/policymodels/SamplePolicyModelMVEL.json",
+ "engineParameters": {
+ "executorParameters": {
+ "MVEL": {
+ "parameterClassName": "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "SyncProducer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "FILE",
+ "parameters": {
+ "fileName": "/tmp/aaa.json"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "synchronousMode": true,
+ "synchronousPeer": "SyncConsumer0"
+ },
+ "SyncProducer1": {
+ "synchronousMode": true,
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "FILE",
+ "parameters": {
+ "fileName": "/tmp/aaa.json"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "synchronousPeer": "SyncConsumer1",
+ "synchronousTimeout" : 456
+ }
+ },
+ "eventInputParameters": {
+ "SyncConsumer0": {
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "synchronousMode": true,
+ "synchronousPeer": "SyncProducer0",
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "FILE",
+ "parameters": {
+ "fileName": "/tmp/bbb.json"
+ }
+ }
+ },
+ "SyncConsumer1": {
+ "synchronousPeer": "SyncProducer1",
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "SUPER_DOOPER",
+ "parameterClassName": "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "SUPER_TOK_DEL",
+ "parameterClassName": "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperTokenDelimitedEventProtocolParameters"
+ },
+ "synchronousMode": true,
+ "synchronousTimeout" : 123
+ }
+ }
+} \ No newline at end of file