aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-06-19 09:43:28 +0000
committerliamfallon <liam.fallon@est.tech>2019-06-19 09:43:28 +0000
commitdc2ca16a6d7d8cc13be5716e058add8190ea4479 (patch)
tree2c2d09d30595eb3e6f60b27bd8a2b56c393f2c1c
parent70611fc67629b4ab0c7db4104d6a26a0645dac0a (diff)
Fix junit tests in apex-pdp
Sonar fix broke some of the junit tests for parameters; fixed those. Issue-ID: POLICY-1791 Change-Id: If39472b9936d5312a1d4109ad83610f5913d3e34 Signed-off-by: liamfallon <liam.fallon@est.tech>
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java7
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java208
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java17
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java371
4 files changed, 290 insertions, 313 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
index 08c0e6910..3aa1f17ff 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
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 61518b84f..10b9ab31d 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
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -42,14 +43,13 @@ import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ParameterTests {
@Test
public void invalidParametersNoFileTest() throws ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/invalidNoFile.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/invalidNoFile.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -63,23 +63,21 @@ 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 ParameterException e) {
- assertTrue(e.getMessage().startsWith(
- "validation error(s) on parameters from \"src/test/resources/parameters/empty.json\""));
+ 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 {
@@ -87,21 +85,20 @@ public class ParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/noParams.json\"\n"
- + "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());
+ + "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 {
@@ -110,25 +107,23 @@ public class ParameterTests {
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/blankParams.json\"\n"
- + "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());
+ + "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 {
@@ -136,53 +131,53 @@ public class ParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/badParams.json\"\n"
- + "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\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, "
- + "\"null\" invalid, must be specified as a non-empty string\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group \"TheFileConsumer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", 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, "
- + "\"null\" invalid, must be specified as a non-empty string\n", 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\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group map 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, "
+ + "\"null\" invalid, must be specified as a non-empty string\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group map 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, "
+ + "\"null\" invalid, must be specified as a non-empty string\n", e.getMessage());
}
}
@Test
public void modelNotFileTest() {
- final String[] args =
- { "-c", "src/test/resources/parameters/badParamsModelNotFile.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/badParamsModelNotFile.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
} catch (final ParameterException e) {
- assertEquals("validation error(s) on parameters from "
+ assertEquals(
+ "validation error(s) on parameters from "
+ "\"src/test/resources/parameters/badParamsModelNotFile.json\"\n"
+ "parameter group \"APEX_PARAMETERS\" type "
+ "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
@@ -190,14 +185,13 @@ public class ParameterTests {
+ "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" "
+ "INVALID, parameter group has status INVALID\n" + " field \"policyModelFileName\" "
+ "type \"java.lang.String\" value \"src/test\" INVALID, is not a plain file\n",
- e.getMessage());
+ 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 {
@@ -209,38 +203,36 @@ 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());
+ .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");
}
@@ -248,8 +240,7 @@ public class ParameterTests {
@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 {
@@ -261,14 +252,14 @@ public class ParameterTests {
assertEquals(345, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
- final CarrierTechnologyParameters prodCarrierTech = parameters.getEventOutputParameters()
- .get("FirstProducer").getCarrierTechnologyParameters();
- final EventProtocolParameters prodEventProt = parameters.getEventOutputParameters().get("FirstProducer")
- .getEventProtocolParameters();
- final CarrierTechnologyParameters consCarrierTech = parameters.getEventInputParameters()
- .get("MySuperDooperConsumer1").getCarrierTechnologyParameters();
- final EventProtocolParameters consEventProt = parameters.getEventInputParameters()
- .get("MySuperDooperConsumer1").getEventProtocolParameters();
+ final CarrierTechnologyParameters prodCarrierTech =
+ parameters.getEventOutputParameters().get("FirstProducer").getCarrierTechnologyParameters();
+ final EventProtocolParameters prodEventProt =
+ parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters();
+ final CarrierTechnologyParameters consCarrierTech =
+ parameters.getEventInputParameters().get("MySuperDooperConsumer1").getCarrierTechnologyParameters();
+ final EventProtocolParameters consEventProt =
+ parameters.getEventInputParameters().get("MySuperDooperConsumer1").getEventProtocolParameters();
assertEquals("SUPER_DOOPER", prodCarrierTech.getLabel());
assertEquals("SUPER_TOK_DEL", prodEventProt.getLabel());
@@ -277,8 +268,8 @@ public class ParameterTests {
assertTrue(prodCarrierTech instanceof SuperDooperCarrierTechnologyParameters);
- final SuperDooperCarrierTechnologyParameters superDooperParameters
- = (SuperDooperCarrierTechnologyParameters) prodCarrierTech;
+ final SuperDooperCarrierTechnologyParameters superDooperParameters =
+ (SuperDooperCarrierTechnologyParameters) prodCarrierTech;
assertEquals("somehost:12345", superDooperParameters.getBootstrapServers());
assertEquals("0", superDooperParameters.getAcks());
assertEquals(25, superDooperParameters.getRetries());
@@ -296,8 +287,7 @@ 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 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 87f1adc02..792897f23 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
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -33,7 +34,7 @@ import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ProducerConsumerTests {
@@ -87,7 +88,7 @@ public class ProducerConsumerTests {
+ "\"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 "
+ + "parameter group map 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());
@@ -109,12 +110,12 @@ public class ProducerConsumerTests {
+ "\"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 "
+ + "parameter group map 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 "
+ + "parameter group map 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."
@@ -216,7 +217,7 @@ public class ProducerConsumerTests {
+ "\"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 "
+ + "parameter group map 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."
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 8ad0654b1..153913b96 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
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -39,14 +40,13 @@ import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class SyncParameterTests {
@Test
public void syncBadNoSyncWithPeer() throws ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -54,22 +54,21 @@ public class SyncParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"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());
+ + "\"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 map 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 ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -77,22 +76,21 @@ public class SyncParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"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());
+ + "\"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 map 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 ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncBadParamsBadPeers.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsBadPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -100,35 +98,32 @@ public class SyncParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"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());
+ + "\"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 map 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 map 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 ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncBadParamsInvalidTimeout.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsInvalidTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -136,35 +131,34 @@ public class SyncParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"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());
+ + "\"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 map 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 map 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 ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncBadParamsBadTimeout.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsBadTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -172,35 +166,35 @@ public class SyncParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"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());
+ + "\"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 map 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 ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncBadParamsUnpairedTimeout.json" };
+ 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 ParameterException e) {
- assertEquals("validation error(s) on parameters from "
+ assertEquals(
+ "validation error(s) on parameters from "
+ "\"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 "
+ + "parameter group map 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"
@@ -209,7 +203,7 @@ public class SyncParameterTests {
+ ", 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 "
+ + "parameter group map 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"
@@ -217,26 +211,25 @@ public class SyncParameterTests {
+ "\"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());
+ e.getMessage());
}
}
@Test
public void syncGoodSyncGoodTimeoutProducer() throws ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncGoodParamsProducerTimeout.json" };
+ 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");
}
@@ -244,20 +237,19 @@ public class SyncParameterTests {
@Test
public void syncGoodSyncGoodTimeoutConsumer() throws ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncGoodParamsConsumerTimeout.json" };
+ 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");
}
@@ -265,20 +257,19 @@ public class SyncParameterTests {
@Test
public void syncGoodSyncGoodTimeoutBoth() throws ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncGoodParamsBothTimeout.json" };
+ 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");
}
@@ -286,8 +277,7 @@ public class SyncParameterTests {
@Test
public void syncUnusedConsumerPeers() throws ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncUnusedConsumerPeers.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/syncUnusedConsumerPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -295,42 +285,42 @@ public class SyncParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"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());
+ + "\"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 map 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 map 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 ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncMismatchedPeers.json" };
+ 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 ParameterException e) {
- assertEquals("validation error(s) on parameters from "
+ assertEquals(
+ "validation error(s) on parameters from "
+ "\"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 "
+ + "parameter group map 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"
@@ -339,7 +329,7 @@ public class SyncParameterTests {
+ ", 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 "
+ + "parameter group map 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"
@@ -347,14 +337,13 @@ public class SyncParameterTests {
+ "\"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());
+ e.getMessage());
}
}
@Test
public void syncUnusedProducerPeers() throws ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncUnusedProducerPeers.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/syncUnusedProducerPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -362,27 +351,26 @@ public class SyncParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"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());
+ + "\"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 map 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 map 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 ParameterException {
- final String[] args =
- { "-c", "src/test/resources/parameters/syncMismatchedTimeout.json" };
+ final String[] args = { "-c", "src/test/resources/parameters/syncMismatchedTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -390,30 +378,28 @@ public class SyncParameterTests {
fail("This test should throw an exception");
} catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"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());
+ + "\"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 map 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 map 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 {
@@ -425,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());
@@ -455,7 +441,7 @@ public class SyncParameterTests {
assertTrue(consEP1 instanceof SuperTokenDelimitedEventProtocolParameters);
final SuperDooperCarrierTechnologyParameters superDooperParameters =
- (SuperDooperCarrierTechnologyParameters) consCT1;
+ (SuperDooperCarrierTechnologyParameters) consCT1;
assertEquals("localhost:9092", superDooperParameters.getBootstrapServers());
assertEquals("all", superDooperParameters.getAcks());
assertEquals(0, superDooperParameters.getRetries());
@@ -469,16 +455,15 @@ 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 ParameterException e) {
fail("This test should not throw an exception");