aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-executor')
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java21
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java27
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java25
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java31
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java26
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java16
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java14
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java49
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java54
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java31
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java16
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java34
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java34
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java34
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java16
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java35
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java25
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java25
18 files changed, 261 insertions, 252 deletions
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java
index 1e1dbf7ed..f9c56ab82 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java
@@ -1,36 +1,41 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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=========================================================
*/
package org.onap.policy.apex.plugins.executor.java;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the JavaExecutorParameters class.
*/
-public class JavaExecutorParametersTest {
+class JavaExecutorParametersTest {
@Test
- public void testJavaExecutorParameters() {
- assertNotNull(new JavaExecutorParameters());
+ void testJavaExecutorParameters() {
+ var executorType = "Java";
+ var javaExecutor = new JavaExecutorParameters();
+ assertTrue(javaExecutor.getTaskExecutorPluginClass().contains(executorType));
+ assertTrue(javaExecutor.getTaskSelectionExecutorPluginClass().contains(executorType));
+ assertTrue(javaExecutor.getStateFinalizerExecutorPluginClass().contains(executorType));
}
}
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java
index a1c296436..884530436 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +22,13 @@
package org.onap.policy.apex.plugins.executor.java;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -50,14 +50,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JavaStateFinalizerExecutor class.
- *
*/
-public class JavaStateFinalizerExecutorTest {
+class JavaStateFinalizerExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -67,8 +66,8 @@ public class JavaStateFinalizerExecutorTest {
/**
* Clear down Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -76,7 +75,7 @@ public class JavaStateFinalizerExecutorTest {
}
@Test
- public void testJavaStateFinalizerExecutor() throws StateMachineException, ContextException {
+ void testJavaStateFinalizerExecutor() throws StateMachineException, ContextException {
JavaStateFinalizerExecutor jsfe = new JavaStateFinalizerExecutor();
assertNotNull(jsfe);
@@ -111,7 +110,7 @@ public class JavaStateFinalizerExecutorTest {
assertThatThrownBy(() -> {
jsfe.execute(-1, new Properties(), event);
}).hasMessage("execute-post: state finalizer logic execution failure on state "
- + "\"NULL:0.0.0:NULL:NULL\" on finalizer logic NULL:0.0.0:NULL:NULL");
+ + "\"NULL:0.0.0:NULL:NULL\" on finalizer logic NULL:0.0.0:NULL:NULL");
state.getStateOutputs().put("SelectedOutputIsMe", null);
jsfe.prepare();
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
index 96bc6bb3d..3fbaf8b16 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,16 +23,16 @@
package org.onap.policy.apex.plugins.executor.java;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -47,14 +47,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JavaTaskExecutor class.
- *
*/
-public class JavaTaskExecutorTest {
+class JavaTaskExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -63,15 +62,15 @@ public class JavaTaskExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJavaTaskExecutor() throws ContextException, StateMachineException {
+ void testJavaTaskExecutor() throws ContextException, StateMachineException {
JavaTaskExecutor jte = new JavaTaskExecutor();
assertNotNull(jte);
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java
index 61acecd9b..feb4cc6fd 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +22,13 @@
package org.onap.policy.apex.plugins.executor.java;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -47,12 +47,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the JavaTaskSelectExecutor class.
*
*/
-public class JavaTaskSelectExecutorTest {
+class JavaTaskSelectExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -61,22 +61,22 @@ public class JavaTaskSelectExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJavaTaskSelectExecutor() throws StateMachineException, ContextException {
+ void testJavaTaskSelectExecutor() throws StateMachineException, ContextException {
JavaTaskSelectExecutor jtse = new JavaTaskSelectExecutor();
assertNotNull(jtse);
assertThatThrownBy(jtse::prepare)
.isInstanceOf(java.lang.NullPointerException.class);
AxState state = new AxState();
- ApexInternalContext internalContext = null;
+ ApexInternalContext internalContext;
internalContext = new ApexInternalContext(new AxPolicyModel());
jtse.setContext(null, state, internalContext);
@@ -96,9 +96,8 @@ public class JavaTaskSelectExecutorTest {
.setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaTaskSelectionLogic");
jtse.prepare();
- assertThatThrownBy(() -> {
- jtse.execute(-1, new Properties(), event);
- }).hasMessage("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"");
+ assertThatThrownBy(() -> jtse.execute(-1, new Properties(), event))
+ .hasMessage("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"");
jtse.prepare();
AxArtifactKey taskKey = jtse.execute(0, new Properties(), event);
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java
index 394126bc4..61422d1d5 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,21 +21,21 @@
package org.onap.policy.apex.plugins.executor.javascript;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.utils.resources.TextFileUtils;
-public class JavascriptExecutorFullApexTest {
+class JavascriptExecutorFullApexTest {
@Test
- public void testFullApexPolicy() throws ApexException {
+ void testFullApexPolicy() throws ApexException {
final String[] args = {"src/test/resources/prodcons/File2File.json"};
final File outFile0 = new File("src/test/resources/events/EventsOut0.json");
@@ -46,19 +46,17 @@ public class JavascriptExecutorFullApexTest {
final ApexMain apexMain = new ApexMain(args);
assertNotNull(apexMain);
- await().atMost(10, TimeUnit.SECONDS).until(() -> outFile0.exists());
- await().atMost(10, TimeUnit.SECONDS).until(() -> outFile1.exists());
+ await().atMost(10, TimeUnit.SECONDS).until(outFile0::exists);
+ await().atMost(10, TimeUnit.SECONDS).until(outFile1::exists);
- await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurencesOf(outFile0, "BasicEventOut0", 50));
- await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurencesOf(outFile1, "BasicEventOut1", 50));
+ await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurrencesOf(outFile0, "BasicEventOut0"));
+ await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurrencesOf(outFile1, "BasicEventOut1"));
apexMain.shutdown();
}
- private boolean fileHasOccurencesOf(final File file, final String token, final int occurenceCount)
- throws IOException {
-
- return occurenceCount == StringUtils.countMatches(TextFileUtils.getTextFileAsString(file.getAbsolutePath()),
- token);
+ private boolean fileHasOccurrencesOf(final File file, final String token)
+ throws IOException {
+ return 50 == StringUtils.countMatches(TextFileUtils.getTextFileAsString(file.getAbsolutePath()), token);
}
}
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java
index 5b23584d0..adc7dbb00 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,17 +20,21 @@
package org.onap.policy.apex.plugins.executor.javascript;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the JavaExecutorParameters class.
*/
-public class JavascriptExecutorParametersTest {
+class JavascriptExecutorParametersTest {
@Test
- public void testJavascriptExecutorParameters() {
- assertNotNull(new JavascriptExecutorParameters());
+ void testJavascriptExecutorParameters() {
+ var executorType = "Javascript";
+ var javascriptExecutor = new JavascriptExecutorParameters();
+ assertTrue(javascriptExecutor.getStateFinalizerExecutorPluginClass().contains(executorType));
+ assertTrue(javascriptExecutor.getTaskExecutorPluginClass().contains(executorType));
+ assertTrue(javascriptExecutor.getTaskSelectionExecutorPluginClass().contains(executorType));
}
}
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java
index 20ba1291f..083ec521a 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2020, 2024 Nordix Foundation. 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,21 +23,21 @@ package org.onap.policy.apex.plugins.executor.javascript;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-public class JavascriptExecutorTest {
+class JavascriptExecutorTest {
@Test
- public void testReturnOK() throws StateMachineException {
+ void testReturnOK() throws StateMachineException {
JavascriptExecutor executor = new JavascriptExecutor(
new AxArtifactKey("TestTask:0.0.1"), "true;");
assertThatCode(() -> executor.execute(new Object())).doesNotThrowAnyException();
}
@Test
- public void testReturnNonBoolean() throws StateMachineException {
+ void testReturnNonBoolean() throws StateMachineException {
JavascriptExecutor executor = new JavascriptExecutor(
new AxArtifactKey("TestTask:0.0.1"), "var a = 1; a;");
assertThatThrownBy(() -> executor.execute(new Object()))
@@ -45,14 +45,14 @@ public class JavascriptExecutorTest {
}
@Test
- public void testBlankLogic() {
+ void testBlankLogic() {
assertThatThrownBy(() -> new JavascriptExecutor(
new AxArtifactKey("TestTask:0.0.1"), " "))
.hasMessageContaining("no logic specified for TestTask:0.0.1");
}
@Test
- public void testCompileFailed() {
+ void testCompileFailed() {
assertThatThrownBy(() -> new JavascriptExecutor(
new AxArtifactKey("TestTask:0.0.1"), "return boolean;"))
.hasMessageContaining("logic failed to compile for TestTask:0.0.1");
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java
index 2a10e70ca..ff7301541 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +21,12 @@
package org.onap.policy.apex.plugins.executor.javascript;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
@@ -46,14 +46,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JavascriptStateFinalizerExecutor class.
- *
*/
-public class JavascriptStateFinalizerExecutorTest {
+class JavascriptStateFinalizerExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -63,8 +62,8 @@ public class JavascriptStateFinalizerExecutorTest {
/**
* Clear down Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -72,12 +71,10 @@ public class JavascriptStateFinalizerExecutorTest {
}
@Test
- public void testJavaStateFinalizerExecutor() throws Exception {
+ void testJavaStateFinalizerExecutor() throws Exception {
JavascriptStateFinalizerExecutor jsfe = new JavascriptStateFinalizerExecutor();
- assertThatThrownBy(() -> {
- jsfe.prepare();
- }).isInstanceOf(java.lang.NullPointerException.class);
+ assertThatThrownBy(jsfe::prepare).isInstanceOf(java.lang.NullPointerException.class);
ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel());
StateExecutor parentStateExcutor = new StateExecutor(new ExecutorFactoryImpl());
@@ -88,9 +85,7 @@ public class JavascriptStateFinalizerExecutorTest {
jsfe.setContext(parentStateExcutor, stateFinalizerLogic, internalContext);
stateFinalizerLogic.setLogic("return false");
- assertThatThrownBy(() -> {
- jsfe.prepare();
- }).hasMessage("logic failed to compile for NULL:0.0.0:NULL:NULL "
+ assertThatThrownBy(jsfe::prepare).hasMessage("logic failed to compile for NULL:0.0.0:NULL:NULL "
+ "with message: invalid return (NULL:0.0.0:NULL:NULL#1)");
stateFinalizerLogic.setLogic("java.lang.String");
@@ -98,11 +93,19 @@ public class JavascriptStateFinalizerExecutorTest {
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
- stateFinalizerLogic.setLogic("if(executor.executionId==-1)" + "{\r\n"
- + "var returnValueType = java.lang.Boolean;" + "var returnValue = new returnValueType(false); }\n"
- + "else{\n" + "executor.setSelectedStateOutputName(\"SelectedOutputIsMe\");\n"
- + "var returnValueType = java.lang.Boolean;\n" + "\n"
- + "var returnValue = new returnValueType(true);} true;");
+ var logic = """
+ if(executor.executionId==-1)
+ {
+ var returnValueType = java.lang.Boolean;
+ var returnValue = new returnValueType(false);
+ }
+ else
+ {
+ executor.setSelectedStateOutputName("SelectedOutputIsMe");
+ var returnValueType = java.lang.Boolean;
+ var returnValue = new returnValueType(true);
+ } true;""";
+ stateFinalizerLogic.setLogic(logic);
assertThatThrownBy(() -> {
jsfe.prepare();
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
index 215491d4e..0dd630a2c 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
@@ -23,17 +23,17 @@
package org.onap.policy.apex.plugins.executor.javascript;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
@@ -58,17 +58,16 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
/**
* Test the JavaTaskExecutor class.
- *
*/
-public class JavascriptTaskExecutorTest {
+class JavascriptTaskExecutorTest {
/**
- * Set ups everything for the test.
+ * Set-ups everything for the test.
*/
- @BeforeClass
- public static void prepareForTest() {
+ @BeforeAll
+ static void prepareForTest() {
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager");
+ .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager");
contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
@@ -90,8 +89,8 @@ public class JavascriptTaskExecutorTest {
/**
* Clear down the test data.
*/
- @AfterClass
- public static void cleanUpAfterTest() {
+ @AfterAll
+ static void cleanUpAfterTest() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -101,12 +100,10 @@ public class JavascriptTaskExecutorTest {
}
@Test
- public void testJavascriptTaskExecutor() throws Exception {
+ void testJavascriptTaskExecutor() throws Exception {
JavascriptTaskExecutor jte = new JavascriptTaskExecutor();
- assertThatThrownBy(() -> {
- jte.prepare();
- }).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(jte::prepare).isInstanceOf(NullPointerException.class);
AxTask task = new AxTask(new AxArtifactKey("TestTask:0.0.1"));
final ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel());
@@ -115,17 +112,14 @@ public class JavascriptTaskExecutorTest {
task.getTaskLogic().setLogic("return boolean;");
- assertThatThrownBy(() -> {
- jte.prepare();
- }).hasMessage("logic failed to compile for TestTask:0.0.1 with message: invalid return (TestTask:0.0.1#1)");
+ assertThatThrownBy(jte::prepare)
+ .hasMessage("logic failed to compile for TestTask:0.0.1 with message: invalid return (TestTask:0.0.1#1)");
task.getTaskLogic().setLogic("var x = 5;");
jte.prepare();
Properties props = new Properties();
- assertThatThrownBy(() -> {
- jte.execute(-1, props, null);
- }).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> jte.execute(-1, props, null)).isInstanceOf(NullPointerException.class);
jte.cleanUp();
task.setInputEvent(new AxEvent());
task.setOutputEvents(new TreeMap<>());
@@ -149,14 +143,12 @@ public class JavascriptTaskExecutorTest {
}
@Test
- public void testJavascriptTaskExecutorLogic() throws Exception {
+ void testJavascriptTaskExecutorLogic() throws Exception {
JavascriptTaskExecutor jte = new JavascriptTaskExecutor();
assertNotNull(jte);
- assertThatThrownBy(() -> {
- jte.prepare();
- }).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(jte::prepare).isInstanceOf(NullPointerException.class);
AxTask task = new AxTask(new AxArtifactKey("TestTask:0.0.1"));
@@ -199,16 +191,16 @@ public class JavascriptTaskExecutorTest {
private ContextAlbum createTestContextAlbum() throws ContextException {
AxContextSchemas schemas = new AxContextSchemas();
AxContextSchema simpleStringSchema =
- new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), "JAVA", "java.lang.String");
+ new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), "JAVA", "java.lang.String");
schemas.getSchemasMap().put(simpleStringSchema.getKey(), simpleStringSchema);
ModelService.registerModel(AxContextSchemas.class, schemas);
AxContextAlbum axContextAlbum = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
- true, AxArtifactKey.getNullKey());
+ true, AxArtifactKey.getNullKey());
axContextAlbum.setItemSchema(simpleStringSchema.getKey());
Distributor distributor = new JvmLocalDistributor();
distributor.init(axContextAlbum.getKey());
- return new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<String, Object>());
+ return new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<>());
}
}
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java
index d2bb852b6..7e7f61622 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java
@@ -22,13 +22,13 @@
package org.onap.policy.apex.plugins.executor.javascript;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
@@ -43,14 +43,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JavaTaskSelectExecutor class.
- *
*/
-public class JavascriptTaskSelectExecutorTest {
+class JavascriptTaskSelectExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -59,15 +58,15 @@ public class JavascriptTaskSelectExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJavascriptTaskSelectExecutor() throws Exception {
+ void testJavascriptTaskSelectExecutor() throws Exception {
JavascriptTaskSelectExecutor jtse = new JavascriptTaskSelectExecutor();
assertThatThrownBy(() -> {
@@ -79,9 +78,7 @@ public class JavascriptTaskSelectExecutorTest {
ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel());
jtse.setContext(null, state, internalContext);
- assertThatThrownBy(() -> {
- jtse.prepare();
- }).hasMessage("no logic specified for NULL:0.0.0:NULL:NULL");
+ assertThatThrownBy(jtse::prepare).hasMessage("no logic specified for NULL:0.0.0:NULL:NULL");
state.getTaskSelectionLogic().setLogic("java.lang.String");
jtse.prepare();
@@ -92,9 +89,7 @@ public class JavascriptTaskSelectExecutorTest {
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
- assertThatThrownBy(() -> {
- jtse.execute(-1, new Properties(), event);
- }).hasMessage(
+ assertThatThrownBy(() -> jtse.execute(-1, new Properties(), event)).hasMessage(
"execute: logic for NULL:0.0.0:NULL:NULL returned a non-boolean value [JavaClass java.lang.String]");
state.getTaskSelectionLogic().setLogic("var x=1;\n" + "false; ");
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java
index 4cfd7a19c..c6e0b3a67 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,16 +20,20 @@
package org.onap.policy.apex.plugins.executor.jruby;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the JrubyExecutorParameters class.
*/
-public class JrubyExecutorParametersTest {
+class JrubyExecutorParametersTest {
@Test
- public void testJrubyExecutorParameters() {
- assertNotNull(new JrubyExecutorParameters());
+ void testJrubyExecutorParameters() {
+ var executorType = "Jruby";
+ var jrubyExecutor = new JrubyExecutorParameters();
+ assertTrue(jrubyExecutor.getTaskExecutorPluginClass().contains(executorType));
+ assertTrue(jrubyExecutor.getTaskSelectionExecutorPluginClass().contains(executorType));
+ assertTrue(jrubyExecutor.getStateFinalizerExecutorPluginClass().contains(executorType));
}
}
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java
index eca9a45cd..a750a0bfe 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,14 +21,14 @@
package org.onap.policy.apex.plugins.executor.jruby;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.lang.reflect.Field;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -53,12 +52,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the JrubyStateFinalizerExecutor class.
*
*/
-public class JrubyStateFinalizerExecutorTest {
+class JrubyStateFinalizerExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -68,8 +67,8 @@ public class JrubyStateFinalizerExecutorTest {
/**
* Clear down Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -77,7 +76,7 @@ public class JrubyStateFinalizerExecutorTest {
}
@Test
- public void testJrubyStateFinalizerExecutor() throws StateMachineException, ContextException,
+ void testJrubyStateFinalizerExecutor() throws StateMachineException, ContextException,
NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
JrubyStateFinalizerExecutor jsfe = new JrubyStateFinalizerExecutor();
assertNotNull(jsfe);
@@ -105,8 +104,13 @@ public class JrubyStateFinalizerExecutorTest {
+ "NULL:0.0.0:NULL:NULL\" on finalizer logic NULL:0.0.0:NULL:NULL");
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
- final String jrubyLogic = "if executor.executionId == -1" + "\n return false" + "\n else "
- + "\n executor.setSelectedStateOutputName(\"SelectedOutputIsMe\")" + "\n return true" + "\n end";
+ final String jrubyLogic = """
+ if executor.executionId == -1
+ return false
+ else
+ executor.setSelectedStateOutputName("SelectedOutputIsMe")
+ return true
+ end""";
stateFinalizerLogic.setLogic(jrubyLogic);
EnEvent event = new EnEvent(axEvent);
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
index 0cc476425..2092c8fb2 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,17 +22,17 @@
package org.onap.policy.apex.plugins.executor.jruby;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -49,12 +49,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the JrubyTaskExecutor class.
*
*/
-public class JrubyTaskExecutorTest {
+class JrubyTaskExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -63,15 +63,15 @@ public class JrubyTaskExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJrubyTaskExecutor() throws StateMachineException, ContextException,
+ void testJrubyTaskExecutor() throws StateMachineException, ContextException,
IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
// Run test twice to check for incorrect shutdown activity
jrubyExecutorTest();
@@ -91,7 +91,7 @@ public class JrubyTaskExecutorTest {
fieldContainer.set(jte, null);
assertThatThrownBy(jte::prepare).isInstanceOf(java.lang.NullPointerException.class);
AxTask task = new AxTask();
- ApexInternalContext internalContext = null;
+ ApexInternalContext internalContext;
internalContext = new ApexInternalContext(new AxPolicyModel());
task.setInputEvent(new AxEvent());
task.setOutputEvents(new TreeMap<>());
@@ -102,8 +102,12 @@ public class JrubyTaskExecutorTest {
Map<String, Object> incomingParameters = new HashMap<>();
assertThatThrownBy(() -> jte.execute(-1, new Properties(), incomingParameters))
.hasMessage("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0");
- final String jrubyLogic = "if executor.executionId == -1" + "\n return false" + "\n else " + "\n return true"
- + "\n end";
+ final String jrubyLogic = """
+ if executor.executionId == -1
+ return false
+ else
+ return true
+ end""";
task.getTaskLogic().setLogic(jrubyLogic);
jte.prepare();
Map<String, Map<String, Object>> returnMap = jte.execute(0, new Properties(), incomingParameters);
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java
index 59d1be4b4..c7b96fde1 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,14 +21,14 @@
package org.onap.policy.apex.plugins.executor.jruby;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.lang.reflect.Field;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -46,14 +45,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JrubyTaskSelectExecutor class.
- *
*/
-public class JrubyTaskSelectExecutorTest {
+class JrubyTaskSelectExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -62,15 +60,15 @@ public class JrubyTaskSelectExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJrubyTaskSelectExecutor() throws StateMachineException, ContextException,
+ void testJrubyTaskSelectExecutor() throws StateMachineException, ContextException,
NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
JrubyTaskSelectExecutor jtse = new JrubyTaskSelectExecutor();
assertNotNull(jtse);
@@ -93,8 +91,12 @@ public class JrubyTaskSelectExecutorTest {
EnEvent event = new EnEvent(axEvent);
assertThatThrownBy(() -> jtse.execute(-1, new Properties(), event))
.hasMessage("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"");
- final String jrubyLogic =
- "if executor.executionId == -1" + "\n return false" + "\n else " + "\n return true" + "\n end";
+ final String jrubyLogic = """
+ if executor.executionId == -1
+ return false
+ else
+ return true
+ end""";
state.getTaskSelectionLogic().setLogic(jrubyLogic);
jtse.prepare();
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java
index 81dc037ae..2d3f51fb1 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,17 +20,21 @@
package org.onap.policy.apex.plugins.executor.mvel;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the MvelExecutorParameters class.
*/
-public class MvelExecutorParametersTest {
+class MvelExecutorParametersTest {
@Test
- public void testJavaExecutorParameters() {
- assertNotNull(new MvelExecutorParameters());
+ void testMvelExecutorParameters() {
+ var executorType = "Mvel";
+ var mvelExecutor = new MvelExecutorParameters();
+ assertTrue(mvelExecutor.getStateFinalizerExecutorPluginClass().contains(executorType));
+ assertTrue(mvelExecutor.getTaskExecutorPluginClass().contains(executorType));
+ assertTrue(mvelExecutor.getTaskSelectionExecutorPluginClass().contains(executorType));
}
}
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java
index 4dd400bbc..fbd789d96 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +21,13 @@
package org.onap.policy.apex.plugins.executor.mvel;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -52,12 +51,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the MvelStateFinalizerExecutor class.
*
*/
-public class MvelStateFinalizerExecutorTest {
+class MvelStateFinalizerExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -67,8 +66,8 @@ public class MvelStateFinalizerExecutorTest {
/**
* Clear down Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -76,22 +75,22 @@ public class MvelStateFinalizerExecutorTest {
}
@Test
- public void testJavaStateFinalizerExecutor() throws StateMachineException, ContextException {
+ void testJavaStateFinalizerExecutor() throws StateMachineException, ContextException {
MvelStateFinalizerExecutor msfe = new MvelStateFinalizerExecutor();
assertNotNull(msfe);
assertThatThrownBy(msfe::prepare).isInstanceOf(java.lang.NullPointerException.class);
- ApexInternalContext internalContext = null;
+ ApexInternalContext internalContext;
internalContext = new ApexInternalContext(new AxPolicyModel());
- StateExecutor parentStateExcutor = null;
+ StateExecutor parentStateExecutor;
- parentStateExcutor = new StateExecutor(new ExecutorFactoryImpl());
+ parentStateExecutor = new StateExecutor(new ExecutorFactoryImpl());
AxState state = new AxState();
- parentStateExcutor.setContext(null, state, internalContext);
+ parentStateExecutor.setContext(null, state, internalContext);
AxStateFinalizerLogic stateFinalizerLogic = new AxStateFinalizerLogic();
- msfe.setContext(parentStateExcutor, stateFinalizerLogic, internalContext);
+ msfe.setContext(parentStateExecutor, stateFinalizerLogic, internalContext);
stateFinalizerLogic.setLogic("x > 1 2 ()");
assertThatThrownBy(msfe::prepare).hasMessage("failed to compile MVEL code for state NULL:0.0.0:NULL:NULL");
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
index 3d59c4b21..f6dd7d824 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,16 +22,16 @@
package org.onap.policy.apex.plugins.executor.mvel;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -49,12 +48,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the MvelTaskExecutor class.
*
*/
-public class MvelTaskExecutorTest {
+class MvelTaskExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -63,15 +62,15 @@ public class MvelTaskExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testMvelTaskExecutor() throws StateMachineException, ContextException {
+ void testMvelTaskExecutor() throws StateMachineException, ContextException {
MvelTaskExecutor mte = new MvelTaskExecutor();
assertNotNull(mte);
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java
index d81c3d13b..4a25730cc 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +21,13 @@
package org.onap.policy.apex.plugins.executor.mvel;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -47,12 +46,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the MvelTaskSelectExecutor class.
*
*/
-public class MvelTaskSelectExecutorTest {
+class MvelTaskSelectExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -61,15 +60,15 @@ public class MvelTaskSelectExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJavaTaskSelectExecutor() throws StateMachineException, ContextException {
+ void testJavaTaskSelectExecutor() throws StateMachineException, ContextException {
MvelTaskSelectExecutor mtse = new MvelTaskSelectExecutor();
assertNotNull(mtse);