summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAjith Sreekumar <ajith.sreekumar@bell.ca>2021-07-06 13:33:46 +0000
committerGerrit Code Review <gerrit@onap.org>2021-07-06 13:33:46 +0000
commitd532d7b5e422ce3e4ef9f6992ef159960988be8f (patch)
tree98adda95982e0ff043dfdfa926c05606d54d6efd /core
parent6092e934c6f0014ab93304c82272efed5c4b1e30 (diff)
parent5f0ec1c2d95c377fbec428f11464e93fe442b5ef (diff)
Merge "Cleanup input & outputFields from Task definition"
Diffstat (limited to 'core')
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java45
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java2
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java3
3 files changed, 27 insertions, 23 deletions
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
index 878d5277a..d45be9652 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
@@ -50,6 +50,7 @@ import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.concepts.AxState;
import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput;
+import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType;
import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference;
import org.onap.policy.apex.model.policymodel.concepts.AxTask;
import org.slf4j.ext.XLogger;
@@ -180,26 +181,34 @@ public class ApexEngineImpl implements ApexEngine {
private void updateTaskBasedOnStateOutput(AxPolicyModel apexPolicyModel, Set<AxArtifactKey> updatedTasks,
AxState state, AxArtifactKey taskKey, AxStateTaskReference taskRef, AxTask task) {
Map<String, AxEvent> outputEvents = new TreeMap<>();
- AxStateOutput stateOutput = state.getStateOutputs().get(taskRef.getOutput().getLocalName());
- if (null == stateOutput.getOutgoingEventSet() || stateOutput.getOutgoingEventSet().isEmpty()) {
- Set<AxArtifactKey> outEventSet = new TreeSet<>();
- outEventSet.add(stateOutput.getOutgoingEvent());
- stateOutput.setOutgoingEventSet(outEventSet);
- }
- if (state.getNextStateSet().isEmpty()
- || state.getNextStateSet().contains(AxReferenceKey.getNullKey().getLocalName())) {
- stateOutput.getOutgoingEventSet().forEach(outgoingEventKey -> outputEvents.put(outgoingEventKey.getName(),
- apexPolicyModel.getEvents().get(outgoingEventKey)));
+ AxStateOutput stateOutput = null;
+ if (AxStateTaskOutputType.LOGIC.equals(taskRef.getStateTaskOutputType())) {
+ // in case of SFL, outgoing event will be same for all state outputs that are part of SFL.So, take any entry
+ stateOutput = state.getStateOutputs().values().iterator().next();
} else {
- AxArtifactKey outgoingEventKey = stateOutput.getOutgoingEvent();
- outputEvents.put(outgoingEventKey.getName(), apexPolicyModel.getEvents().get(outgoingEventKey));
+ stateOutput = state.getStateOutputs().get(taskRef.getOutput().getLocalName());
}
- if (updatedTasks.contains(taskKey)) {
- // this happens only when same task is used by multiple policies
- // with different eventName but same fields
- task.getOutputEvents().putAll(outputEvents);
- } else {
- task.setOutputEvents(outputEvents);
+ if (null != stateOutput) {
+ if (null == stateOutput.getOutgoingEventSet() || stateOutput.getOutgoingEventSet().isEmpty()) {
+ Set<AxArtifactKey> outEventSet = new TreeSet<>();
+ outEventSet.add(stateOutput.getOutgoingEvent());
+ stateOutput.setOutgoingEventSet(outEventSet);
+ }
+ if (state.getNextStateSet().isEmpty()
+ || state.getNextStateSet().contains(AxReferenceKey.getNullKey().getLocalName())) {
+ stateOutput.getOutgoingEventSet().forEach(outgoingEventKey -> outputEvents
+ .put(outgoingEventKey.getName(), apexPolicyModel.getEvents().get(outgoingEventKey)));
+ } else {
+ AxArtifactKey outgoingEventKey = stateOutput.getOutgoingEvent();
+ outputEvents.put(outgoingEventKey.getName(), apexPolicyModel.getEvents().get(outgoingEventKey));
+ }
+ if (updatedTasks.contains(taskKey)) {
+ // this happens only when same task is used by multiple policies
+ // with different eventName but same fields
+ task.getOutputEvents().putAll(outputEvents);
+ } else {
+ task.setOutputEvents(outputEvents);
+ }
}
}
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 1ddc3f5b5..4160a9f19 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
@@ -125,8 +125,6 @@ public class TaskExecutorTest {
Mockito.doReturn(true).when(axOptionalOutputFieldMock).getOptional();
Mockito.doReturn(false).when(axMissingOutputFieldMock).getOptional();
- Mockito.doReturn(inFieldMap).when(axTaskMock).getInputFields();
- Mockito.doReturn(outFieldMap).when(axTaskMock).getOutputFields();
Mockito.doReturn(taskLogicMock).when(axTaskMock).getTaskLogic();
Mockito.doReturn(inEvent).when(axTaskMock).getInputEvent();
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java
index 6f8402e55..9da8ecfad 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java
@@ -99,9 +99,6 @@ public class AxTaskFacadeTest {
Mockito.doReturn(inEvent).when(axTaskMock).getInputEvent();
Mockito.doReturn(outEvents).when(axTaskMock).getOutputEvents();
- Mockito.doReturn(inFieldMap).when(axTaskMock).getInputFields();
- Mockito.doReturn(outFieldMap).when(axTaskMock).getOutputFields();
-
Mockito.doReturn(new AxReferenceKey(task0Key, "InField0")).when(axInputFieldMock).getKey();
Mockito.doReturn(stringTypeKey).when(axInputFieldMock).getSchema();