From 8ad30f496f930ac942b7fa85cda99da0b4e62494 Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Fri, 26 Jul 2019 02:34:19 -0400 Subject: Use BuildingBlockExecution for PauseForManualTasks Fix variable settings and execution object usage for manual tasks. Issue-ID: SO-2113 Signed-off-by: Kuleshov, Elena Change-Id: I3fa24d70b46658ce5afcdc843d5482e157641112 --- .../subprocess/Activity/PauseForManualTaskActivity.bpmn | 10 +++++----- .../bpmn/subprocess/PauseForManualTaskActivityTest.java | 3 ++- .../so/bpmn/infrastructure/activity/ExecuteActivity.java | 7 +++++++ .../manualhandling/tasks/ManualHandlingTasks.java | 9 +++++---- .../manualhandling/tasks/ManualHandlingTasksTest.java | 16 ++++++++++------ 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn index fb9704d294..884ec209aa 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn @@ -22,11 +22,11 @@ - + SequenceFlow_0jav6cu SequenceFlow_0b84ki5 - + SequenceFlow_192yimz SequenceFlow_14cyk9v @@ -37,12 +37,12 @@ - + SequenceFlow_0b84ki5 SequenceFlow_0igra4l - + SequenceFlow_01k6zgt SequenceFlow_16bjdgj @@ -147,4 +147,4 @@ - + \ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java index 484f9b8506..c0b0094f20 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java @@ -35,6 +35,7 @@ import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.onap.so.bpmn.BaseBPMNTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; public class PauseForManualTaskActivityTest extends BaseBPMNTest { @@ -85,7 +86,7 @@ public class PauseForManualTaskActivityTest extends BaseBPMNTest { @Test public void rainyDayPauseForManualTask_Test() throws Exception { doThrow(new BpmnError("7000", "TESTING ERRORS")).when(manualHandlingTasks) - .createExternalTicket((any(DelegateExecution.class))); + .createExternalTicket((any(BuildingBlockExecution.class))); ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskActivity", variables); assertThat(pi).isNotNull().isStarted() .hasPassedInOrder("PauseForManualTaskActivity_Start", "UpdateDbStatusToPendingManualTask", diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index 775e3213d4..638ecefa49 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.activity; +import java.io.Serializable; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -99,6 +100,12 @@ public class ExecuteActivity implements JavaDelegate { variables.put("retryCount", 1); variables.put("aLaCarte", true); + execution.getVariables().forEach((key, value) -> { + if (value instanceof Serializable) { + variables.put(key, (Serializable) value); + } + }); + ProcessInstanceWithVariables buildingBlockResult = runtimeService.createProcessInstanceByKey("ExecuteBuildingBlock").setVariables(variables) .executeWithVariablesInReturn(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java index 17089be571..7e45c3b640 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java @@ -27,6 +27,7 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateTask; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.ticket.ExternalTicket; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -46,7 +47,7 @@ public class ManualHandlingTasks { private static final String TASK_TYPE_FALLOUT = "fallout"; public static final String VNF_TYPE = "vnfType"; public static final String SERVICE_TYPE = "serviceType"; - public static final String MSO_REQUEST_ID = "msoRequestId"; + public static final String MSO_REQUEST_ID = "mso-request-id"; public static final String REQUESTOR_ID = "requestorId"; public static final String ERROR_CODE = "errorCode"; public static final String VALID_RESPONSES = "validResponses"; @@ -120,7 +121,7 @@ public class ManualHandlingTasks { String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID); String originalRequestorId = (String) execution.getVariable(REQUESTOR_ID); String description = (String) execution.getVariable(DESCRIPTION); - String timeout = (String) execution.getVariable("taskTimeout"); + String timeout = ""; String errorSource = ""; String errorCode = ""; String errorMessage = ""; @@ -188,7 +189,7 @@ public class ManualHandlingTasks { } - public void createExternalTicket(DelegateExecution execution) { + public void createExternalTicket(BuildingBlockExecution execution) { try { ExternalTicket ticket = new ExternalTicket(); @@ -218,7 +219,7 @@ public class ManualHandlingTasks { } - public void updateRequestDbStatus(DelegateExecution execution, String status) { + public void updateRequestDbStatus(BuildingBlockExecution execution, String status) { try { String requestId = (String) execution.getVariable(MSO_REQUEST_ID); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java index 9677f8e8f3..b40195c07b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java @@ -38,6 +38,8 @@ import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.db.request.beans.InfraActiveRequests; public class ManualHandlingTasksTest extends BaseTaskTest { @@ -56,11 +58,13 @@ public class ManualHandlingTasksTest extends BaseTaskTest { @Mock private DelegateTask task; - private DelegateExecution delegateExecution; + @Mock + private BuildingBlockExecution buildingBlockExecution; @Before public void before() throws Exception { delegateExecution = new DelegateExecutionFake(); + buildingBlockExecution = new DelegateExecutionImpl(delegateExecution); } @Test @@ -99,18 +103,18 @@ public class ManualHandlingTasksTest extends BaseTaskTest { @Test public void updateRequestDbStatus_Test() throws Exception { InfraActiveRequests mockedRequest = new InfraActiveRequests(); - delegateExecution.setVariable("msoRequestId", "testMsoRequestId"); + buildingBlockExecution.setVariable("mso-request-id", "msoRequestId"); when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); - manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS"); + manualHandlingTasks.updateRequestDbStatus(buildingBlockExecution, "IN_PROGRESS"); verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS"); } @Test public void createExternalTicket_Test() throws Exception { - delegateExecution.setVariable("msoRequestId", ("testMsoRequestId")); - delegateExecution.setVariable("vnfType", "testVnfType"); - manualHandlingTasks.createExternalTicket(delegateExecution); + buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId")); + buildingBlockExecution.setVariable("vnfType", "testVnfType"); + manualHandlingTasks.createExternalTicket(buildingBlockExecution); } } -- cgit 1.2.3-korg