aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGamboa, Gilbert <gilbert.g.gamboa@att.com>2019-10-24 14:33:12 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-11-04 14:02:58 -0500
commit0eac9a23fb2e79f3c996664cf6d6f02e1573dadc (patch)
treec38c3f67666c49e62ffe27e798b5d319ffbed353
parent4ec5384dc1fac74d0fde85a4c941fe7aba233069 (diff)
Call WorkflowActionTasks.sendErrorSyncAck()
Call WorkflowActionTasks.sendErrorSyncAck() instead of WorkflowActionTasks.sendSyncAck() from WorkflowActionBB in error handling subroutine. Call WorkflowActionTasks.sendErrorSyncAck() instead of WorkflowActionTasks.sendSyncAck() from WorkflowActionBB in error handling subroutine. Issue-ID: SO-2489 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I8c1c2bb6af70d5e76cfbfd3ce54fb506ab653cf7
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java8
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java59
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn2
3 files changed, 66 insertions, 3 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
index ace6e1937d..4fb63651eb 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
@@ -102,7 +102,11 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables));
processor.startProcess(processKey, variableMap);
WorkflowResponse response = waitForResponse(inputVariables);
- return Response.status(202).entity(response).build();
+ if (response.getMessageCode() == 500) {
+ return Response.status(500).entity(response).build();
+ } else {
+ return Response.status(202).entity(response).build();
+ }
} catch (WorkflowProcessorException e) {
WorkflowResponse response = e.getWorkflowResponse();
return Response.status(500).entity(response).build();
@@ -112,7 +116,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
}
}
- private WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception {
+ protected WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception {
String requestId = getRequestId(inputVariables);
long currentWaitTime = 0;
long waitTime = getWaitTime(inputVariables);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java
new file mode 100644
index 0000000000..df9a23019a
--- /dev/null
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java
@@ -0,0 +1,59 @@
+package org.onap.so.bpmn.common.workflow.service;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.ArgumentMatchers.anyMap;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.core.Response;
+import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
+
+@RunWith(MockitoJUnitRunner.class)
+public class WorkflowAsyncResourceTest {
+
+ @InjectMocks
+ @Spy
+ private WorkflowAsyncResource workflowAsyncResource;
+
+ @Mock
+ private WorkflowProcessor processor;
+
+ private WorkflowResponse workflowResponse;
+ private VariableMapImpl varMap;
+
+ @Before
+ public void before() {
+ workflowResponse = new WorkflowResponse();
+ varMap = new VariableMapImpl();
+ Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> requestIdMap = new HashMap<String, Object>();
+ requestIdMap.put("value", "123");
+ requestIdMap.put("type", "String");
+ variables.put("mso-request-id", requestIdMap);
+ varMap.put("variables", variables);
+ }
+
+ @Test
+ public void startProcessInstanceByKey200Test() throws Exception {
+ workflowResponse.setMessageCode(200);
+ doReturn(workflowResponse).when(workflowAsyncResource).waitForResponse(anyMap());
+ Response response = workflowAsyncResource.startProcessInstanceByKey("123", varMap);
+ assertEquals(202, response.getStatus());
+ }
+
+ @Test
+ public void startProcessInstanceByKey500Test() throws Exception {
+ workflowResponse.setMessageCode(500);
+ doReturn(workflowResponse).when(workflowAsyncResource).waitForResponse(anyMap());
+ Response response = workflowAsyncResource.startProcessInstanceByKey("123", varMap);
+ assertEquals(500, response.getStatus());
+ }
+}
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn
index e112fdc161..f2e0ce29ff 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn
@@ -89,7 +89,7 @@
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==true&amp;&amp;execution.getVariable("sentSyncResponse")==false}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_0eana0l" sourceRef="Task_SendSyncAckError" targetRef="Task_UpdateDb" />
- <bpmn:serviceTask id="Task_SendSyncAckError" name="Send Sync Ack API Handler" camunda:asyncAfter="true" camunda:expression="${WorkflowActionBBTasks.sendSyncAck(execution)}">
+ <bpmn:serviceTask id="Task_SendSyncAckError" name="Send Sync Ack API Handler" camunda:asyncAfter="true" camunda:expression="${WorkflowActionBBTasks.sendErrorSyncAck(execution)}">
<bpmn:incoming>SequenceFlow_0vi883o</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0eana0l</bpmn:outgoing>
</bpmn:serviceTask>