diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java | 4 | ||||
-rw-r--r-- | bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java | 18 | ||||
-rw-r--r-- | bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java) | 19 |
3 files changed, 38 insertions, 3 deletions
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 a17556f091..073dead8b3 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 @@ -28,6 +28,7 @@ import javax.persistence.EntityNotFoundException; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.aai.domain.yang.Vnfc; import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse; import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; @@ -81,6 +82,8 @@ public class WorkflowActionBBTasks { private CatalogDbClient catalogDbClient; @Autowired private FlowManipulatorListenerRunner flowManipulatorListenerRunner; + @Autowired + private RequestsDbListenerRunner requestsDbListener; public void selectBB(DelegateExecution execution) { List<ExecuteBuildingBlock> flowsToExecute = @@ -225,6 +228,7 @@ public class WorkflowActionBBTasks { request.setProgress(Long.valueOf(100)); request.setRequestStatus("COMPLETE"); request.setLastModifiedBy("CamundaBPMN"); + requestsDbListener.post(request, new DelegateExecutionImpl(execution)); requestDbclient.updateInfraActiveRequests(request); } catch (Exception ex) { workflowAction.buildAndThrowException(execution, "Error Updating Request Database", ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java index fd0de086ad..376a27e830 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java @@ -24,16 +24,18 @@ import java.util.Collections; import java.util.List; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.db.PostCompletionRequestsDbListener; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class MultiStageSkipListener implements FlowManipulator { +public class MultiStageSkipListener implements FlowManipulator, PostCompletionRequestsDbListener { @Autowired protected BBInputSetupUtils bbInputSetupUtils; @@ -41,12 +43,21 @@ public class MultiStageSkipListener implements FlowManipulator { @Autowired private CatalogDbClient catalogDbClient; + private static final String G_MULTI_STAGE_DESIGN = "multiStageDesign"; + @Override public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { return ((boolean) execution.getVariable(BBConstants.G_ALACARTE)) && "AssignVfModuleBB".equals(currentBBName) && isFirst; } + + @Override + public boolean shouldRunFor(BuildingBlockExecution execution) { + + return (boolean) execution.getVariable(G_MULTI_STAGE_DESIGN); + } + @Override public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) { @@ -61,10 +72,15 @@ public class MultiStageSkipListener implements FlowManipulator { if (vnfCust != null && vnfCust.getMultiStageDesign() != null && vnfCust.getMultiStageDesign().equalsIgnoreCase("true")) { flowsToExecute.retainAll(Collections.singletonList(currentBB)); + execution.setVariable(G_MULTI_STAGE_DESIGN, Boolean.valueOf(vnfCust.getMultiStageDesign())); } } } } + @Override + public void run(InfraActiveRequests request, BuildingBlockExecution execution) { + request.setFlowStatus("Successfully completed Assign Building Block only due to multi-stage-design VNF"); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java index b6f8aafa55..9e2eac416c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java @@ -36,16 +36,16 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.bpmn.infrastructure.workflow.tasks.listeners.MultiStageSkipListener; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; @RunWith(MockitoJUnitRunner.class) -public class MultiStageSkipTest { +public class MultiStageSkipListenerTest { @Mock private CatalogDbClient catalogDbClient; @@ -71,6 +71,12 @@ public class MultiStageSkipTest { assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB2", true, execution)); + execution.setVariable("multiStageDesign", true); + assertTrue("should be triggered", multiStageSkipListener.shouldRunFor(execution)); + + execution.setVariable("multiStageDesign", false); + assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution)); + } @@ -107,6 +113,15 @@ public class MultiStageSkipTest { assertEquals("Flows should only have Assign", flowsToExecute.size(), 1); assertEquals("Flows should only have Assign", flowsToExecute.get(0).getBuildingBlock().getBpmnFlowName(), "AssignVfModuleBB"); + } + + @Test + public void postCompletionRequestsDbListenerTest() { + InfraActiveRequests request = new InfraActiveRequests(); + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); + multiStageSkipListener.run(request, execution); + assertEquals("Successfully completed Assign Building Block only due to multi-stage-design VNF", + request.getFlowStatus()); } } |