### Question:
WorkflowActionBBFailure { 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"; } 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())); 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); } }  void updateRequestStatusToFailed(DelegateExecution execution); void updateRequestStatusToFailedWithRollback(DelegateExecution execution); void abortCallErrorHandling(); static final String ROLLBACK_TARGET_STATE; }### Answer:
@Test public void updateRequestErrorStatusMessageTest() { String reqId = "reqId123"; execution.setVariable("mso-request-id", reqId); WorkflowException we = new WorkflowException("WorkflowAction", 1231, "Error Case"); execution.setVariable("WorkflowException", we); doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); workflowActionBBFailure.updateRequestErrorStatusMessage(execution); Mockito.verify(reqMock, Mockito.times(1)).setStatusMessage("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 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)); }