diff options
author | Mnushkin, Dmitry <dmitry.mnushkin@att.com> | 2019-07-01 08:10:54 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-07-01 08:11:00 -0400 |
commit | 5c174ddc476187b358da608c3d2ad85d512a67f7 (patch) | |
tree | 358c3bc6ce8f93be0854f7658e4df7cf2c02a7ae /bpmn | |
parent | cabd51660c3c8ec52e329027179f5c6cabb03aca (diff) |
do not overwrite status message with rollback
update rollback error for rollback and not original msg
run code formatting on updated files
add unit test for false value of isRollback flag
Change-Id: I25d8fb9771766461b1192e3758237dfc199787f8
Issue-ID: SO-2081
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn')
2 files changed, 40 insertions, 1 deletions
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 index 4d2f9fd98c..67dc9fec26 100644 --- 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 @@ -53,7 +53,12 @@ public class WorkflowActionBBFailure { } else { errorMsg = "Failed to determine error message"; } - request.setStatusMessage(errorMsg); + Boolean isRollback = (Boolean) execution.getVariable("isRollback"); + if (!Boolean.TRUE.equals(isRollback)) { + request.setStatusMessage(errorMsg); + } else { + request.setRollbackStatusMessage(errorMsg); + } request.setProgress(Long.valueOf(100)); request.setLastModifiedBy("CamundaBPMN"); request.setEndTime(new Timestamp(System.currentTimeMillis())); 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 index c683303a41..12f34eaddf 100644 --- 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 @@ -160,4 +160,38 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN"); Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class)); } + + @Test + public void updateRequestRollbackErrorStatusMessageTest() { + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + WorkflowException we = new WorkflowException("WorkflowAction", 1231, "Error Case"); + execution.setVariable("WorkflowException", we); + execution.setVariable("isRollback", true); + + doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + workflowActionBBFailure.updateRequestErrorStatusMessage(execution); + Mockito.verify(reqMock, Mockito.times(0)).setStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(1)).setRollbackStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(1)).setProgress(Long.valueOf(100)); + Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN"); + Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class)); + } + + @Test + public void updateRequestNotRollbackErrorStatusMessageTest() { + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + WorkflowException we = new WorkflowException("WorkflowAction", 1231, "Error Case"); + execution.setVariable("WorkflowException", we); + execution.setVariable("isRollback", false); + + doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + workflowActionBBFailure.updateRequestErrorStatusMessage(execution); + Mockito.verify(reqMock, Mockito.times(1)).setStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(0)).setRollbackStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(1)).setProgress(Long.valueOf(100)); + Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN"); + Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class)); + } } |