From aced60c11508e1267580492b95372f0b088e2ad9 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Sat, 29 May 2021 06:48:46 -0400 Subject: Enable WorkflowActionBB to skip last building block WorkflowActionBB does not take into account flowmanipulators such as SkipCDSBuildingBlockListener, which increment the current index of building blocks to execute. In the case where ControllerExecutionBB is the last building block and should be skipped, the index would be incremented beyond bounds and cause exception. WorkflowActionBB needs to check if the flow has been completed before it tries to execute the next building block. Issue-ID: SO-3678 Change-Id: I635c12a568c3b98031cbeb37ef521663d96b852b Signed-off-by: Jozsef Csongvai --- .../workflow/tasks/WorkflowActionBBTasks.java | 19 ++++++++++++------- .../workflow/tasks/WorkflowActionBBTasksTest.java | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'bpmn/so-bpmn-tasks') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index cd151bafea..b76cf1eb5f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -111,13 +111,15 @@ public class WorkflowActionBBTasks { } int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); - - execution.setVariable("buildingBlock", ebb); - currentSequence++; - execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size()); - execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence); - + boolean completed = false; + if (currentSequence < flowsToExecute.size()) { + ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); + execution.setVariable("buildingBlock", ebb); + execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence + 1); + } else { + completed = true; + } + execution.setVariable(COMPLETED, completed); } catch (Exception e) { workflowAction.buildAndThrowException(execution, "Internal Error occured during selectBB", e); } @@ -425,6 +427,9 @@ public class WorkflowActionBBTasks { final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE); int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); logger.debug("Current Sequence: {}", currentSequence); + if (currentSequence >= flowsToExecute.size()) { + execution.setVariable(COMPLETED, true); + } ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1); String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName(); if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 5cd3055b5f..cbb746d514 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -149,7 +149,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { workflowActionBBTasks.selectBB(execution); boolean success = (boolean) execution.getVariable("completed"); int currentSequence = (int) execution.getVariable("gCurrentSequence"); - assertTrue(success); + assertFalse(success); assertEquals(1, currentSequence); } -- cgit 1.2.3-korg