diff options
author | liamfallon <liam.fallon@est.tech> | 2019-06-26 15:40:41 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-06-26 15:40:41 +0000 |
commit | ce9d82d2c0e863597d84cc8909955e398405f45a (patch) | |
tree | 8ebb853119bdf673cf6f9516d428d4cc00080aeb /core | |
parent | 5f029543f1e673655af2d2974113069df0b6def0 (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 'core')
22 files changed, 415 insertions, 573 deletions
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/StateMachineHandler.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/StateMachineHandler.java index 636f87af3..c1007b1fe 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/StateMachineHandler.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/StateMachineHandler.java @@ -38,13 +38,12 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * This handler holds and manages state machines for each policy in an Apex engine. When the class - * is instantiated, an executor {@link StateMachineExecutor} is created for each policy in the - * policy model the state machine handler will execute. The executors for each policy are held in a - * map indexed by event. + * This handler holds and manages state machines for each policy in an Apex engine. When the class is instantiated, an + * executor {@link StateMachineExecutor} is created for each policy in the policy model the state machine handler will + * execute. The executors for each policy are held in a map indexed by event. * - * <p>When an event is received on the policy, the state machine executor to execute that event is - * looked up on the executor map and the event is passed to the executor for execution. + * <p>When an event is received on the policy, the state machine executor to execute that event is looked up on the + * executor map and the event is passed to the executor for execution. * * @author Liam Fallon * @@ -111,8 +110,7 @@ public class StateMachineHandler { } /** - * This constructor starts the state machines for each policy, carrying out whatever - * initialization executors need. + * This constructor starts the state machines for each policy, carrying out whatever initialization executors need. * * @throws StateMachineException On state machine initiation errors */ @@ -127,8 +125,7 @@ public class StateMachineHandler { final String stateMachineId = smExecutor.getContext().getKey().getId(); String message = "start()<-" + key.getId() + ", start failed, state machine \"" + stateMachineId + "\""; LOGGER.warn(message, e); - throw new StateMachineException( - message, e); + throw new StateMachineException(message, e); } } @@ -159,7 +156,8 @@ public class StateMachineHandler { // Run the state machine try { LOGGER.debug("execute(): state machine \"{}\" execution starting . . .", stateMachineExecutor); - final EnEvent outputObject = stateMachineExecutor.execute(event.getExecutionId(), event); + final EnEvent outputObject = + stateMachineExecutor.execute(event.getExecutionId(), event.getExecutionProperties(), event); LOGGER.debug("execute()<-: state machine \"{}\" execution completed", stateMachineExecutor); return outputObject; 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 c510763cc..b7afedfea 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 @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Properties; import java.util.Random; import java.util.Set; @@ -70,6 +71,9 @@ public class EnEvent extends HashMap<String, Object> { // be reset private long executionId = rand.nextLong(); + // Event related properties used during processing of this event + private Properties executionProperties; + // A string holding a message that indicates why processing of this event threw an exception private String exceptionMessage; @@ -89,7 +93,7 @@ public class EnEvent extends HashMap<String, Object> { */ public EnEvent(final AxEvent axEvent) { super(); - + if (axEvent == null) { throw new EnException("event definition is null or was not found in model service"); } @@ -160,6 +164,24 @@ public class EnEvent extends HashMap<String, Object> { } /** + * Get the event execution properties. + * + * @return the event execution properties + */ + public Properties getExecutionProperties() { + return executionProperties; + } + + /** + * Set the event execution properties. + * + * @param executionProperties the execution properties to set + */ + public void setExecutionProperties(Properties executionProperties) { + this.executionProperties = executionProperties; + } + + /** * Gets the exception message explaining why processing of this event to fail. * * @return the exception message @@ -177,7 +199,6 @@ public class EnEvent extends HashMap<String, Object> { this.exceptionMessage = exceptionMessage; } - /** * Get the user artifact stack of the event. * diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java index 7a026edf7..fa0b40e77 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java @@ -20,6 +20,8 @@ package org.onap.policy.apex.core.engine.executor; +import java.util.Properties; + import org.onap.policy.apex.core.engine.ExecutorParameters; import org.onap.policy.apex.core.engine.executor.exception.StateMachineException; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; @@ -65,20 +67,22 @@ public interface Executor<I, O, S, C> { * Executes the executor, running through its context in its natural order. * * @param executionId the execution ID of the current APEX execution policy thread + * @param executionProperties the execution properties to set * @param incomingEntity the incoming entity that triggers execution * @return The outgoing entity that is the result of execution * @throws ApexException on an execution error */ - O execute(long executionId, I incomingEntity) throws ApexException; + O execute(long executionId, Properties executionProperties, I incomingEntity) throws ApexException; /** * Carry out the preparatory work for execution. * * @param executionId the execution ID of the current APEX execution policy thread + * @param executionProperties the execution properties to set * @param incomingEntity the incoming entity that triggers execution * @throws ApexException on an execution error */ - void executePre(long executionId, I incomingEntity) throws ApexException; + void executePre(long executionId, Properties executionProperties, I incomingEntity) throws ApexException; /** * Carry out the post work for execution, the returning entity should be set by the child diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateExecutor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateExecutor.java index 28ea13ea7..069c750c0 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateExecutor.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateExecutor.java @@ -23,6 +23,7 @@ package org.onap.policy.apex.core.engine.executor; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Properties; import java.util.TreeMap; import org.onap.policy.apex.context.ContextException; @@ -84,18 +85,14 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap /** * Constructor, save the executor factory. * - * @param executorFactory the executor factory to use for getting executors for task selection - * logic + * @param executorFactory the executor factory to use for getting executors for task selection logic */ public StateExecutor(final ExecutorFactory executorFactory) { this.executorFactory = executorFactory; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core. - * engine.executor.Executor, java.lang.Object, java.lang.Object) + /** + * {@inheritDoc} */ @Override public void setContext(final Executor<?, ?, ?, ?> incomingParent, final AxState incomingAxState, @@ -145,10 +142,8 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#prepare() + /** + * {@inheritDoc} */ @Override public void prepare() throws StateMachineException { @@ -164,15 +159,12 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, - * java.lang.Object) + /** + * {@inheritDoc} */ @Override - public StateOutput execute(final long executionId, final EnEvent incomingEvent) - throws StateMachineException, ContextException { + public StateOutput execute(final long executionId, final Properties executionProperties, + final EnEvent incomingEvent) throws StateMachineException, ContextException { this.lastIncomingEvent = incomingEvent; // Check that the incoming event matches the trigger for this state @@ -188,7 +180,7 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap // There may be no task selection logic, in which case just return the default task if (taskSelectExecutor != null) { // Fire the task selector to find the task to run - taskKey = taskSelectExecutor.execute(executionId, incomingEvent); + taskKey = taskSelectExecutor.execute(executionId, executionProperties, incomingEvent); } // If there's no task selection logic or the TSL returned no task, just use the default @@ -201,7 +193,7 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap final TreeMap<String, Object> incomingValues = new TreeMap<>(); incomingValues.putAll(incomingEvent); final Map<String, Object> taskExecutionResultMap = - taskExecutorMap.get(taskKey).execute(executionId, incomingValues); + taskExecutorMap.get(taskKey).execute(executionId, executionProperties, incomingValues); final AxTask task = taskExecutorMap.get(taskKey).getSubject(); // Check if this task has direct output @@ -220,7 +212,7 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap // Execute the state finalizer logic to select a state output and to adjust the // taskExecutionResultMap stateOutputName = - finalizerLogicExecutor.execute(incomingEvent.getExecutionId(), taskExecutionResultMap); + finalizerLogicExecutor.execute(executionId, executionProperties, taskExecutionResultMap); } // Now look up the the actual state output @@ -242,6 +234,7 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap // Set the ExecutionID for the outgoing event to the value in the incoming event. if (stateOutput.getOutputEvent() != null) { stateOutput.getOutputEvent().setExecutionId(incomingEvent.getExecutionId()); + stateOutput.getOutputEvent().setExecutionProperties(incomingEvent.getExecutionProperties()); } // That's it, the state execution is complete @@ -255,31 +248,22 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long, - * java.lang.Object) + /** + * {@inheritDoc} */ @Override - public final void executePre(final long executionId, final EnEvent incomingEntity) throws StateMachineException { + public final void executePre(final long executionId, final Properties executionProperties, + final EnEvent incomingEntity) throws StateMachineException { throw new StateMachineException("execution pre work not implemented on class"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean) - */ @Override public final void executePost(final boolean returnValue) throws StateMachineException { throw new StateMachineException("execution post work not implemented on class"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp() + /** + * {@inheritDoc} */ @Override public void cleanUp() throws StateMachineException { @@ -294,94 +278,72 @@ public class StateExecutor implements Executor<EnEvent, StateOutput, AxState, Ap } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getKey() + /** + * {@inheritDoc} */ @Override public AxReferenceKey getKey() { return axState.getKey(); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getParent() + /** + * {@inheritDoc} */ @Override public Executor<?, ?, ?, ?> getParent() { return parent; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject() + /** + * {@inheritDoc} */ @Override public AxState getSubject() { return axState; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getContext() + /** + * {@inheritDoc} */ @Override public final ApexInternalContext getContext() { return context; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming() + /** + * {@inheritDoc} */ @Override public final EnEvent getIncoming() { return lastIncomingEvent; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing() + /** + * {@inheritDoc} */ @Override public final StateOutput getOutgoing() { return lastStateOutput; } - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine. - * executor.Executor) + /** + * {@inheritDoc} */ @Override public final void setNext(final Executor<EnEvent, StateOutput, AxState, ApexInternalContext> incomingNextExecutor) { this.nextExecutor = incomingNextExecutor; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getNext() + /** + * {@inheritDoc} */ @Override public final Executor<EnEvent, StateOutput, AxState, ApexInternalContext> getNext() { return nextExecutor; } - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core. - * engine. ExecutorParameters) + /** + * {@inheritDoc} */ @Override public void setParameters(final ExecutorParameters parameters) { 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 2e6d96143..d406ac9ec 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 @@ -24,6 +24,7 @@ package org.onap.policy.apex.core.engine.executor; import static org.onap.policy.common.utils.validation.Assertions.argumentOfClassNotNull; import java.util.Map; +import java.util.Properties; import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.ExecutorParameters; @@ -44,7 +45,7 @@ import org.slf4j.ext.XLoggerFactory; * @author Liam Fallon (liam.fallon@ericsson.com) */ public abstract class StateFinalizerExecutor - implements Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> { + implements Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(StateFinalizerExecutor.class); @@ -77,76 +78,64 @@ public abstract class StateFinalizerExecutor return executionContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core. - * engine.executor.Executor, java.lang.Object, java.lang.Object) + /** + * {@inheritDoc} */ @Override public void setContext(final Executor<?, ?, ?, ?> incomingParent, - final AxStateFinalizerLogic incomingFinalizerLogic, - final ApexInternalContext incomingInternalContext) { + final AxStateFinalizerLogic incomingFinalizerLogic, final ApexInternalContext incomingInternalContext) { this.parent = incomingParent; axState = (AxState) parent.getSubject(); this.finalizerLogic = incomingFinalizerLogic; this.internalContext = incomingInternalContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#prepare() + /** + * {@inheritDoc} */ @Override public void prepare() throws StateMachineException { LOGGER.debug("prepare:" + finalizerLogic.getId() + "," + finalizerLogic.getLogicFlavour() + "," - + finalizerLogic.getLogic()); + + finalizerLogic.getLogic()); argumentOfClassNotNull(finalizerLogic.getLogic(), StateMachineException.class, - "state finalizer logic cannot be null."); + "state finalizer logic cannot be null."); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object) + /** + * {@inheritDoc} */ @Override - public String execute(final long executionId, final Map<String, Object> newIncomingFields) - throws StateMachineException, ContextException { + public String execute(final long executionId, final Properties executionProperties, + final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException { throw new StateMachineException("execute() not implemented on abstract StateFinalizerExecutionContext class, " - + "only on its subclasses"); + + "only on its subclasses"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long, java.lang.Object) + /** + * {@inheritDoc} */ @Override - public final void executePre(final long executionId, final Map<String, Object> newIncomingFields) - throws StateMachineException, ContextException { + public final void executePre(final long executionId, final Properties executionProperties, + final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException { LOGGER.debug("execute-pre:" + finalizerLogic.getLogicFlavour() + "," + getSubject().getId() + "," - + finalizerLogic.getLogic()); + + finalizerLogic.getLogic()); // Record the incoming fields this.incomingFields = newIncomingFields; // Get state finalizer context object - executionContext = new StateFinalizerExecutionContext(this, executionId, axState, getIncoming(), - axState.getStateOutputs().keySet(), getContext()); + executionContext = new StateFinalizerExecutionContext(this, executionId, executionProperties, axState, + getIncoming(), axState.getStateOutputs().keySet(), getContext()); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean) + /** + * {@inheritDoc} */ @Override public final void executePost(final boolean returnValue) throws StateMachineException, ContextException { if (!returnValue) { String errorMessage = "execute-post: state finalizer logic execution failure on state \"" + axState.getId() - + "\" on finalizer logic " + finalizerLogic.getId(); + + "\" on finalizer logic " + finalizerLogic.getId(); if (executionContext.getMessage() != null) { errorMessage += ", user message: " + executionContext.getMessage(); } @@ -163,79 +152,65 @@ public abstract class StateFinalizerExecutor if (!axState.getStateOutputs().keySet().contains(getOutgoing())) { LOGGER.warn(EXECUTE_POST_SFL + finalizerLogic.getId() + "\" selected output state \"" + getOutgoing() - + "\" that does not exsist on state \"" + axState.getId() + "\""); + + "\" that does not exsist on state \"" + axState.getId() + "\""); throw new StateMachineException(EXECUTE_POST_SFL + finalizerLogic.getId() + "\" selected output state \"" - + getOutgoing() + "\" that does not exsist on state \"" + axState.getId() + "\""); + + getOutgoing() + "\" that does not exsist on state \"" + axState.getId() + "\""); } LOGGER.debug("execute-post:{}, returning state output \"{}\" and fields {}", finalizerLogic.getId(), - getOutgoing(), incomingFields); + getOutgoing(), incomingFields); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp() + /** + * {@inheritDoc} */ @Override public void cleanUp() throws StateMachineException { throw new StateMachineException("cleanUp() not implemented on class"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getKey() + /** + * {@inheritDoc} */ @Override public AxReferenceKey getKey() { return finalizerLogic.getKey(); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getParent() + /** + * {@inheritDoc} */ @Override public Executor<?, ?, ?, ?> getParent() { return parent; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject() + /** + * {@inheritDoc} */ @Override public AxStateFinalizerLogic getSubject() { return finalizerLogic; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getContext() + /** + * {@inheritDoc} */ @Override public ApexInternalContext getContext() { return internalContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming() + /** + * {@inheritDoc} */ @Override public Map<String, Object> getIncoming() { return incomingFields; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing() + /** + * {@inheritDoc} */ @Override public String getOutgoing() { @@ -246,35 +221,26 @@ public abstract class StateFinalizerExecutor } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine. - * executor.Executor) + /** + * {@inheritDoc} */ @Override public void setNext( - final Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> inNextEx) { + final Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> inNextEx) { this.nextExecutor = inNextEx; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getNext() + /** + * {@inheritDoc} */ @Override public Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> getNext() { return nextExecutor; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core. engine. - * ExecutorParameters) + /** + * {@inheritDoc} */ @Override - public void setParameters(final ExecutorParameters parameters) { - } + public void setParameters(final ExecutorParameters parameters) {} } diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java index 34ba3942c..afc888e8d 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.core.engine.executor; import java.util.Map; +import java.util.Properties; import java.util.TreeMap; import org.onap.policy.apex.context.ContextException; @@ -59,8 +60,7 @@ public class StateMachineExecutor implements Executor<EnEvent, EnEvent, AxPolicy private ExecutorFactory executorFactory = null; /** - * Constructor, save the executor factory that will give us executors for task selection logic - * and task logic. + * Constructor, save the executor factory that will give us executors for task selection logic and task logic. * * @param executorFactory the executor factory * @param owner the artifact key of the owner of this state machine @@ -69,11 +69,8 @@ public class StateMachineExecutor implements Executor<EnEvent, EnEvent, AxPolicy this.executorFactory = executorFactory; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core. - * engine.executor.Executor, java.lang.Object, java.lang.Object) + /** + * {@inheritDoc} */ @Override public void setContext(final Executor<?, ?, ?, ?> newParent, final AxPolicy newAxPolicy, @@ -109,10 +106,8 @@ public class StateMachineExecutor implements Executor<EnEvent, EnEvent, AxPolicy } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#prepare() + /** + * {@inheritDoc} */ @Override public void prepare() throws StateMachineException { @@ -121,14 +116,11 @@ public class StateMachineExecutor implements Executor<EnEvent, EnEvent, AxPolicy } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executeDirected(java.lang.long, - * java.lang.Object) + /** + * {@inheritDoc} */ @Override - public EnEvent execute(final long executionId, final EnEvent incomingEvent) + public EnEvent execute(final long executionId, final Properties executionProperties, final EnEvent incomingEvent) throws StateMachineException, ContextException { // Check if there are any states on the state machine if (stateExecutorMap.size() == 0) { @@ -145,9 +137,10 @@ public class StateMachineExecutor implements Executor<EnEvent, EnEvent, AxPolicy StateExecutor stateExecutor = firstExecutor; StateOutput stateOutput = new StateOutput(new AxStateOutput(firstExecutor.getSubject().getKey(), incomingEvent.getKey(), firstExecutor.getSubject().getKey()), incomingEvent); + while (true) { // Execute the state, it returns an output or throws an exception - stateOutput = stateExecutor.execute(executionId, stateOutput.getOutputEvent()); + stateOutput = stateExecutor.execute(executionId, executionProperties, stateOutput.getOutputEvent()); // Use the next state of the state output to find if all the states have executed if (stateOutput.getNextState().equals(AxReferenceKey.getNullKey())) { @@ -165,31 +158,25 @@ public class StateMachineExecutor implements Executor<EnEvent, EnEvent, AxPolicy return stateOutput.getOutputEvent(); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long, - * java.lang.Object) + /** + * {@inheritDoc} */ @Override - public final void executePre(final long executionId, final EnEvent incomingEntity) throws StateMachineException { + public final void executePre(final long executionId, final Properties executionProperties, + final EnEvent incomingEntity) throws StateMachineException { throw new StateMachineException("execution pre work not implemented on class"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean) + /** + * {@inheritDoc} */ @Override public final void executePost(final boolean returnValue) throws StateMachineException { throw new StateMachineException("execution post work not implemented on class"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp() + /** + * {@inheritDoc} */ @Override public void cleanUp() throws StateMachineException { @@ -198,94 +185,72 @@ public class StateMachineExecutor implements Executor<EnEvent, EnEvent, AxPolicy } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getKey() + /** + * {@inheritDoc} */ @Override public AxArtifactKey getKey() { return axPolicy.getKey(); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getParent() + /** + * {@inheritDoc} */ @Override public final Executor<?, ?, ?, ?> getParent() { return parent; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject() + /** + * {@inheritDoc} */ @Override public final AxPolicy getSubject() { return axPolicy; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getContext() + /** + * {@inheritDoc} */ @Override public final ApexInternalContext getContext() { return internalContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming() + /** + * {@inheritDoc} */ @Override public final EnEvent getIncoming() { return null; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing() + /** + * {@inheritDoc} */ @Override public final EnEvent getOutgoing() { return null; } - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine. - * executor.Executor) + /** + * {@inheritDoc} */ @Override public final void setNext(final Executor<EnEvent, EnEvent, AxPolicy, ApexInternalContext> newNextExecutor) { this.nextExecutor = newNextExecutor; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getNext() + /** + * {@inheritDoc} */ @Override public final Executor<EnEvent, EnEvent, AxPolicy, ApexInternalContext> getNext() { return nextExecutor; } - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core. - * engine. ExecutorParameters) + /** + * {@inheritDoc} */ @Override public void setParameters(final ExecutorParameters parameters) { 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 9c21dc570..0aade5ff1 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 @@ -25,6 +25,7 @@ import static org.onap.policy.common.utils.validation.Assertions.argumentOfClass import java.util.Iterator; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -49,7 +50,7 @@ import org.slf4j.ext.XLoggerFactory; * @author Liam Fallon (liam.fallon@ericsson.com) */ public abstract class TaskExecutor - implements Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> { + implements Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(TaskExecutor.class); @@ -79,55 +80,46 @@ public abstract class TaskExecutor return executionContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core. - * engine.executor.Executor, java.lang.Object, java.lang.Object) + /** + * {@inheritDoc} */ @Override public void setContext(final Executor<?, ?, ?, ?> newParent, final AxTask newAxTask, - final ApexInternalContext newInternalContext) { + final ApexInternalContext newInternalContext) { this.parent = newParent; this.axTask = newAxTask; this.internalContext = newInternalContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#prepare() + /** + * {@inheritDoc} */ @Override public void prepare() throws StateMachineException { LOGGER.debug("prepare:" + axTask.getKey().getId() + "," + axTask.getTaskLogic().getLogicFlavour() + "," - + axTask.getTaskLogic().getLogic()); + + axTask.getTaskLogic().getLogic()); argumentOfClassNotNull(axTask.getTaskLogic().getLogic(), StateMachineException.class, - "task logic cannot be null."); + "task logic cannot be null."); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object) + /** + * {@inheritDoc} */ @Override - public Map<String, Object> execute(final long executionId, final Map<String, Object> newIncomingFields) - throws StateMachineException, ContextException { + public Map<String, Object> execute(final long executionId, final Properties executionProperties, + final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException { throw new StateMachineException( - "execute() not implemented on abstract TaskExecutor class, only on its subclasses"); + "execute() not implemented on abstract TaskExecutor class, only on its subclasses"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long, java.lang.Object) + /** + * {@inheritDoc} */ @Override - public final void executePre(final long executionId, final Map<String, Object> newIncomingFields) - throws StateMachineException, ContextException { + public final void executePre(final long executionId, final Properties executionProperties, + final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException { LOGGER.debug("execute-pre:" + getSubject().getTaskLogic().getLogicFlavour() + "," - + getSubject().getKey().getId() + "," + getSubject().getTaskLogic().getLogic()); + + getSubject().getKey().getId() + "," + getSubject().getTaskLogic().getLogic()); // Check that the incoming event has all the input fields for this state final Set<String> missingTaskInputFields = new TreeSet<>(axTask.getInputFields().keySet()); @@ -136,7 +128,7 @@ public abstract class TaskExecutor // Remove fields from the set that are optional final Set<String> optionalFields = new TreeSet<>(); for (final Iterator<String> missingFieldIterator = missingTaskInputFields.iterator(); missingFieldIterator - .hasNext();) { + .hasNext();) { final String missingField = missingFieldIterator.next(); if (axTask.getInputFields().get(missingField).getOptional()) { optionalFields.add(missingField); @@ -145,7 +137,7 @@ public abstract class TaskExecutor missingTaskInputFields.removeAll(optionalFields); if (!missingTaskInputFields.isEmpty()) { throw new StateMachineException("task input fields \"" + missingTaskInputFields - + "\" are missing for task \"" + axTask.getKey().getId() + "\""); + + "\" are missing for task \"" + axTask.getKey().getId() + "\""); } // Record the incoming fields @@ -158,20 +150,18 @@ public abstract class TaskExecutor } // Get task context object - executionContext = new TaskExecutionContext(this, executionId, getSubject(), getIncoming(), getOutgoing(), - getContext()); + executionContext = new TaskExecutionContext(this, executionId, executionProperties, getSubject(), getIncoming(), + getOutgoing(), getContext()); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean) + /** + * {@inheritDoc} */ @Override public final void executePost(final boolean returnValue) throws StateMachineException, ContextException { if (!returnValue) { String errorMessage = "execute-post: task logic execution failure on task \"" + axTask.getKey().getName() - + "\" in model " + internalContext.getKey().getId(); + + "\" in model " + internalContext.getKey().getId(); if (executionContext.getMessage() != null) { errorMessage += ", user message: " + executionContext.getMessage(); } @@ -194,17 +184,17 @@ public abstract class TaskExecutor // Remove fields from the set that are optional final Set<String> optionalOrCopiedFields = new TreeSet<>(); for (final Iterator<String> missingFieldIterator = missingTaskOutputFields.iterator(); missingFieldIterator - .hasNext();) { + .hasNext();) { final String missingField = missingFieldIterator.next(); if (axTask.getInputFields().containsKey(missingField) - || axTask.getOutputFields().get(missingField).getOptional()) { + || axTask.getOutputFields().get(missingField).getOptional()) { optionalOrCopiedFields.add(missingField); } } missingTaskOutputFields.removeAll(optionalOrCopiedFields); if (!missingTaskOutputFields.isEmpty()) { throw new StateMachineException("task output fields \"" + missingTaskOutputFields - + "\" are missing for task \"" + axTask.getKey().getId() + "\""); + + "\" are missing for task \"" + axTask.getKey().getId() + "\""); } // Finally, check that the outgoing field map don't have any extra fields, if present, raise @@ -214,7 +204,7 @@ public abstract class TaskExecutor extraTaskOutputFields.removeAll(axTask.getOutputFields().keySet()); if (!extraTaskOutputFields.isEmpty()) { throw new StateMachineException("task output fields \"" + extraTaskOutputFields - + "\" are unwanted for task \"" + axTask.getKey().getId() + "\""); + + "\" are unwanted for task \"" + axTask.getKey().getId() + "\""); } String message = "execute-post:" + axTask.getKey().getId() + ", returning fields " + outgoingFields.toString(); @@ -246,105 +236,81 @@ public abstract class TaskExecutor getOutgoing().put(field, getIncoming().get(field)); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp() + /** + * {@inheritDoc} */ @Override public void cleanUp() throws StateMachineException { throw new StateMachineException("cleanUp() not implemented on class"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getKey() + /** + * {@inheritDoc} */ @Override public AxArtifactKey getKey() { return axTask.getKey(); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getParent() + /** + * {@inheritDoc} */ @Override public Executor<?, ?, ?, ?> getParent() { return parent; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject() + /** + * {@inheritDoc} */ @Override public AxTask getSubject() { return axTask; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getContext() + /** + * {@inheritDoc} */ @Override public ApexInternalContext getContext() { return internalContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming() + /** + * {@inheritDoc} */ @Override public Map<String, Object> getIncoming() { return incomingFields; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing() + /** + * {@inheritDoc} */ @Override public Map<String, Object> getOutgoing() { return outgoingFields; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine. - * executor.Executor) + /** + * {@inheritDoc} */ @Override - public void setNext( - final Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> nextEx) { + public void setNext(final Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> nextEx) { this.nextExecutor = nextEx; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getNext() + /** + * {@inheritDoc} */ @Override public Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> getNext() { return nextExecutor; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core. engine. - * ExecutorParameters) + /** + * {@inheritDoc} */ @Override - public void setParameters(final ExecutorParameters parameters) { - } + public void setParameters(final ExecutorParameters parameters) {} } 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 3439655c9..66ffa9b32 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 @@ -23,6 +23,8 @@ package org.onap.policy.apex.core.engine.executor; import static org.onap.policy.common.utils.validation.Assertions.argumentNotNull; +import java.util.Properties; + import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.ExecutorParameters; import org.onap.policy.apex.core.engine.context.ApexInternalContext; @@ -36,8 +38,8 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * This abstract class executes a the task selection logic of a state of an Apex policy and is - * specialized by classes that implement execution of task selection logic. + * This abstract class executes a the task selection logic of a state of an Apex policy and is specialized by classes + * that implement execution of task selection logic. * * @author Sven van der Meer (sven.van.der.meer@ericsson.com) * @author Liam Fallon (liam.fallon@ericsson.com) @@ -72,11 +74,8 @@ public abstract class TaskSelectExecutor implements Executor<EnEvent, AxArtifact return executionContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core. - * engine.executor.Executor, java.lang.Object, java.lang.Object) + /** + * {@inheritDoc} */ @Override public void setContext(final Executor<?, ?, ?, ?> newParent, final AxState newAxState, @@ -86,10 +85,8 @@ public abstract class TaskSelectExecutor implements Executor<EnEvent, AxArtifact this.context = newContext; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#prepare() + /** + * {@inheritDoc} */ @Override public void prepare() throws StateMachineException { @@ -98,26 +95,21 @@ public abstract class TaskSelectExecutor implements Executor<EnEvent, AxArtifact argumentNotNull(axState.getTaskSelectionLogic().getLogic(), "task selection logic cannot be null."); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, - * java.lang.Object) + /** + * {@inheritDoc} */ @Override - public AxArtifactKey execute(final long executionId, final EnEvent newIncomingEvent) - throws StateMachineException, ContextException { + public AxArtifactKey execute(final long executionId, final Properties executionProperties, + final EnEvent newIncomingEvent) throws StateMachineException, ContextException { throw new StateMachineException("execute() not implemented on class"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long, - * java.lang.Object) + /** + * {@inheritDoc} */ @Override - public final void executePre(final long executionId, final EnEvent newIncomingEvent) throws StateMachineException { + public final void executePre(final long executionId, final Properties executionProperties, + final EnEvent newIncomingEvent) throws StateMachineException { LOGGER.debug("execute-pre:" + axState.getKey().getId() + "," + axState.getTaskSelectionLogic().getLogicFlavour() + "," + axState.getTaskSelectionLogic().getLogic()); @@ -131,10 +123,8 @@ public abstract class TaskSelectExecutor implements Executor<EnEvent, AxArtifact getOutgoing(), getContext()); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean) + /** + * {@inheritDoc} */ @Override public final void executePost(final boolean returnValue) throws StateMachineException { @@ -164,104 +154,80 @@ public abstract class TaskSelectExecutor implements Executor<EnEvent, AxArtifact LOGGER.debug("execute-post:" + axState.getKey().getId() + "," + ", returning task " + outgoingTaskKey.getId()); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp() + /** + * {@inheritDoc} */ @Override public void cleanUp() throws StateMachineException { throw new StateMachineException("cleanUp() not implemented on class"); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getKey() + /** + * {@inheritDoc} */ @Override public AxReferenceKey getKey() { return axState.getKey(); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getParent() + /** + * {@inheritDoc} */ @Override public Executor<?, ?, ?, ?> getParent() { return parent; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject() + /** + * {@inheritDoc} */ @Override public AxState getSubject() { return axState; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getContext() + /** + * {@inheritDoc} */ @Override public ApexInternalContext getContext() { return context; } - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine. - * executor.Executor) + /** + * {@inheritDoc} */ @Override public void setNext(final Executor<EnEvent, AxArtifactKey, AxState, ApexInternalContext> newNextExecutor) { this.nextExecutor = newNextExecutor; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getNext() + /** + * {@inheritDoc} */ @Override public Executor<EnEvent, AxArtifactKey, AxState, ApexInternalContext> getNext() { return nextExecutor; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming() + /** + * {@inheritDoc} */ @Override public EnEvent getIncoming() { return incomingEvent; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing() + /** + * {@inheritDoc} */ @Override public AxArtifactKey getOutgoing() { return outgoingTaskKey; } - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core. - * engine. ExecutorParameters) + /** + * {@inheritDoc} */ @Override public void setParameters(final ExecutorParameters parameters) {} 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 460639b90..5efd47e53 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 @@ -23,6 +23,7 @@ package org.onap.policy.apex.core.engine.executor.context; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.TreeMap; @@ -38,16 +39,15 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * Container class for the execution context for state finalizer logic executions in a state being - * executed in an Apex engine. The state finalizer must have easy access to the state definition, - * the fields, as well as the policy, global, and external context. + * Container class for the execution context for state finalizer logic executions in a state being executed in an Apex + * engine. The state finalizer must have easy access to the state definition, the fields, as well as the policy, global, + * and external context. * * @author Sven van der Meer (sven.van.der.meer@ericsson.com) */ public class StateFinalizerExecutionContext { /** - * Logger for state finalizer execution, state finalizer logic can use this field to access and - * log to Apex logging. + * Logger for state finalizer execution, state finalizer logic can use this field to access and log to Apex logging. */ private static final XLogger EXCEUTION_LOGGER = XLoggerFactory.getXLogger("org.onap.policy.apex.executionlogging.StateFinalizerExecutionLogging"); @@ -60,17 +60,19 @@ 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. + * 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. */ public final Set<String> stateOutputNames; /** - * The fields of this state finalizer. A state finalizer receives this list of fields from a - * task and may use these fields to determine what state output to select. Once a state - * finalizer has selected a state output, it must marshal these fields so that they match the - * fields required for the event defined in the state output. + * The fields of this state finalizer. A state finalizer receives this list of fields from a task and may use these + * fields to determine what state output to select. Once a state finalizer has selected a state output, it must + * marshal these fields so that they match the fields required for the event defined in the state output. */ public final Map<String, Object> fields; @@ -78,15 +80,13 @@ public class StateFinalizerExecutionContext { 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. + * 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. */ private String selectedStateOutputName; /** - * Logger for state finalizer execution, state finalizer logic can use this field to access and - * log to Apex logging. + * Logger for state finalizer execution, state finalizer logic can use this field to access and log to Apex logging. */ public final XLogger logger = EXCEUTION_LOGGER; @@ -100,20 +100,20 @@ public class StateFinalizerExecutionContext { * * @param stateFinalizerExecutor the state finalizer executor that requires context * @param executionId the execution ID for the current APEX policy execution instance + * @param executionProperties the execution properties for task execution * @param axState the state definition that is the subject of execution * @param fields the fields to be manipulated by the state finalizer - * @param stateOutputNames the state output names, one of which will be selected by the state - * finalizer - * @param internalContext the execution context of the Apex engine in which the task is being - * executed + * @param stateOutputNames the state output names, one of which will be selected by the state finalizer + * @param internalContext the execution context of the Apex engine in which the task is being executed */ public StateFinalizerExecutionContext(final StateFinalizerExecutor stateFinalizerExecutor, final long executionId, - final AxState axState, final Map<String, Object> fields, final Set<String> stateOutputNames, - final ApexInternalContext internalContext) { + final Properties executionProperties, final AxState axState, final Map<String, Object> fields, + final Set<String> stateOutputNames, final ApexInternalContext internalContext) { subject = new AxStateFacade(axState); // Execution ID is the current policy execution instance this.executionId = executionId; + this.executionProperties = executionProperties; this.fields = fields; this.stateOutputNames = stateOutputNames; @@ -147,8 +147,7 @@ public class StateFinalizerExecutionContext { * * @param contextAlbumName The context album name * @return The context album - * @throws ContextRuntimeException if the context album does not exist on the state for this - * executor + * @throws ContextRuntimeException if the context album does not exist on the state for this executor */ public ContextAlbum getContextAlbum(final String contextAlbumName) { // Find the context album 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 4a9e83063..6fb55a3e7 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 @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.TreeMap; import org.onap.policy.apex.context.ContextAlbum; @@ -38,9 +39,9 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * Container class for the execution context for Task logic executions in a task being executed in - * an Apex engine. The task must have easy access to the task definition, the incoming and outgoing - * field contexts, as well as the policy, global, and external context. + * Container class for the execution context for Task logic executions in a task being executed in an Apex engine. The + * task must have easy access to the task definition, the incoming and outgoing field contexts, as well as the policy, + * global, and external context. * * @author Sven van der Meer (sven.van.der.meer@ericsson.com) */ @@ -65,15 +66,18 @@ 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. + * The incoming fields from the trigger event for the task. The task logic can access these fields when executing + * its logic. */ public final Map<String, Object> inFields; /** - * The outgoing fields from the task. The task logic can access and set these fields with its - * logic. A task outputs its result using these fields. + * The outgoing fields from the task. The task logic can access and set these fields with its logic. A task outputs + * its result using these fields. */ public final Map<String, Object> outFields; @@ -98,20 +102,21 @@ public class TaskExecutionContext { * * @param taskExecutor the task executor that requires context * @param executionId the execution ID for the current APEX policy execution instance + * @param executionProperties the execution properties for task execution * @param axTask the task definition that is the subject of execution * @param inFields the in fields * @param outFields the out fields - * @param internalContext the execution context of the Apex engine in which the task is being - * executed + * @param internalContext the execution context of the Apex engine in which the task is being executed */ - public TaskExecutionContext(final TaskExecutor taskExecutor, final long executionId, final AxTask axTask, - final Map<String, Object> inFields, final Map<String, Object> outFields, - final ApexInternalContext internalContext) { + public TaskExecutionContext(final TaskExecutor taskExecutor, final long executionId, + final Properties executionProperties, final AxTask axTask, final Map<String, Object> inFields, + final Map<String, Object> outFields, final ApexInternalContext internalContext) { // The subject is the task definition subject = new AxTaskFacade(axTask); // Execution ID is the current policy execution instance this.executionId = executionId; + this.executionProperties = executionProperties; // The input and output fields this.inFields = Collections.unmodifiableMap(inFields); @@ -144,8 +149,7 @@ public class TaskExecutionContext { * * @param contextAlbumName The context album name * @return The context album - * @throws ContextRuntimeException if the context album does not exist on the task for this - * executor + * @throws ContextRuntimeException if the context album does not exist on the task for this executor */ public ContextAlbum getContextAlbum(final String contextAlbumName) { // Find the context album 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 63052348a..10d21a76f 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 @@ -23,6 +23,7 @@ package org.onap.policy.apex.core.engine.executor.context; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.TreeMap; import org.onap.policy.apex.context.ContextAlbum; @@ -65,6 +66,9 @@ 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. @@ -111,6 +115,7 @@ public class TaskSelectionExecutionContext { // Execution ID is the current policy execution instance this.executionId = executionId; + this.executionProperties = incomingEvent.getExecutionProperties(); // The events inFields = incomingEvent; diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySmExecutor.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySmExecutor.java index db8fc32d9..b95e959f0 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySmExecutor.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySmExecutor.java @@ -5,21 +5,23 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.apex.core.engine.engine.impl; +import java.util.Properties; + import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.core.engine.executor.ExecutorFactory; import org.onap.policy.apex.core.engine.executor.StateMachineExecutor; @@ -32,10 +34,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; public class DummySmExecutor extends StateMachineExecutor { private boolean cleanupWorks = false; private boolean prepareWorks; - + /** * Constructor. - * + * * @param executorFactory the factory for executors * @param owner the owner key */ @@ -43,10 +45,8 @@ public class DummySmExecutor extends StateMachineExecutor { super(executorFactory, owner); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#prepare() + /** + * {@inheritDoc} */ @Override public void prepare() throws StateMachineException { @@ -59,20 +59,16 @@ public class DummySmExecutor extends StateMachineExecutor { } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#executeDirected(java.lang.long, java.lang.Object) + /** + * {@inheritDoc} */ @Override - public EnEvent execute(final long executionId, final EnEvent incomingEvent) { + public EnEvent execute(final long executionId, final Properties executionProperties, final EnEvent incomingEvent) { return incomingEvent; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp() + /** + * {@inheritDoc} */ @Override public void cleanUp() throws StateMachineException { diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyStateFinalizerExecutor.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyStateFinalizerExecutor.java index abc11871e..b4fefc2d9 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyStateFinalizerExecutor.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyStateFinalizerExecutor.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -21,6 +21,7 @@ package org.onap.policy.apex.core.engine.executor; import java.util.Map; +import java.util.Properties; import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.executor.exception.StateMachineException; @@ -30,34 +31,31 @@ import org.onap.policy.apex.core.engine.executor.exception.StateMachineException */ public class DummyStateFinalizerExecutor extends StateFinalizerExecutor { private boolean override; - + private boolean returnBad; public DummyStateFinalizerExecutor() { this(false); } - + public DummyStateFinalizerExecutor(final boolean override) { this.override = override; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object) + /** + * {@inheritDoc} */ @Override - public String execute(final long executionId, final Map<String, Object> newIncomingFields) - throws StateMachineException, ContextException { - + public String execute(final long executionId, final Properties executionProperties, + final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException { + if (!override) { - super.execute(executionId, newIncomingFields); + super.execute(executionId, executionProperties, newIncomingFields); } - + if (returnBad) { return "stateOutputBad"; - } - else { + } else { return "stateOutput1"; } } diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyTaskExecutor.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyTaskExecutor.java index 93fc6190f..fcfc85f66 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyTaskExecutor.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyTaskExecutor.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -21,6 +21,7 @@ package org.onap.policy.apex.core.engine.executor; import java.util.Map; +import java.util.Properties; import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.event.EnEvent; @@ -48,42 +49,36 @@ public class DummyTaskExecutor extends TaskExecutor { super.prepare(); } } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object) + + /** + * {@inheritDoc} */ @Override - public Map<String, Object> execute(final long executionId, final Map<String, Object> newIncomingFields) - throws StateMachineException, ContextException { + public Map<String, Object> execute(final long executionId, final Properties executionProperties, + final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException { if (!override) { - super.execute(executionId, newIncomingFields); + super.execute(executionId, executionProperties, newIncomingFields); } - + AxArtifactKey event0Key = new AxArtifactKey("Event0:0.0.1"); return new EnEvent(event0Key); } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject() + + /** + * {@inheritDoc} */ @Override public AxTask getSubject() { if (!override) { super.getSubject(); } - + AxArtifactKey taskKey = new AxArtifactKey("FirstTask:0.0.1"); return new AxTask(taskKey); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp() + /** + * {@inheritDoc} */ @Override public void cleanUp() throws StateMachineException { diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyTaskSelectExecutor.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyTaskSelectExecutor.java index abbb1bd79..03d0b2894 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyTaskSelectExecutor.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/DummyTaskSelectExecutor.java @@ -5,21 +5,23 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.apex.core.engine.executor; +import java.util.Properties; + import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.core.engine.executor.exception.StateMachineException; @@ -32,7 +34,7 @@ public class DummyTaskSelectExecutor extends TaskSelectExecutor { private boolean override; private static int taskNo; - + public DummyTaskSelectExecutor() { this(false); } @@ -48,30 +50,25 @@ public class DummyTaskSelectExecutor extends TaskSelectExecutor { } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object) + /** + * {@inheritDoc} */ @Override - public AxArtifactKey execute(final long executionId, final EnEvent newIncomingEvent) - throws StateMachineException, ContextException { + public AxArtifactKey execute(final long executionId, final Properties executionProperties, + final EnEvent newIncomingEvent) throws StateMachineException, ContextException { if (!override) { - return super.execute(executionId, newIncomingEvent); + return super.execute(executionId, executionProperties, newIncomingEvent); } - + return new AxArtifactKey("task" + (taskNo++) + ":0.0.1"); } public void setTaskNo(int incomingTaskNo) { taskNo = incomingTaskNo; } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp() + /** + * {@inheritDoc} */ @Override public void cleanUp() throws StateMachineException { diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java index 08ab03b06..ed5f9135c 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -56,7 +56,7 @@ public class StateExecutorTest { @Before public void startMocking() { MockitoAnnotations.initMocks(this); - + Mockito.doReturn(new AxReferenceKey("Policy:0.0.1:PolName:State0")).when(axStateMock).getKey(); } @@ -80,7 +80,7 @@ public class StateExecutorTest { assertEquals(null, executor.getNext()); try { - executor.executePre(0, null); + executor.executePre(0, null, null); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execution pre work not implemented on class", ex.getMessage()); diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java index 82ac610c9..a94fe9e80 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -63,10 +63,10 @@ public class StateFinalizerExecutorTest { @Before public void startMocking() { MockitoAnnotations.initMocks(this); - + AxState state = new AxState(); state.getStateOutputs().put("ValidOutput", null); - + Mockito.doReturn(state).when(parentMock).getSubject(); Mockito.doReturn(new AxReferenceKey("State:0.0.1:StateName:StateSFL")).when(stateFinalizerLogicMock).getKey(); @@ -117,19 +117,19 @@ public class StateFinalizerExecutorTest { } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception ex) { assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage()); } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } try { - executor.execute(0, incomingEvent); + executor.execute(0, null, incomingEvent); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute() not implemented on abstract StateFinalizerExecutionContext class, " @@ -154,7 +154,7 @@ public class StateFinalizerExecutorTest { } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -168,7 +168,7 @@ public class StateFinalizerExecutorTest { } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -184,7 +184,7 @@ public class StateFinalizerExecutorTest { } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception ex) { fail("test should not throw an exception"); } diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java index f9d3edc6c..c2abd1e96 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -187,7 +187,7 @@ public class StateMachineExecutorTest { new AxArtifactKey("OwnerKey:0.0.1")); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("no states defined on state machine", ex.getMessage()); @@ -209,7 +209,7 @@ public class StateMachineExecutorTest { assertEquals(null, executor.getNext()); try { - executor.executePre(0, null); + executor.executePre(0, null, null); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execution pre work not implemented on class", ex.getMessage()); @@ -231,7 +231,7 @@ public class StateMachineExecutorTest { axPolicy.setFirstState("BadState"); executor.setContext(null, axPolicy, internalContextMock); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("first state not defined on state machine", ex.getMessage()); @@ -240,14 +240,14 @@ public class StateMachineExecutorTest { axPolicy.setFirstState("state0"); executor.setContext(null, axPolicy, internalContextMock); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); } catch (Exception ex) { fail("test should not throw an exception"); } dummyTsle.setTaskNo(0); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -256,7 +256,7 @@ public class StateMachineExecutorTest { axPolicy.getStateMap().get("State1").getStateOutputs().get("stateOutput1").setNextState(badStateKey); dummyTsle.setTaskNo(0); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("state execution failed, next state \"Policy:0.0.1:PName:BadState\" not found", @@ -267,7 +267,7 @@ public class StateMachineExecutorTest { .setNextState(AxReferenceKey.getNullKey()); dummyTsle.setTaskNo(0); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -275,7 +275,7 @@ public class StateMachineExecutorTest { axPolicy.getStateMap().get("State1").setTrigger(new AxArtifactKey("BadTrigger:0.0.1")); dummyTsle.setTaskNo(0); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("incoming event \"Event1:0.0.1\" does not match trigger \"BadTrigger:0.0.1\" " @@ -285,7 +285,7 @@ public class StateMachineExecutorTest { axPolicy.getStateMap().get("State1").setTrigger(new AxArtifactKey("Event1:0.0.1")); dummyTsle.setTaskNo(0); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -309,7 +309,7 @@ public class StateMachineExecutorTest { dummyTsle.setTaskNo(0); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -334,7 +334,7 @@ public class StateMachineExecutorTest { dummyTsle.setTaskNo(0); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -342,7 +342,7 @@ public class StateMachineExecutorTest { dummyTsle.setTaskNo(0); dummySfle.setReturnBad(true); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("State execution of state \"Policy:0.0.1:NULL:state1\" on task \"task1:0.0.1\" failed: " @@ -353,7 +353,7 @@ public class StateMachineExecutorTest { dummyTsle.setTaskNo(0); dummySfle.setReturnBad(false); try { - executor.execute(0, incomingEventMock); + executor.execute(0, null, incomingEventMock); } catch (Exception ex) { fail("test should not throw an exception"); } diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java index bfc8e2b6d..a4a0f21ec 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -158,20 +158,20 @@ public class TaskExecutorTest { Map<String, Object> incomingFields = new LinkedHashMap<>(); try { - executor.executePre(0, incomingFields); + executor.executePre(0, null, incomingFields); } catch (Exception ex) { assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage()); } incomingFields.put("InField0", "A Value"); try { - executor.executePre(0, incomingFields); + executor.executePre(0, null, incomingFields); } catch (Exception e) { fail("test should not throw an exception"); } try { - executor.execute(0, incomingFields); + executor.execute(0, null, incomingFields); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute() not implemented on abstract TaskExecutor class, only on its subclasses", diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java index b303df06a..2ee308977 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -70,7 +70,7 @@ public class TaskSelectExecutorTest { AxReferenceKey state0Key = new AxReferenceKey("State0Parent:0.0.1:Parent:State0"); Mockito.doReturn(state0Key).when(axStateMock).getKey(); Mockito.doReturn(state0Key.getId()).when(axStateMock).getId(); - + Map<AxArtifactKey, AxStateTaskReference> taskReferences = new LinkedHashMap<>(); taskReferences.put(new AxArtifactKey("Task0:0.0.0"), null); taskReferences.put(new AxArtifactKey("Task1:0.0.0"), null); @@ -127,19 +127,19 @@ public class TaskSelectExecutorTest { } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception ex) { assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage()); } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } try { - executor.execute(0, incomingEvent); + executor.execute(0, null, incomingEvent); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute() not implemented on class", ex.getMessage()); @@ -163,7 +163,7 @@ public class TaskSelectExecutorTest { } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } @@ -176,7 +176,7 @@ public class TaskSelectExecutorTest { } try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } @@ -189,15 +189,15 @@ public class TaskSelectExecutorTest { assertEquals("task \"IDontExist:0.0.0\" returned by task selection logic not defined " + "on state \"State0Parent:0.0.1:Parent:State0\"", ex.getMessage()); } - + try { - executor.executePre(0, incomingEvent); + executor.executePre(0, null, incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } executor.getOutgoing().setName("Task0"); - + try { executor.executePost(true); assertEquals("Task0", executor.getOutgoing().getName()); diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java index 8b0710ec7..fe437b823 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -89,7 +89,7 @@ public class StateFinalizerExecutionContextTest { final Map<String, Object> fields = new LinkedHashMap<>(); final Set<String> stateOutputNames = new LinkedHashSet<>(); - StateFinalizerExecutionContext sfec = new StateFinalizerExecutionContext(stateFinalizerExecutorMock, 0, + StateFinalizerExecutionContext sfec = new StateFinalizerExecutionContext(stateFinalizerExecutorMock, 0, null, axStateMock, fields, stateOutputNames, internalContextMock); assertNotNull(sfec); diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java index c6c196a01..29c536ed4 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -87,7 +87,7 @@ public class TaskExecutionContextTest { final Map<String, Object> inFields = new LinkedHashMap<>(); final Map<String, Object> outFields = new LinkedHashMap<>(); - TaskExecutionContext tec = new TaskExecutionContext(taskExecutorMock, 0, axTaskMock, inFields, outFields, + TaskExecutionContext tec = new TaskExecutionContext(taskExecutorMock, 0, null, axTaskMock, inFields, outFields, internalContextMock); assertNotNull(tec); |