aboutsummaryrefslogtreecommitdiffstats
path: root/core/core-engine/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-07-10 19:44:39 +0000
committerliamfallon <liam.fallon@est.tech>2019-07-10 19:44:39 +0000
commitadf67497761295115dc75b525500d687518fc4fd (patch)
treec5c5b5e737ac08256e9f782b5dccbd3ddc08d3c3 /core/core-engine/src/main
parent5c384fb2888029c2babb859c30318749e1ce828c (diff)
Add integration tests for executor properties
Added integration test that sets properties in a dummy plugin and amends them in tasks in a policy. Variosu tests added to check combinations of where properties are set in plugins or in tasks or both. Implementaiton changed to: - Always pass in a Properies object, the properties object coming into the policy cannot be null because the task/TSL/SFL may wish to set it - Fix a bug where the properties were not passed from the ApexEvent to the engine event in the ApexEventUnmarshaller class Issue-ID: POLICY-1743 Change-Id: I6aa152b28d46cf3cc6fa56a1a95b76a8e55f5a49 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'core/core-engine/src/main')
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java2
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutor.java4
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java4
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutor.java4
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java36
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java30
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java30
7 files changed, 40 insertions, 70 deletions
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java
index 95ea6b5d2..9a5acbf3e 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java
@@ -82,7 +82,7 @@ public class EnEvent extends HashMap<String, Object> {
// Event related properties used during processing of this event
@Getter
@Setter
- private Properties executionProperties;
+ private Properties executionProperties = new Properties();
// A string holding a message that indicates why processing of this event threw an exception
@Getter
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutor.java
index e3a64eb30..698a1d837 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutor.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutor.java
@@ -26,6 +26,8 @@ import static org.onap.policy.common.utils.validation.Assertions.argumentOfClass
import java.util.Map;
import java.util.Properties;
+import lombok.NonNull;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -115,7 +117,7 @@ public abstract class StateFinalizerExecutor
* {@inheritDoc}.
*/
@Override
- public final void executePre(final long executionId, final Properties executionProperties,
+ public final void executePre(final long executionId, @NonNull final Properties executionProperties,
final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
LOGGER.debug("execute-pre:" + finalizerLogic.getLogicFlavour() + "," + getSubject().getId() + ","
+ finalizerLogic.getLogic());
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java
index 15fee6efa..ab81a8490 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java
@@ -30,6 +30,8 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
+import lombok.NonNull;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -116,7 +118,7 @@ public abstract class TaskExecutor
* {@inheritDoc}.
*/
@Override
- public final void executePre(final long executionId, final Properties executionProperties,
+ public final void executePre(final long executionId, @NonNull final Properties executionProperties,
final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
LOGGER.debug("execute-pre:" + getSubject().getTaskLogic().getLogicFlavour() + ","
+ getSubject().getKey().getId() + "," + getSubject().getTaskLogic().getLogic());
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutor.java
index 097bc98b5..d99d6b005 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutor.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutor.java
@@ -25,6 +25,8 @@ import static org.onap.policy.common.utils.validation.Assertions.argumentNotNull
import java.util.Properties;
+import lombok.NonNull;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -108,7 +110,7 @@ public abstract class TaskSelectExecutor implements Executor<EnEvent, AxArtifact
* {@inheritDoc}.
*/
@Override
- public final void executePre(final long executionId, final Properties executionProperties,
+ public final void executePre(final long executionId, @NonNull final Properties executionProperties,
final EnEvent newIncomingEvent) throws StateMachineException {
LOGGER.debug("execute-pre:" + axState.getKey().getId() + "," + axState.getTaskSelectionLogic().getLogicFlavour()
+ "," + axState.getTaskSelectionLogic().getLogic());
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
index 5efd47e53..e27c62f9a 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
@@ -27,6 +27,9 @@ import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
+import lombok.Getter;
+import lombok.Setter;
+
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -60,9 +63,6 @@ public class StateFinalizerExecutionContext {
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
- /** the execution properties the current APEX policy execution instance. */
- public final Properties executionProperties;
-
/**
* The list of state outputs for this state finalizer. The purpose of a state finalizer is to select a state output
* for a state from this list of state output names.
@@ -76,9 +76,6 @@ public class StateFinalizerExecutionContext {
*/
public final Map<String, Object> fields;
- // A message specified in the logic
- private String message;
-
/**
* The state output that the state finalizer logic has selected for a state. The state finalizer logic sets this
* field in its logic after executing and the Apex engine uses this state output for this state.
@@ -95,6 +92,15 @@ public class StateFinalizerExecutionContext {
// All available context albums
private final Map<String, ContextAlbum> context;
+ // A message specified in the logic
+ @Getter
+ @Setter
+ private String message;
+
+ // Execution properties for a policy execution
+ @Getter
+ private Properties executionProperties;
+
/**
* Instantiates a new state finalizer execution context.
*
@@ -179,22 +185,4 @@ public class StateFinalizerExecutionContext {
public void setSelectedStateOutputName(final String selectedStateOutputName) {
this.selectedStateOutputName = selectedStateOutputName;
}
-
- /**
- * Gets the user message.
- *
- * @return the user message
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the user message.
- *
- * @param message the message
- */
- public void setMessage(final String message) {
- this.message = message;
- }
}
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java
index 6fb55a3e7..b322cf402 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java
@@ -27,6 +27,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
+import lombok.Getter;
+import lombok.Setter;
+
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -66,9 +69,6 @@ public class TaskExecutionContext {
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
- /** the execution properties the current APEX policy execution instance. */
- public final Properties executionProperties;
-
/**
* The incoming fields from the trigger event for the task. The task logic can access these fields when executing
* its logic.
@@ -95,8 +95,14 @@ public class TaskExecutionContext {
private final List<AxConcept> usedArtifactStack;
// A message specified in the logic
+ @Getter
+ @Setter
private String message;
+ // Execution properties for a policy execution
+ @Getter
+ private Properties executionProperties;
+
/**
* Instantiates a new task execution context.
*
@@ -163,22 +169,4 @@ public class TaskExecutionContext {
+ "\" on task \"" + subject.getId() + "\"");
}
}
-
- /**
- * Get the user message.
- *
- * @return the user message
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the user message.
- *
- * @param message the message
- */
- public void setMessage(final String message) {
- this.message = message;
- }
}
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
index 10d21a76f..8d83e7645 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
@@ -26,6 +26,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
+import lombok.Getter;
+import lombok.Setter;
+
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -66,9 +69,6 @@ public class TaskSelectionExecutionContext {
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
- /** the execution properties the current APEX policy execution instance. */
- public final Properties executionProperties;
-
/**
* The incoming fields from the trigger event for the state. The task selection logic can access
* these fields to decide what task to select for the state.
@@ -94,8 +94,14 @@ public class TaskSelectionExecutionContext {
private final Map<String, ContextAlbum> context;
// A message specified in the logic
+ @Getter
+ @Setter
private String message;
+ // Execution properties for a policy execution
+ @Getter
+ private Properties executionProperties;
+
/**
* Instantiates a new task selection execution context.
*
@@ -170,22 +176,4 @@ public class TaskSelectionExecutionContext {
+ "\" on state \"" + subject.getId() + "\"");
}
}
-
- /**
- * Gets the user message.
- *
- * @return the user message
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the user message.
- *
- * @param message the message
- */
- public void setMessage(final String message) {
- this.message = message;
- }
}