set multi-stage flag in listener to log success 34/92034/1
authorBenjamin, Max <max.benjamin@att.com>
Thu, 25 Jul 2019 17:36:18 +0000 (13:36 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Thu, 25 Jul 2019 17:36:18 +0000 (13:36 -0400)
fixed null pointer error when multistage not set

Issue-ID: SO-2159
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I1f2313d074bea404776877ef56607a814e46e514

bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java

index 376a27e..4cde9c1 100644 (file)
@@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners;
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import org.onap.so.bpmn.common.BBConstants;
 import org.onap.so.bpmn.common.BuildingBlockExecution;
 import org.onap.so.bpmn.common.listener.db.PostCompletionRequestsDbListener;
@@ -55,7 +56,7 @@ public class MultiStageSkipListener implements FlowManipulator, PostCompletionRe
     @Override
     public boolean shouldRunFor(BuildingBlockExecution execution) {
 
-        return (boolean) execution.getVariable(G_MULTI_STAGE_DESIGN);
+        return (boolean) Optional.ofNullable(execution.getVariable(G_MULTI_STAGE_DESIGN)).orElse(false);
     }
 
     @Override
index 9e2eac4..82d610f 100644 (file)
@@ -77,6 +77,8 @@ public class MultiStageSkipListenerTest {
         execution.setVariable("multiStageDesign", false);
         assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution));
 
+        execution.setVariable("multiStageDesign", null);
+        assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution));
 
     }