aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'services/services-engine/src/test/java/org')
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/PluginFactoriesTest.java9
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArgumentsTest.java129
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java16
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java7
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java27
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java24
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java41
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java25
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java29
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java280
10 files changed, 201 insertions, 386 deletions
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/PluginFactoriesTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/PluginFactoriesTest.java
index 3055daeef..514b3b1e5 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/PluginFactoriesTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/PluginFactoriesTest.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* 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=========================================================
*/
@@ -41,7 +42,7 @@ public class PluginFactoriesTest {
@Test
public void testEventConsumerFactory() throws ApexEventException, ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/factoryGoodParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/factoryGoodParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArgumentsTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArgumentsTest.java
index 09fbe91fe..09663c0bf 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArgumentsTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArgumentsTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,99 +44,62 @@ public class ApexCommandLineArgumentsTest {
public void testCommandLineArguments() throws ApexException {
final ApexCommandLineArguments apexArguments = new ApexCommandLineArguments();
- final String[] args00 =
- { "" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args00);
- apexArguments.validate();
- }).hasMessage("Apex configuration file was not specified as an argument");
- final String[] args01 =
- { "-h" };
+ final String[] args00 = {""};
+ apexArguments.parse(args00);
+ assertThatThrownBy(() -> apexArguments.validate())
+ .hasMessage("Tosca Policy file was not specified as an argument");
+ final String[] args01 = {"-h"};
final String result = apexArguments.parse(args01);
assertTrue(result.startsWith("usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]"));
- final String[] args02 =
- { "-v" };
+ final String[] args02 = {"-v"};
final String result02 = apexArguments.parse(args02);
assertTrue(result02.startsWith("Apex Adaptive Policy Engine"));
- final String[] args03 =
- { "-v", "-h" };
-
+ final String[] args03 = {"-v", "-h"};
final String result03 = apexArguments.parse(args03);
assertTrue(result03.startsWith("usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]"));
- final String[] args04 =
- { "-h", "-v" };
-
+ final String[] args04 = {"-h", "-v"};
final String result04 = apexArguments.parse(args04);
assertTrue(result04.startsWith("usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]"));
- final String[] args05 =
- { "-a" };
+ final String[] args05 = {"-a"};
assertThatThrownBy(() -> apexArguments.parse(args05))
.hasMessage("invalid command line arguments specified : Unrecognized option: -a");
- final String[] args06 =
- { "-c", "hello", "-m", "goodbye", "-h", "-v" };
+
+ final String[] args06 = {"-p", "goodbye", "-h", "-v"};
final String result06 = apexArguments.parse(args06);
assertTrue(result06.startsWith("usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]"));
- final String[] args07 =
- { "-c", "hello", "-m", "goodbye", "-h", "aaa" };
+ final String[] args07 = {"-p", "goodbye", "-h", "aaa"};
assertThatThrownBy(() -> apexArguments.parse(args07))
- .hasMessage("too many command line arguments specified : [-c, hello, -m, goodbye, -h, aaa]");
+ .hasMessage("too many command line arguments specified : [-p, goodbye, -h, aaa]");
}
@Test
public void testCommandLineFileParameters() throws ApexException {
final ApexCommandLineArguments apexArguments = new ApexCommandLineArguments();
- final String[] args00 =
- { "-c", "zooby" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args00);
- apexArguments.validate();
- }).hasMessage("Apex configuration file \"zooby\" does not exist");
- final String[] args01 =
- { "-c" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args01);
- apexArguments.validate();
- }).hasMessage("invalid command line arguments specified : Missing argument for option: c");
- final String[] args02 =
- { "-c", "src/test/resources/parameters/goodParams.json" };
- apexArguments.parse(args02);
- apexArguments.validate();
+ final String[] args00 = {"-c", "zooby"};
+ assertThatThrownBy(() -> apexArguments.parse(args00))
+ .hasMessage("invalid command line arguments specified : Unrecognized option: -c");
- final String[] args03 =
- { "-c", "src/test/resources/parameters/goodParams.json", "-m", "zooby" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args03);
- apexArguments.validate();
- }).hasMessage("Apex model file \"zooby\" does not exist");
- final String[] args04 =
- { "-m" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args04);
- apexArguments.validate();
- }).hasMessage("invalid command line arguments specified : Missing argument for option: m");
- final String[] args05 =
- { "-c", "src/test/resources/parameters/goodParams.json", "-m" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args05);
- apexArguments.validate();
- }).hasMessage("invalid command line arguments specified : Missing argument for option: m");
- final String[] args06 =
- { "-c", "src/test/resources/parameters/goodParams.json", "-m",
- "src/test/resources/main/DummyModelFile.json" };
- apexArguments.parse(args06);
+ final String[] args01 = {"-p"};
+ assertThatThrownBy(() -> apexArguments.parse(args01))
+ .hasMessage("invalid command line arguments specified : Missing argument for option: p");
+
+ final String[] args02 = {"-p", "src/test/resources/parameters/goodParams.json"};
+ apexArguments.parse(args02);
apexArguments.validate();
- final String[] args07 =
- { "-c", "parameters/goodParams.json", "-m", "main/DummyModelFile.json" };
+ final String[] args03 = {"-p", "src/test/resources/parameters/goodParams.json", "-m", "zooby"};
+ assertThatThrownBy(() -> apexArguments.parse(args03))
+ .hasMessage("invalid command line arguments specified : Unrecognized option: -m");
- apexArguments.parse(args07);
+ final String[] args06 = {"-p", "src/test/resources/parameters/goodParams.json"};
+ apexArguments.parse(args06);
apexArguments.validate();
}
@@ -143,33 +107,26 @@ public class ApexCommandLineArgumentsTest {
public void testCommandLineRelativeRootParameters() throws ApexException {
final ApexCommandLineArguments apexArguments = new ApexCommandLineArguments();
- final String[] args00 =
- { "-c", "src/test/resources/parameters/goodParams.json", "-rfr", "zooby" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args00);
- apexArguments.validate();
- }).hasMessageContaining("zooby\" does not exist or is not a directory");
- final String[] args01 =
- { "-rfr" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args01);
- apexArguments.validate();
- }).hasMessage("invalid command line arguments specified : Missing argument for option: rfr");
- final String[] args02 =
- { "-c", "src/test/resources/parameters/goodParams.json", "-rfr", "pom.xml" };
- assertThatThrownBy(() -> {
- apexArguments.parse(args02);
- apexArguments.validate();
- }).hasMessageContaining("pom.xml\" does not exist or is not a directory");
- final String[] args03 =
- { "-c", "src/test/resources/parameters/goodParams.json", "-rfr", "target" };
+ final String[] args00 = {"-p", "src/test/resources/parameters/goodParams.json", "-rfr", "zooby"};
+ apexArguments.parse(args00);
+ assertThatThrownBy(() -> apexArguments.validate())
+ .hasMessageContaining("zooby\" does not exist or is not a directory");
+
+ final String[] args01 = {"-rfr"};
+ assertThatThrownBy(() -> apexArguments.parse(args01))
+ .hasMessage("invalid command line arguments specified : Missing argument for option: rfr");
+ final String[] args02 = {"-p", "src/test/resources/parameters/goodParams.json", "-rfr", "pom.xml"};
+ apexArguments.parse(args02);
+ assertThatThrownBy(() -> apexArguments.validate())
+ .hasMessageContaining("pom.xml\" does not exist or is not a directory");
+
+ final String[] args03 = {"-p", "src/test/resources/parameters/goodParams.json", "-rfr", "target"};
apexArguments.parse(args03);
apexArguments.validate();
final String[] args04 =
- { "-c", "src/test/resources/parameters/goodParamsRelative.json", "-rfr", "src/test/resources" };
-
+ {"-p", "src/test/resources/parameters/goodParamsRelative.json", "-rfr", "src/test/resources"};
apexArguments.parse(args04);
apexArguments.validate();
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
index f38dcaa40..122e47bb1 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
@@ -62,9 +62,9 @@ public class ApexMainTest {
ApexMain.main(null);
await().atMost(200, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
- .contains("Apex configuration file was not specified as an argument"));
+ .contains("Tosca Policy file was not specified as an argument"));
assertThat(outContent.toString())
- .contains("Apex configuration file was not specified as an argument");
+ .contains("Tosca Policy file was not specified as an argument");
}
@Test
@@ -100,7 +100,7 @@ public class ApexMainTest {
OutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
- String[] args = { "-c", "src/test/resources/parameters/badParams.json" };
+ String[] args = { "-p", "src/test/resources/parameters/badParams.json" };
final ApexMain apexMain = new ApexMain(args);
await().atMost(200, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
@@ -114,7 +114,7 @@ public class ApexMainTest {
OutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
- String[] args = { "-c", "src/test/resources/parameters/correctParams.json" };
+ String[] args = { "-p", "src/test/resources/parameters/correctParams.json" };
final ApexMain apexMain = new ApexMain(args);
assertEquals("MyApexEngine",
@@ -129,7 +129,7 @@ public class ApexMainTest {
OutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
- String[] args = { "-c", "src/test/resources/parameters/correctParamsJavaProperties.json" };
+ String[] args = { "-p", "src/test/resources/parameters/correctParamsJavaProperties.json" };
final ApexMain apexMain = new ApexMain(args);
assertEquals("MyApexEngine",
@@ -147,8 +147,7 @@ public class ApexMainTest {
OutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
Map<ToscaPolicyIdentifier, String[]> argsMap = new HashMap<ToscaPolicyIdentifier, String[]>();
- String[] args = {"-c", "src/test/resources/parameters/correctParams.json", "-m",
- "src/test/resources/policymodels/SmallModel.json"};
+ String[] args = {"-p", "src/test/resources/parameters/correctParams.json"};
argsMap.put(new ToscaPolicyIdentifier("id1", "v1"), args);
final ApexMain apexMain = new ApexMain(argsMap);
ApexParameters apexParam = (ApexParameters) apexMain.getApexParametersMap().values().toArray()[0];
@@ -163,8 +162,7 @@ public class ApexMainTest {
OutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
Map<ToscaPolicyIdentifier, String[]> argsMap = new HashMap<ToscaPolicyIdentifier, String[]>();
- String[] args = {"-c", "src/test/resources/parameters/correctParams.json", "-m",
- "src/test/resources/policymodels/SmallModel.json"};
+ String[] args = {"-p", "src/test/resources/parameters/correctParams.json"};
argsMap.put(new ToscaPolicyIdentifier("id1", "v1"), args);
argsMap.put(new ToscaPolicyIdentifier("id2", "v2"), args);
final ApexMain apexMain = new ApexMain(argsMap);
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java
index 1c816768f..9557ca8f9 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +42,7 @@ public class ApexParametersTest {
@Test
public void testJavaPropertiesOk() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/javaPropertiesOK.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/javaPropertiesOK.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -55,7 +56,7 @@ public class ApexParametersTest {
@Test
public void testJavaPropertiesEmpty() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/javaPropertiesEmpty.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/javaPropertiesEmpty.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -65,7 +66,7 @@ public class ApexParametersTest {
@Test
public void testJavaPropertiesBad() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/javaPropertiesBad.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/javaPropertiesBad.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
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 e8485d109..a55afbed4 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +41,7 @@ public class ContextParameterTests {
@Test
public void testNoParamsTest() {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextNoParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextNoParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -51,7 +52,7 @@ public class ContextParameterTests {
@Test
public void testBadParamsTest() {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextBadParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -62,7 +63,7 @@ public class ContextParameterTests {
@Test
public void testBadPluginParamNameTest() {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadPluginNameParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextBadPluginNameParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -74,7 +75,7 @@ public class ContextParameterTests {
@Test
public void testBadClassParamTest() {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadClassParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextBadClassParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage(
@@ -86,7 +87,7 @@ public class ContextParameterTests {
@Test
public void testBadPluginClassTest() {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadPluginClassParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextBadPluginClassParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -102,7 +103,7 @@ public class ContextParameterTests {
@Test
public void testOkFlushParamTest() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextOKFlushParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextOKFlushParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -115,7 +116,7 @@ public class ContextParameterTests {
@Test
public void testOkDefaultParamTest() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextOKDefaultParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextOKDefaultParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -128,7 +129,7 @@ public class ContextParameterTests {
@Test
public void testOkDistParamTest() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextOKDistParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextOKDistParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -142,7 +143,7 @@ public class ContextParameterTests {
@Test
public void testOkFullDefaultParamTest() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/goodParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/goodParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -164,7 +165,7 @@ public class ContextParameterTests {
@Test
public void testOkFullParamTest() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextOKFullParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextOKFullParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -192,7 +193,7 @@ public class ContextParameterTests {
@Test
public void testBadClassDistParamTest() {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadClassDistParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextBadClassDistParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -207,7 +208,7 @@ public class ContextParameterTests {
@Test
public void testBadClassLockParamTest() {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadClassLockParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextBadClassLockParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -222,7 +223,7 @@ public class ContextParameterTests {
@Test
public void testBadClassPersistParamTest() {
- final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadClassPersistParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/serviceContextBadClassPersistParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
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 5d1b3f726..92a7b7d54 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +24,6 @@ package org.onap.policy.apex.service.engine.parameters;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Test;
@@ -45,7 +45,7 @@ public class ExecutorParameterTests {
@Test
public void testNoParamsTest() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/serviceExecutorNoParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/serviceExecutorNoParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -56,7 +56,7 @@ public class ExecutorParameterTests {
@Test
public void testBadParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/serviceExecutorBadParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/serviceExecutorBadParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -68,7 +68,7 @@ public class ExecutorParameterTests {
@Test
public void testNoExecutorParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/serviceExecutorNoExecutorParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/serviceExecutorNoExecutorParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -80,7 +80,7 @@ public class ExecutorParameterTests {
@Test
public void testEmptyParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/serviceExecutorEmptyParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/serviceExecutorEmptyParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -92,7 +92,7 @@ public class ExecutorParameterTests {
@Test
public void testBadPluginParamNameTest() {
- final String[] args = {"-c", "src/test/resources/parameters/serviceExecutorBadPluginNameParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/serviceExecutorBadPluginNameParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -104,7 +104,7 @@ public class ExecutorParameterTests {
@Test
public void testBadPluginParamObjectTest() {
- final String[] args = {"-c", "src/test/resources/parameters/serviceExecutorBadPluginValueObjectParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/serviceExecutorBadPluginValueObjectParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -116,7 +116,7 @@ public class ExecutorParameterTests {
@Test
public void testBadPluginParamBlankTest() {
- final String[] args = {"-c", "src/test/resources/parameters/serviceExecutorBadPluginValueBlankParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/serviceExecutorBadPluginValueBlankParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -128,7 +128,7 @@ public class ExecutorParameterTests {
@Test
public void testBadPluginParamValueTest() {
- final String[] args = {"-c", "src/test/resources/parameters/serviceExecutorBadPluginValueParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/serviceExecutorBadPluginValueParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -141,7 +141,7 @@ public class ExecutorParameterTests {
@Test
public void testGoodParametersTest() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/goodParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -160,7 +160,7 @@ public class ExecutorParameterTests {
final String[] args = {
"-rfr",
"src/test/resources",
- "-c",
+ "-p",
"src/test/resources/parameters/goodParamsRelative.json"
};
// @formatter:on
@@ -173,7 +173,5 @@ public class ExecutorParameterTests {
assertEquals(45, parameters.getEngineServiceParameters().getId());
assertEquals(19, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
- assertTrue(parameters.getEngineServiceParameters().getPolicyModelFileName()
- .endsWith("policymodels/SmallModel.json"));
}
}
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 4948ab5f3..da4ceaa12 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.nio.file.NoSuchFileException;
import java.util.Arrays;
import org.junit.Test;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.ApexFileEventConsumer;
@@ -48,27 +50,25 @@ import org.onap.policy.common.parameters.ParameterException;
public class ParameterTests {
@Test
public void testInvalidParametersNoFileTest() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/invalidNoFile.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/invalidNoFile.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessageStartingWith("error reading parameters from \"src")
- .hasMessageContaining("FileNotFoundException");
+ .hasRootCauseInstanceOf(NoSuchFileException.class);
}
@Test
public void testInvalidParametersEmptyTest() {
- final String[] args = {"-c", "src/test/resources/parameters/empty.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/empty.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessageStartingWith("validation error(s) on parameters from \"src/test/resources/parameters/empty"
- + ".json\"");
+ .hasMessageStartingWith("error reading parameters from \"src/test/resources/parameters/empty.json");
}
@Test
public void testInvalidParametersNoParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/noParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/noParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -85,7 +85,7 @@ public class ParameterTests {
@Test
public void testInvalidParametersBlankParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/blankParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/blankParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -97,6 +97,7 @@ public class ParameterTests {
+ "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"
+ + " field \"policyModel\" type \"java.lang.String\" value \"null\" INVALID, must be specified\n"
+ " parameter group map \"eventOutputParameters\" INVALID, "
+ "at least one event output must be specified\n"
+ " parameter group map \"eventInputParameters\" INVALID, "
@@ -105,7 +106,7 @@ public class ParameterTests {
@Test
public void testInvalidParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/badParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/badParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -123,8 +124,6 @@ public class ParameterTests {
+ "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"
@@ -146,24 +145,8 @@ public class ParameterTests {
}
@Test
- public void testModelNotFileTest() {
- final String[] args = {"-c", "src/test/resources/parameters/badParamsModelNotFile.json"};
- final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
-
- assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/badParamsModelNotFile.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group \"MyApexEngine\" type "
- + "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" "
- + "INVALID, parameter group has status INVALID\n" + " field \"policyModelFileName\" "
- + "type \"java.lang.String\" value \"src/test\" INVALID, is not a plain file\n");
- }
-
- @Test
public void testGoodParametersTest() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/goodParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -207,7 +190,7 @@ public class ParameterTests {
@Test
public void testSuperDooperParametersTest() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/superDooperParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/superDooperParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
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 8c7c9df82..0ef4fa252 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +41,7 @@ import org.onap.policy.common.parameters.ParameterException;
public class ProducerConsumerTests {
@Test
public void testGoodParametersTest() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/goodParams.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/goodParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -70,7 +71,7 @@ public class ProducerConsumerTests {
@Test
public void testNoCarrierTechnology() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsNoCT.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsNoCT.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -86,7 +87,7 @@ public class ProducerConsumerTests {
@Test
public void testNoEventProcol() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsNoEP.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsNoEP.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -111,7 +112,7 @@ public class ProducerConsumerTests {
@Test
public void testNoCarrierTechnologyParClass() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsNoCTParClass.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsNoCTParClass.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -122,7 +123,7 @@ public class ProducerConsumerTests {
@Test
public void testMismatchCarrierTechnologyParClass() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsMismatchCTParClass.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsMismatchCTParClass.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage(
@@ -135,7 +136,7 @@ public class ProducerConsumerTests {
@Test
public void testWrongTypeCarrierTechnologyParClass() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsWrongTypeCTParClass.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsWrongTypeCTParClass.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage(
@@ -151,7 +152,7 @@ public class ProducerConsumerTests {
@Test
public void testOkFileNameCarrierTechnology() throws ParameterException {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsOKFileName.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsOKFileName.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -166,7 +167,7 @@ public class ProducerConsumerTests {
@Test
public void testBadFileNameCarrierTechnology() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsBadFileName.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsBadFileName.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage(
@@ -186,7 +187,7 @@ public class ProducerConsumerTests {
@Test
public void testBadEventProtocolParClass() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsBadEPParClass.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsBadEPParClass.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -199,7 +200,7 @@ public class ProducerConsumerTests {
@Test
public void testNoEventProtocolParClass() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsNoEPParClass.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsNoEPParClass.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -210,7 +211,7 @@ public class ProducerConsumerTests {
@Test
public void testMismatchEventProtocolParClass() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsMismatchEPParClass.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsMismatchEPParClass.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage(
@@ -224,7 +225,7 @@ public class ProducerConsumerTests {
@Test
public void testWrongTypeEventProtocolParClass() {
- final String[] args = { "-c", "src/test/resources/parameters/prodConsWrongTypeEPParClass.json" };
+ final String[] args = {"-p", "src/test/resources/parameters/prodConsWrongTypeEPParClass.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage(
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 91f8c6699..9f420d8fb 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +46,7 @@ import org.onap.policy.common.parameters.ParameterException;
public class SyncParameterTests {
@Test
public void testSyncBadNoSyncWithPeer() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -63,7 +64,7 @@ public class SyncParameterTests {
@Test
public void testSyncBadNotSyncWithPeer() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -81,7 +82,7 @@ public class SyncParameterTests {
@Test
public void testSyncBadSyncBadPeers() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsBadPeers.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncBadParamsBadPeers.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -110,7 +111,7 @@ public class SyncParameterTests {
@Test
public void testSyncBadSyncInvalidTimeout() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsInvalidTimeout.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncBadParamsInvalidTimeout.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -141,7 +142,7 @@ public class SyncParameterTests {
@Test
public void testSyncBadSyncBadTimeout() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsBadTimeout.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncBadParamsBadTimeout.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -159,7 +160,7 @@ public class SyncParameterTests {
@Test
public void testSyncBadSyncUnpairedTimeout() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsUnpairedTimeout.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncBadParamsUnpairedTimeout.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -190,7 +191,7 @@ public class SyncParameterTests {
@Test
public void testSyncGoodSyncGoodTimeoutProducer() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsProducerTimeout.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncGoodParamsProducerTimeout.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -207,7 +208,7 @@ public class SyncParameterTests {
@Test
public void testSyncGoodSyncGoodTimeoutConsumer() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsConsumerTimeout.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncGoodParamsConsumerTimeout.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -224,7 +225,7 @@ public class SyncParameterTests {
@Test
public void testSyncGoodSyncGoodTimeoutBoth() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsBothTimeout.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncGoodParamsBothTimeout.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
@@ -241,7 +242,7 @@ public class SyncParameterTests {
@Test
public void testSyncUnusedConsumerPeers() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncUnusedConsumerPeers.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncUnusedConsumerPeers.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -266,7 +267,7 @@ public class SyncParameterTests {
@Test
public void testSyncMismatchedPeers() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncMismatchedPeers.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncMismatchedPeers.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -297,7 +298,7 @@ public class SyncParameterTests {
@Test
public void testSyncUnusedProducerPeers() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncUnusedProducerPeers.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncUnusedProducerPeers.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -320,7 +321,7 @@ public class SyncParameterTests {
@Test
public void testSyncMismatchedTimeout() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncMismatchedTimeout.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncMismatchedTimeout.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
@@ -345,7 +346,7 @@ public class SyncParameterTests {
@Test
public void testSyncGoodParametersTest() throws ParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParams.json"};
+ final String[] args = {"-p", "src/test/resources/parameters/syncGoodParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
index eb99c97bb..e9a1a858e 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.apex.service.engine.runtime.impl;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -73,7 +75,7 @@ public class EngineServiceImplTest {
simpleModelString = TextFileUtils.getTextFileAsString("src/test/resources/policymodels/SmallModel.json");
differentModelString =
- TextFileUtils.getTextFileAsString("src/test/resources/policymodels/SmallModelDifferent.json");
+ TextFileUtils.getTextFileAsString("src/test/resources/policymodels/SmallModelDifferent.json");
final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class);
simpleModel = modelReader.read(new ByteArrayInputStream(simpleModelString.getBytes()));
@@ -110,18 +112,18 @@ public class EngineServiceImplTest {
ExecutorParameters jsExecutorParameters = new ExecutorParameters();
jsExecutorParameters.setName("JAVASCRIPT");
jsExecutorParameters
- .setTaskSelectionExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummyTse");
+ .setTaskSelectionExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummyTse");
jsExecutorParameters.setTaskExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummyTe");
jsExecutorParameters
- .setStateFinalizerExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummySfe");
+ .setStateFinalizerExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummySfe");
engineParameters.getExecutorParameterMap().put("JAVASCRIPT", jsExecutorParameters);
ExecutorParameters mvvelExecutorParameters = new ExecutorParameters();
mvvelExecutorParameters.setName("MVEL");
mvvelExecutorParameters
- .setTaskSelectionExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummyTse");
+ .setTaskSelectionExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummyTse");
mvvelExecutorParameters.setTaskExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummyTe");
mvvelExecutorParameters
- .setStateFinalizerExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummySfe");
+ .setStateFinalizerExecutorPluginClass("org.onap.policy.apex.service.engine.runtime.impl.DummySfe");
engineParameters.getExecutorParameterMap().put("MVEL", jsExecutorParameters);
ParameterService.register(engineParameters);
}
@@ -142,26 +144,17 @@ public class EngineServiceImplTest {
@Test
public void testEngineServiceImplSanity() throws ApexException {
- try {
- EngineServiceImpl.create(null);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine service configuration parameters are null", apEx.getMessage());
- }
-
+ assertThatThrownBy(() -> EngineServiceImpl.create(null)).isInstanceOf(ApexException.class)
+ .hasMessage("engine service configuration parameters are null");
EngineServiceParameters config = new EngineServiceParameters();
config.setInstanceCount(0);
-
- try {
- EngineServiceImpl.create(config);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("Invalid engine service configuration parameters:", apEx.getMessage().substring(0, 48));
- }
+ assertThatThrownBy(() -> EngineServiceImpl.create(config)).isInstanceOf(ApexException.class)
+ .hasMessageContaining("Invalid engine service configuration parameters");
config.setId(123);
config.setEngineKey(new AxArtifactKey("Engine", "0.0.1"));
config.setInstanceCount(1);
+ config.setPolicyModel("policyModelContent");
EngineServiceImpl esImpl = EngineServiceImpl.create(config);
assertEquals("Engine:0.0.1", esImpl.getKey().getId());
@@ -171,12 +164,8 @@ public class EngineServiceImplTest {
esImpl.registerActionListener(null, new DummyApexEventListener());
esImpl.registerActionListener("DummyListener", new DummyApexEventListener());
- try {
- esImpl.deregisterActionListener(null);
- fail("test should throw an exception");
- } catch (Exception apEx) {
- assertEquals("removeEventListener()<-Engine-0:0.0.1,STOPPED, listenerName is null", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.deregisterActionListener(null))
+ .hasMessage("removeEventListener()<-Engine-0:0.0.1,STOPPED, listenerName is null");
esImpl.deregisterActionListener("DummyListener");
@@ -185,38 +174,21 @@ public class EngineServiceImplTest {
assertNull(esImpl.getApexModelKey());
- try {
- esImpl.getRuntimeInfo(null);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine key must be specified and may not be null", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.getRuntimeInfo(null)).isInstanceOf(ApexException.class)
+ .hasMessage("engine key must be specified and may not be null");
- try {
- esImpl.getRuntimeInfo(new AxArtifactKey("DummyKey", "0.0.1"));
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine with key DummyKey:0.0.1 not found in engine service", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.getRuntimeInfo(new AxArtifactKey("DummyKey", "0.0.1")))
+ .isInstanceOf(ApexException.class).hasMessage("engine with key DummyKey:0.0.1 not found in engine service");
String runtimeInfo = esImpl.getRuntimeInfo(esImpl.getEngineKeys().iterator().next());
assertEquals("{\n \"TimeStamp\":", runtimeInfo.substring(0, 16));
assertEquals(AxEngineState.STOPPED, esImpl.getState());
- try {
- esImpl.getStatus(null);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine key must be specified and may not be null", apEx.getMessage());
- }
-
- try {
- esImpl.getStatus(new AxArtifactKey("DummyKey", "0.0.1"));
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine with key DummyKey:0.0.1 not found in engine service", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.getStatus(null)).isInstanceOf(ApexException.class)
+ .hasMessage("engine key must be specified and may not be null");
+ assertThatThrownBy(() -> esImpl.getStatus(new AxArtifactKey("DummyKey", "0.0.1")))
+ .isInstanceOf(ApexException.class).hasMessage("engine with key DummyKey:0.0.1 not found in engine service");
String status = esImpl.getStatus(esImpl.getEngineKeys().iterator().next());
assertTrue(status.contains("\n \"apexEngineModel\" :"));
@@ -230,182 +202,84 @@ public class EngineServiceImplTest {
assertTrue(esImpl.isStopped(new AxArtifactKey("DummyKey", "0.0.1")));
assertTrue(esImpl.isStopped(esImpl.getEngineKeys().iterator().next()));
- try {
- esImpl.start(null);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine key must be specified and may not be null", apEx.getMessage());
- }
-
- try {
- esImpl.start(new AxArtifactKey("DummyKey", "0.0.1"));
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine with key DummyKey:0.0.1 not found in engine service", apEx.getMessage());
- }
-
- try {
- esImpl.start(esImpl.getEngineKeys().iterator().next());
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("start()<-Engine-0:0.0.1,STOPPED, cannot start engine, "
- + "engine has not been initialized, its model is not loaded", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.start(null)).isInstanceOf(ApexException.class)
+ .hasMessage("engine key must be specified and may not be null");
- try {
- esImpl.startAll();
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("start()<-Engine-0:0.0.1,STOPPED, cannot start engine, "
- + "engine has not been initialized, its model is not loaded", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.start(new AxArtifactKey("DummyKey", "0.0.1"))).isInstanceOf(ApexException.class)
+ .hasMessage("engine with key DummyKey:0.0.1 not found in engine service");
- try {
- esImpl.stop(null);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine key must be specified and may not be null", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.start(esImpl.getEngineKeys().iterator().next()))
+ .isInstanceOf(ApexException.class).hasMessage("start()<-Engine-0:0.0.1,STOPPED, cannot start engine, "
+ + "engine has not been initialized, its model is not loaded");
- try {
- esImpl.stop(new AxArtifactKey("DummyKey", "0.0.1"));
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine with key DummyKey:0.0.1 not found in engine service", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.startAll()).isInstanceOf(ApexException.class)
+ .hasMessage("start()<-Engine-0:0.0.1,STOPPED, cannot start engine, "
+ + "engine has not been initialized, its model is not loaded");
- try {
- esImpl.stop(esImpl.getEngineKeys().iterator().next());
- } catch (ApexException apEx) {
- fail("test should not throw an exception");
- }
+ assertThatThrownBy(() -> esImpl.stop(null)).isInstanceOf(ApexException.class)
+ .hasMessage("engine key must be specified and may not be null");
- try {
- esImpl.stop();
- } catch (ApexException apEx) {
- fail("test should not throw an exception");
- }
+ assertThatThrownBy(() -> esImpl.stop(new AxArtifactKey("DummyKey", "0.0.1"))).isInstanceOf(ApexException.class)
+ .hasMessage("engine with key DummyKey:0.0.1 not found in engine service");
- try {
- esImpl.sendEvent(null);
- } catch (Exception apEx) {
- fail("test should not throw an exception");
- }
+ esImpl.stop(esImpl.getEngineKeys().iterator().next());
- try {
- esImpl.sendEvent(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget"));
- } catch (ApexException apEx) {
- fail("test should not throw an exception");
- }
+ esImpl.stop();
+ esImpl.sendEvent(null);
+ esImpl.sendEvent(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget"));
esImpl.startPeriodicEvents(100000);
- try {
- esImpl.startPeriodicEvents(100000);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("Peiodic event geneation already running on engine Engine:0.0.1, ApexPeriodicEventGenerator "
- + "[period=100000, firstEventTime=0, lastEventTime=0, eventCount=0]", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.startPeriodicEvents(100000)).isInstanceOf(ApexException.class)
+ .hasMessage("Peiodic event geneation already running on engine Engine:0.0.1, ApexPeriodicEventGenerator "
+ + "[period=100000, firstEventTime=0, lastEventTime=0, eventCount=0]");
esImpl.stopPeriodicEvents();
- try {
- esImpl.stopPeriodicEvents();
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("Peiodic event geneation not running on engine Engine:0.0.1", apEx.getMessage());
- }
- try {
- esImpl.clear(null);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine key must be specified and may not be null", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.stopPeriodicEvents()).isInstanceOf(ApexException.class)
+ .hasMessage("Peiodic event geneation not running on engine Engine:0.0.1");
- try {
- esImpl.clear(new AxArtifactKey("DummyKey", "0.0.1"));
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine with key DummyKey:0.0.1 not found in engine service", apEx.getMessage());
- }
-
- try {
- esImpl.clear(esImpl.getEngineKeys().iterator().next());
- } catch (ApexException apEx) {
- fail("test should not throw an exception");
- }
+ assertThatThrownBy(() -> esImpl.clear(null)).isInstanceOf(ApexException.class)
+ .hasMessage("engine key must be specified and may not be null");
- try {
- esImpl.clear();
- } catch (ApexException apEx) {
- fail("test should not throw an exception");
- }
+ assertThatThrownBy(() -> esImpl.clear(new AxArtifactKey("DummyKey", "0.0.1"))).isInstanceOf(ApexException.class)
+ .hasMessage("engine with key DummyKey:0.0.1 not found in engine service");
+ esImpl.clear(esImpl.getEngineKeys().iterator().next());
+ esImpl.clear();
- try {
- esImpl.updateModel(null, (String) null, true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine key must be specified and may not be null", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.updateModel(null, (String) null, true)).isInstanceOf(ApexException.class)
+ .hasMessage("engine key must be specified and may not be null");
- try {
- esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), (String) null, true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("model for updating engine service with key DummyKey:0.0.1 is empty", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), (String) null, true))
+ .isInstanceOf(ApexException.class)
+ .hasMessage("model for updating engine service with key DummyKey:0.0.1 is empty");
- try {
- esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), "", true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("model for updating engine service with key DummyKey:0.0.1 is empty", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), "", true))
+ .isInstanceOf(ApexException.class)
+ .hasMessage("model for updating engine service with key DummyKey:0.0.1 is empty");
- try {
- esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), "I am not an Apex model", true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("failed to unmarshal the apex model on engine service DummyKey:0.0.1", apEx.getMessage());
- }
+ assertThatThrownBy(
+ () -> esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), "I am not an Apex model", true))
+ .isInstanceOf(ApexException.class)
+ .hasMessage("failed to unmarshal the apex model on engine service DummyKey:0.0.1");
- try {
- esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), simpleModelString, true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine service key DummyKey:0.0.1 does not match the keyEngine:0.0.1 of this engine service",
- apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), simpleModelString, true))
+ .isInstanceOf(ApexException.class)
+ .hasMessage("engine service key DummyKey:0.0.1 does not match the keyEngine:0.0.1 of this engine service");
- try {
- esImpl.updateModel(null, simpleModelString, true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine key must be specified and may not be null", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.updateModel(null, simpleModelString, true)).isInstanceOf(ApexException.class)
+ .hasMessage("engine key must be specified and may not be null");
- try {
- esImpl.updateModel(null, (AxPolicyModel) null, true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine key must be specified and may not be null", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.updateModel(null, (AxPolicyModel) null, true)).isInstanceOf(ApexException.class)
+ .hasMessage("engine key must be specified and may not be null");
- try {
- esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), (AxPolicyModel) null, true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("model for updating on engine service with key DummyKey:0.0.1 is null", apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), (AxPolicyModel) null, true))
+ .isInstanceOf(ApexException.class)
+ .hasMessage("model for updating on engine service with key DummyKey:0.0.1 is null");
- try {
- esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), simpleModel, true);
- fail("test should throw an exception");
- } catch (ApexException apEx) {
- assertEquals("engine service key DummyKey:0.0.1 does not match the keyEngine:0.0.1 of this engine service",
- apEx.getMessage());
- }
+ assertThatThrownBy(() -> esImpl.updateModel(new AxArtifactKey("DummyKey", "0.0.1"), simpleModel, true))
+ .isInstanceOf(ApexException.class)
+ .hasMessage("engine service key DummyKey:0.0.1 does not match the keyEngine:0.0.1 of this engine service");
}
@Test
@@ -414,7 +288,7 @@ public class EngineServiceImplTest {
config.setId(123);
config.setEngineKey(new AxArtifactKey("Engine", "0.0.1"));
config.setInstanceCount(1);
-
+ config.setPolicyModel("policyModelContent");
EngineServiceImpl esImpl = EngineServiceImpl.create(config);
assertEquals("Engine:0.0.1", esImpl.getKey().getId());