summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-mvel/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-06-26 15:40:41 +0000
committerliamfallon <liam.fallon@est.tech>2019-06-26 15:40:41 +0000
commitce9d82d2c0e863597d84cc8909955e398405f45a (patch)
tree8ebb853119bdf673cf6f9516d428d4cc00080aeb /plugins/plugins-executor/plugins-executor-mvel/src
parent5f029543f1e673655af2d2974113069df0b6def0 (diff)
Add passthrough properties for APEX engine
APEX event receiver and sender plugins sometimes need to exchange information with tasks, especially in the case of REST communication. This change enables passthrough of Properties from the event carrier technology plugins to APEX task, task selection, and state finalizer logics. Apologies for the size of the review but this change involves passinng the properties through all the APEX components, hence the large number of small changes. Issue-ID: POLICY-1742 Change-Id: I219fd69550f06702ef64adbb165fe7baac422e96 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-mvel/src')
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java8
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java8
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java8
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java8
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java8
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java8
6 files changed, 27 insertions, 21 deletions
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java
index 9b941a39a..ab62ca4bf 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java
@@ -26,6 +26,7 @@ import static org.onap.policy.common.utils.validation.Assertions.argumentNotNull
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.mvel2.MVEL;
import org.onap.policy.apex.context.ContextException;
@@ -70,16 +71,17 @@ public class MvelStateFinalizerExecutor 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);
// Check and execute the MVEL logic
argumentNotNull(compiled, "MVEL state finalizer logic not compiled.");
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java
index 69a53a26b..3fa753bec 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java
@@ -26,6 +26,7 @@ import static org.onap.policy.common.utils.validation.Assertions.argumentNotNull
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.mvel2.MVEL;
import org.onap.policy.apex.context.ContextException;
@@ -70,16 +71,17 @@ public class MvelTaskExecutor 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);
// Check and execute the MVEL logic
argumentNotNull(compiled, "MVEL task not compiled.");
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java
index eefc50d0d..1ba79ceec 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java
@@ -25,6 +25,7 @@ import static org.onap.policy.common.utils.validation.Assertions.argumentNotNull
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Properties;
import org.mvel2.MVEL;
import org.onap.policy.apex.context.ContextException;
@@ -71,16 +72,17 @@ public class MvelTaskSelectExecutor 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);
// Check and execute the MVEL logic
argumentNotNull(compiled, "MVEL task not compiled.");
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 948dd31e2..5e66be30f 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
@@ -126,7 +126,7 @@ public class MvelStateFinalizerExecutorTest {
}
try {
- msfe.execute(-1, null);
+ msfe.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
@@ -136,7 +136,7 @@ public class MvelStateFinalizerExecutorTest {
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- msfe.execute(-1, event);
+ msfe.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
@@ -146,7 +146,7 @@ public class MvelStateFinalizerExecutorTest {
stateFinalizerLogic.setLogic("executionId !=-1");
try {
msfe.prepare();
- msfe.execute(-1, event);
+ msfe.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals(
@@ -161,7 +161,7 @@ public class MvelStateFinalizerExecutorTest {
state.getStateOutputs().put("SelectedOutputIsMe", null);
try {
msfe.prepare();
- String stateOutput = msfe.execute(0, event);
+ String stateOutput = msfe.execute(0, null, event);
assertEquals("SelectedOutputIsMe", stateOutput);
} catch (Exception msfeException) {
LOGGER.warn("Unexpected exception happened here.", msfeException);
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 0759aac23..18bccd670 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
@@ -103,7 +103,7 @@ public class MvelTaskExecutorTest {
}
try {
- mte.execute(-1, null);
+ mte.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals(java.lang.NullPointerException.class, mteException.getClass());
@@ -111,7 +111,7 @@ public class MvelTaskExecutorTest {
Map<String, Object> incomingParameters = new HashMap<>();
try {
- mte.execute(-1, incomingParameters);
+ mte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals("failed to execute MVEL code for task NULL:0.0.0", mteException.getMessage());
@@ -120,7 +120,7 @@ public class MvelTaskExecutorTest {
task.getTaskLogic().setLogic("executionId != -1");
try {
mte.prepare();
- mte.execute(-1, incomingParameters);
+ mte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
@@ -129,7 +129,7 @@ public class MvelTaskExecutorTest {
try {
mte.prepare();
- Map<String, Object> returnMap = mte.execute(0, incomingParameters);
+ Map<String, Object> returnMap = mte.execute(0, null, incomingParameters);
assertEquals(0, returnMap.size());
mte.cleanUp();
} catch (Exception mteException) {
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 fd4857fa0..05591b075 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
@@ -103,7 +103,7 @@ public class MvelTaskSelectExecutorTest {
}
try {
- mtse.execute(-1, null);
+ mtse.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals(java.lang.NullPointerException.class, mtseException.getClass());
@@ -112,7 +112,7 @@ public class MvelTaskSelectExecutorTest {
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- mtse.execute(-1, event);
+ mtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
@@ -122,7 +122,7 @@ public class MvelTaskSelectExecutorTest {
state.getTaskSelectionLogic().setLogic("executionId != -1");
try {
mtse.prepare();
- mtse.execute(-1, event);
+ mtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",
@@ -131,7 +131,7 @@ public class MvelTaskSelectExecutorTest {
try {
mtse.prepare();
- AxArtifactKey taskKey = mtse.execute(0, event);
+ AxArtifactKey taskKey = mtse.execute(0, null, event);
assertEquals("NULL:0.0.0", taskKey.getId());
mtse.cleanUp();
} catch (Exception mtseException) {