aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-javascript
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-06-17 15:31:12 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-06-17 16:05:42 +0100
commitfe6bb57982677177f85daa5f893868556b18e63c (patch)
tree54a2f6f5a3e31469c4ea703a777399fb30fc9cfc /plugins/plugins-executor/plugins-executor-javascript
parente9b746340711ddfccee7ac0f669ace626b1b3d46 (diff)
Convert junit4 to junit5
- plugins module Issue-ID: POLICY-5041 Change-Id: Iebff0a2e6898a5dfe9679662dd2be4c5067a4008 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-javascript')
-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
6 files changed, 91 insertions, 99 deletions
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; ");