summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-jruby
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-jruby
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-jruby')
-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
4 files changed, 66 insertions, 52 deletions
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();