summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-javascript
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-javascript')
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java13
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java13
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java13
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java6
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java10
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java10
6 files changed, 37 insertions, 28 deletions
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java
index c906a9ca3..cd660c807 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java
@@ -22,6 +22,8 @@
package org.onap.policy.apex.plugins.executor.javascript;
import java.util.Map;
+import java.util.Properties;
+
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngine;
@@ -34,8 +36,8 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JavascriptStateFinalizerExecutor is the state finalizer executor for state finalizer
- * logic written in Javascript It is unlikely that this is thread safe.
+ * The Class JavascriptStateFinalizerExecutor is the state finalizer executor for state finalizer logic written in
+ * Javascript It is unlikely that this is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -70,16 +72,17 @@ public class JavascriptStateFinalizerExecutor extends StateFinalizerExecutor {
* Executes the executor for the state finalizer logic in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields for finalisation
* @return The state output for the state
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public String execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
index 4b6ff0232..9769f42db 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
@@ -22,6 +22,8 @@
package org.onap.policy.apex.plugins.executor.javascript;
import java.util.Map;
+import java.util.Properties;
+
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngine;
@@ -34,8 +36,8 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JavascriptTaskExecutor is the task executor for task logic written in Javascript It is
- * unlikely that this is thread safe.
+ * The Class JavascriptTaskExecutor is the task executor for task logic written in Javascript It is unlikely that this
+ * is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -69,16 +71,17 @@ public class JavascriptTaskExecutor extends TaskExecutor {
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields
* @return The outgoing fields
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java
index 305f3a2da..afc7d0183 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.executor.javascript;
+import java.util.Properties;
+
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngine;
@@ -35,8 +37,8 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JavascriptTaskSelectExecutor is the task selection executor for task selection logic
- * written in Javascript It is unlikely that this is thread safe.
+ * The Class JavascriptTaskSelectExecutor is the task selection executor for task selection logic written in Javascript
+ * It is unlikely that this is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -76,16 +78,17 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor {
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingEvent the incoming event
* @return The outgoing event
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEvent) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingEvent);
+ executePre(executionId, executionProperties, incomingEvent);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
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 4dd403e38..d42ad6cb9 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
@@ -117,7 +117,7 @@ public class JavascriptStateFinalizerExecutorTest {
Map<String, Object> incomingParameters1 = new HashMap<>();
try {
- jsfe.execute(-1, incomingParameters1);
+ jsfe.execute(-1, null, incomingParameters1);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
@@ -141,7 +141,7 @@ public class JavascriptStateFinalizerExecutorTest {
+ "var returnValue = new returnValueType(true);}");
try {
jsfe.prepare();
- jsfe.execute(-1, event);
+ jsfe.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
@@ -153,7 +153,7 @@ public class JavascriptStateFinalizerExecutorTest {
state.getStateOutputs().put("SelectedOutputIsMe", null);
try {
jsfe.prepare();
- String stateOutput = jsfe.execute(0, event);
+ String stateOutput = jsfe.execute(0, null, event);
assertEquals("SelectedOutputIsMe", stateOutput);
jsfe.cleanUp();
} catch (Exception jtseException) {
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 50610b2e0..20e758fae 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
@@ -95,7 +95,7 @@ public class JavascriptTaskExecutorTest {
Map<String, Object> incomingParameters2 = new HashMap<>();
try {
- jte.execute(-1, incomingParameters2);
+ jte.execute(-1, null, incomingParameters2);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("task logic failed to run for task \"NULL:0.0.0\"", jteException.getMessage());
@@ -110,7 +110,7 @@ public class JavascriptTaskExecutorTest {
}
try {
- jte.execute(-1, null);
+ jte.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals(java.lang.NullPointerException.class, jteException.getClass());
@@ -118,7 +118,7 @@ public class JavascriptTaskExecutorTest {
Map<String, Object> incomingParameters = new HashMap<>();
try {
- jte.execute(-1, incomingParameters);
+ jte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute: task logic failed to set a return value for task \"NULL:0.0.0\"",
@@ -129,7 +129,7 @@ public class JavascriptTaskExecutorTest {
+ "var returnValue = new returnValueType(false); ");
try {
jte.prepare();
- jte.execute(-1, incomingParameters);
+ jte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
@@ -140,7 +140,7 @@ public class JavascriptTaskExecutorTest {
+ "var returnValue = new returnValueType(true); ");
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
} catch (Exception jteException) {
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 17c0be15f..8efbc6241 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
@@ -98,7 +98,7 @@ public class JavascriptTaskSelectExecutorTest {
AxEvent axEvent1 = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event1 = new EnEvent(axEvent1);
try {
- jtse.execute(-1, event1);
+ jtse.execute(-1, null, event1);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
@@ -115,7 +115,7 @@ public class JavascriptTaskSelectExecutorTest {
}
try {
- jtse.execute(-1, null);
+ jtse.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(java.lang.NullPointerException.class, jtseException.getClass());
@@ -124,7 +124,7 @@ public class JavascriptTaskSelectExecutorTest {
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jtse.execute(-1, event);
+ jtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
@@ -136,7 +136,7 @@ public class JavascriptTaskSelectExecutorTest {
+ "var returnValue = new returnValueType(false); ");
try {
jtse.prepare();
- jtse.execute(-1, event);
+ jtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",
@@ -147,7 +147,7 @@ public class JavascriptTaskSelectExecutorTest {
+ "var returnValue = new returnValueType(true); ");
try {
jtse.prepare();
- AxArtifactKey taskKey = jtse.execute(0, event);
+ AxArtifactKey taskKey = jtse.execute(0, null, event);
assertEquals("NULL:0.0.0", taskKey.getId());
jtse.cleanUp();
} catch (Exception jtseException) {