From 5c174ddc476187b358da608c3d2ad85d512a67f7 Mon Sep 17 00:00:00 2001 From: "Mnushkin, Dmitry" Date: Mon, 1 Jul 2019 08:10:54 -0400 Subject: 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) --- .../workflow/tasks/WorkflowActionBBFailure.java | 7 ++++- .../tasks/WorkflowActionBBFailureTest.java | 34 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'bpmn/so-bpmn-tasks') 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)); + } } -- cgit 1.2.3-korg