summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn8
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java4
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java116
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java102
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java126
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java38
7 files changed, 267 insertions, 129 deletions
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 4b075d403b..2ca9437e9b 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
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2">
<bpmn:process id="WorkflowActionBB" name="WorkflowActionBB" isExecutable="true">
<bpmn:startEvent id="Start_WorkflowActionBB" name="start">
<bpmn:outgoing>SequenceFlow_15s0okp</bpmn:outgoing>
@@ -79,7 +79,7 @@
<bpmn:endEvent id="ErrorEnd" name="end">
<bpmn:incoming>SequenceFlow_0wvzfgf</bpmn:incoming>
</bpmn:endEvent>
- <bpmn:serviceTask id="Task_UpdateDb" name="Update Request To Failed" camunda:expression="${WorkflowActionBBTasks.updateRequestStatusToFailed(execution)}">
+ <bpmn:serviceTask id="Task_UpdateDb" name="Update Request To Failed" camunda:expression="${WorkflowActionBBFailure.updateRequestStatusToFailed(execution)}">
<bpmn:incoming>SequenceFlow_024g0d1</bpmn:incoming>
<bpmn:incoming>SequenceFlow_0eana0l</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0wvzfgf</bpmn:outgoing>
@@ -116,7 +116,7 @@
<bpmn:sequenceFlow id="SequenceFlow_11530ei" name="Abort = true" sourceRef="ExclusiveGateway_Finished" targetRef="ExclusiveGateway_isTopLevelFlowAbort">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("handlingCode")=="Abort"}]]></bpmn:conditionExpression>
</bpmn:sequenceFlow>
- <bpmn:serviceTask id="Task_AbortAndCallErrorHandling" name="Update Request To Failed" camunda:expression="${WorkflowActionBBTasks.updateRequestStatusToFailed(execution)}">
+ <bpmn:serviceTask id="Task_AbortAndCallErrorHandling" name="Update Request To Failed" camunda:expression="${WorkflowActionBBFailure.updateRequestStatusToFailed(execution)}">
<bpmn:incoming>SequenceFlow_02ksbt0</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1p8yxu6</bpmn:outgoing>
</bpmn:serviceTask>
@@ -164,7 +164,7 @@
<bpmn:sequenceFlow id="SequenceFlow_11dlyzt" name="Rollback Not Needed" sourceRef="Task_RollbackExecutionPath" targetRef="Task_UpdateRequestToFailed">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isRollbackNeeded")==false}]]></bpmn:conditionExpression>
</bpmn:sequenceFlow>
- <bpmn:serviceTask id="Task_UpdateRequestToFailed" name="Update Request To Failed" camunda:expression="${WorkflowActionBBTasks.updateRequestStatusToFailedWithRollback(execution)}">
+ <bpmn:serviceTask id="Task_UpdateRequestToFailed" name="Update Request To Failed" camunda:expression="${WorkflowActionBBFailure.updateRequestStatusToFailedWithRollback(execution)}">
<bpmn:incoming>SequenceFlow_11dlyzt</bpmn:incoming>
<bpmn:incoming>SequenceFlow_0l7kaba</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1ui67mc</bpmn:outgoing>
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
index f9ff28a023..1e3f175cf1 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
@@ -68,6 +68,7 @@ import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCUnassignTasks;
import org.onap.so.bpmn.infrastructure.workflow.tasks.FlowCompletionTasks;
import org.onap.so.bpmn.infrastructure.workflow.tasks.OrchestrationStatusValidator;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowAction;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBFailure;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBTasks;
import org.onap.so.bpmn.sdno.tasks.SDNOHealthCheckTasks;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
@@ -219,6 +220,9 @@ public abstract class BaseBPMNTest {
@MockBean
protected SniroHomingV2 sniroHoming;
+
+ @MockBean
+ protected WorkflowActionBBFailure workflowActionBBFailure;
@LocalServerPort
protected int port;
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java
index 5da6d3a577..45dafbe606 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java
@@ -92,7 +92,7 @@ public class WorkflowActionBBTest extends BaseBPMNTest {
Map<String, String> map = new HashMap<>();
map.put("handlingCode", "Abort");
- doThrow(new BpmnError("7000", "TESTING ERRORS")).when(workflowActionBBTasks).abortCallErrorHandling(any(DelegateExecution.class));
+ doThrow(new BpmnError("7000", "TESTING ERRORS")).when(workflowActionBBFailure).abortCallErrorHandling(any(DelegateExecution.class));
mockSubprocess("ExecuteBuildingBlock", "Mocked ExecuteBuildingBlock", "GenericStub", map);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("WorkflowActionBB", variables);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
new file mode 100644
index 0000000000..7e6eb2a23d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
@@ -0,0 +1,116 @@
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import java.util.Optional;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class WorkflowActionBBFailure {
+
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBFailure.class);
+ @Autowired
+ private RequestsDbClient requestDbclient;
+ @Autowired
+ private WorkflowAction workflowAction;
+
+ protected void updateRequestErrorStatusMessage(DelegateExecution execution) {
+ try {
+ String requestId = (String) execution.getVariable("mso-request-id");
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ String errorMsg = "";
+ Optional<String> errorMsgOp = retrieveErrorMessage(execution);
+ if(errorMsgOp.isPresent()){
+ errorMsg = errorMsgOp.get();
+ }else{
+ errorMsg = "Failed to determine error message";
+ }
+ request.setStatusMessage(errorMsg);
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception e) {
+ logger.error("Failed to update Request db with the status message after retry or rollback has been initialized.",e);
+ }
+ }
+
+ public void updateRequestStatusToFailed(DelegateExecution execution) {
+ try {
+ String requestId = (String) execution.getVariable("mso-request-id");
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ String rollbackErrorMsg = "";
+ String errorMsg = "";
+ Boolean rollbackCompletedSuccessfully = (Boolean) execution.getVariable("isRollbackComplete");
+ Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
+
+ if(rollbackCompletedSuccessfully==null)
+ rollbackCompletedSuccessfully = false;
+
+ if(isRollbackFailure==null)
+ isRollbackFailure = false;
+
+ if(rollbackCompletedSuccessfully){
+ rollbackErrorMsg = "Rollback has been completed successfully.";
+ request.setRollbackStatusMessage(rollbackErrorMsg);
+ execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
+ }else if(isRollbackFailure){
+ Optional<String> rollbackErrorMsgOp = retrieveErrorMessage(execution);
+ if(rollbackErrorMsgOp.isPresent()){
+ rollbackErrorMsg = rollbackErrorMsgOp.get();
+ }else{
+ rollbackErrorMsg = "Failed to determine rollback error message.";
+ }
+ request.setRollbackStatusMessage(rollbackErrorMsg);
+ execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
+ }else{
+ Optional<String> errorMsgOp = retrieveErrorMessage(execution);
+ if(errorMsgOp.isPresent()){
+ errorMsg = errorMsgOp.get();
+ }else{
+ errorMsg = "Failed to determine error message";
+ }
+ request.setStatusMessage(errorMsg);
+ execution.setVariable("ErrorMessage", errorMsg);
+ }
+ request.setProgress(Long.valueOf(100));
+ request.setRequestStatus("FAILED");
+ request.setLastModifiedBy("CamundaBPMN");
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception e) {
+ workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e);
+ }
+ }
+
+ private Optional<String> retrieveErrorMessage (DelegateExecution execution){
+ String errorMsg = "";
+ try {
+ WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
+ if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){
+ errorMsg = exception.getErrorMessage();
+ }
+ if(errorMsg == null || errorMsg.equals("")){
+ errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage");
+ }
+ return Optional.of(errorMsg);
+ } catch (Exception ex) {
+ logger.error("Failed to extract workflow exception from execution.",ex);
+ }
+ return Optional.of(errorMsg);
+ }
+
+ public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) {
+ execution.setVariable("isRollbackComplete", true);
+ updateRequestStatusToFailed(execution);
+ }
+
+ public void abortCallErrorHandling(DelegateExecution execution) {
+ String msg = "Flow has failed. Rainy day handler has decided to abort the process.";
+ logger.error(msg);
+ throw new BpmnError(msg);
+ }
+}
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 7670e0245d..d9125e4104 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
@@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -57,6 +58,8 @@ public class WorkflowActionBBTasks {
private RequestsDbClient requestDbclient;
@Autowired
private WorkflowAction workflowAction;
+ @Autowired
+ private WorkflowActionBBFailure workflowActionBBFailure;
public void selectBB(DelegateExecution execution) {
List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution
@@ -207,7 +210,7 @@ public class WorkflowActionBBTasks {
String retryDuration = (String) execution.getVariable("RetryDuration");
int retryCount = (int) execution.getVariable(RETRY_COUNT);
if (handlingCode.equals("Retry")){
- updateRequestErrorStatusMessage(execution);
+ workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
try{
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
request.setRetryStatusMessage("Retry " + retryCount+1 + "/5 will be started in " + retryDuration);
@@ -267,7 +270,7 @@ public class WorkflowActionBBTasks {
}
}
- updateRequestErrorStatusMessage(execution);
+ workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
if (rollbackFlows.isEmpty())
execution.setVariable("isRollbackNeeded", false);
@@ -282,99 +285,4 @@ public class WorkflowActionBBTasks {
workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
}
}
-
- protected void updateRequestErrorStatusMessage(DelegateExecution execution) {
- try {
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- String errorMsg = retrieveErrorMessage(execution);
- if(errorMsg == null || errorMsg.equals("")){
- errorMsg = "Failed to determine error message";
- }
- request.setStatusMessage(errorMsg);
- logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg);
- requestDbclient.updateInfraActiveRequests(request);
- } catch (Exception e) {
- logger.error("Failed to update Request db with the status message after retry or rollback has been initialized.",e);
- }
- }
-
- public void abortCallErrorHandling(DelegateExecution execution) {
- String msg = "Flow has failed. Rainy day handler has decided to abort the process.";
- logger.error(msg);
- throw new BpmnError(msg);
- }
-
- public void updateRequestStatusToFailed(DelegateExecution execution) {
- try {
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- String errorMsg = null;
- String rollbackErrorMsg = null;
- Boolean rollbackCompleted = (Boolean) execution.getVariable("isRollbackComplete");
- Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
-
- if(rollbackCompleted==null)
- rollbackCompleted = false;
-
- if(isRollbackFailure==null)
- isRollbackFailure = false;
-
- if(rollbackCompleted){
- rollbackErrorMsg = "Rollback has been completed successfully.";
- request.setRollbackStatusMessage(rollbackErrorMsg);
- logger.debug("Updating RequestDB to failed: Rollback has been completed successfully");
- }else{
- if(isRollbackFailure){
- rollbackErrorMsg = retrieveErrorMessage(execution);
- if(rollbackErrorMsg == null || rollbackErrorMsg.equals("")){
- rollbackErrorMsg = "Failed to determine rollback error message.";
- }
- request.setRollbackStatusMessage(rollbackErrorMsg);
- logger.debug("Updating RequestDB to failed: rollbackErrorMsg = " + rollbackErrorMsg);
- }else{
- errorMsg = retrieveErrorMessage(execution);
- if(errorMsg == null || errorMsg.equals("")){
- errorMsg = "Failed to determine error message";
- }
- request.setStatusMessage(errorMsg);
- logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg);
- }
- }
- request.setProgress(Long.valueOf(100));
- request.setRequestStatus("FAILED");
- request.setLastModifiedBy("CamundaBPMN");
- requestDbclient.updateInfraActiveRequests(request);
- } catch (Exception e) {
- workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e);
- }
- }
-
- private String retrieveErrorMessage (DelegateExecution execution){
- String errorMsg = "";
- try {
- WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
- if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){
- errorMsg = exception.getErrorMessage();
- }
- } catch (Exception ex) {
- //log error and attempt to extact WorkflowExceptionMessage
- logger.error("Failed to extract workflow exception from execution.",ex);
- }
-
- if (errorMsg == null){
- try {
- errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage");
- } catch (Exception ex) {
- logger.error("Failed to extract workflow exception message from WorkflowException",ex);
- errorMsg = "Unexpected Error in BPMN.";
- }
- }
- return errorMsg;
- }
-
- public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) {
- execution.setVariable("isRollbackComplete", true);
- updateRequestStatusToFailed(execution);
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
new file mode 100644
index 0000000000..d9a7eeb8f7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -0,0 +1,126 @@
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+
+public class WorkflowActionBBFailureTest extends BaseTaskTest {
+
+ @Mock
+ protected WorkflowAction workflowAction;
+
+ @InjectMocks
+ @Spy
+ protected WorkflowActionBBFailure workflowActionBBFailure;
+
+ @Mock
+ InfraActiveRequests reqMock;
+
+ private DelegateExecution execution;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), isA(Customer.class))).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
+
+ @Test
+ public void updateRequestStatusToFailed_Null_Rollback(){
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("retryCount", 3);
+ execution.setVariable("handlingCode","Success");
+ execution.setVariable("gCurrentSequence",1);
+ WorkflowException we = new WorkflowException("WorkflowAction",1231,"Error Case");
+ execution.setVariable("WorkflowException",we);
+
+ doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ Mockito.verify( reqMock, Mockito.times(1)).setStatusMessage("Error Case");
+ Mockito.verify( reqMock, Mockito.times(1)).setRequestStatus("FAILED");
+ Mockito.verify( reqMock, Mockito.times(1)).setProgress(Long.valueOf(100));
+ Mockito.verify( reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN");
+ }
+
+ @Test
+ public void updateRequestStatusToFailed(){
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", false);
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in test case");
+ execution.setVariable("WorkflowException", wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("ErrorMessage");
+ assertEquals("error in test case", errorMsg);
+ }
+
+ @Test
+ public void updateRequestStatusToFailedRollback(){
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", true);
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ execution.setVariable("WorkflowException", wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
+ assertEquals("error in rollback", errorMsg);
+ }
+
+ @Test
+ public void updateRequestStatusToFailedRollbackCompleted(){
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", true);
+ execution.setVariable("isRollback", true);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
+ assertEquals("Rollback has been completed successfully.", errorMsg);
+ }
+
+ @Test
+ public void updateRequestStatusToFailedNoWorkflowException(){
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", false);
+ execution.setVariable("WorkflowExceptionErrorMessage", "error in test case");
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("ErrorMessage");
+ assertEquals("error in test case", errorMsg);
+ }
+}
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 0ef764ac99..189ecb96c7 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
@@ -52,6 +52,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
@Mock
protected WorkflowAction workflowAction;
+ @Mock
+ protected WorkflowActionBBFailure workflowActionBBFailure;
+
@InjectMocks
@Spy
protected WorkflowActionBBTasks workflowActionBBTasks;
@@ -146,8 +149,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable("gCurrentSequence", 3);
- doNothing().when(workflowActionBBTasks).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
workflowActionBBTasks.rollbackExecutionPath(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateVfModuleBB");
@@ -179,8 +182,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable("gCurrentSequence", 2);
- doNothing().when(workflowActionBBTasks).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
workflowActionBBTasks.rollbackExecutionPath(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
@@ -217,8 +220,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable("gCurrentSequence", 3);
- doNothing().when(workflowActionBBTasks).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
workflowActionBBTasks.rollbackExecutionPath(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
@@ -255,7 +258,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable("gCurrentSequence", 3);
- doNothing().when(workflowActionBBTasks).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
workflowActionBBTasks.rollbackExecutionPath(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
@@ -267,7 +270,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
public void checkRetryStatusTest(){
String reqId = "reqId123";
execution.setVariable("mso-request-id", reqId);
- doNothing().when(workflowActionBBTasks).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
execution.setVariable("handlingCode","Retry");
execution.setVariable("retryCount", 1);
execution.setVariable("gCurrentSequence",1);
@@ -289,23 +292,4 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
workflowActionBBTasks.checkRetryStatus(execution);
assertEquals(0,execution.getVariable("retryCount"));
}
-
-
- @Test
- public void updateRequestStatusToFailed_Null_Rollback(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("retryCount", 3);
- execution.setVariable("handlingCode","Success");
- execution.setVariable("gCurrentSequence",1);
- WorkflowException we = new WorkflowException("WorkflowAction",1231,"Error Case");
- execution.setVariable("WorkflowException",we);
-
- doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- workflowActionBBTasks.updateRequestStatusToFailed(execution);
- Mockito.verify( reqMock, Mockito.times(1)).setStatusMessage("Error Case");
- Mockito.verify( reqMock, Mockito.times(1)).setRequestStatus("FAILED");
- Mockito.verify( reqMock, Mockito.times(1)).setProgress(Long.valueOf(100));
- Mockito.verify( reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN");
- }
}