### Question:
FlowCompletionTasks { public void updateRequestDbStatus(BuildingBlockExecution execution) { try { String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId(); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); if (workflowException == null) { request.setStatusMessage("RequestCompletedSuccessfully"); request.setRequestStatus("COMPLETE"); } else { request.setStatusMessage(workflowException.getErrorMessage()); request.setRequestStatus("FAILED"); } request.setProgress(100L); request.setLastModifiedBy("CamundaBPMN"); requestDbclient.updateInfraActiveRequests(request); } catch (Exception e) { logger.error("Unable to save the updated request status to the DB", e); } }  void updateRequestDbStatus(BuildingBlockExecution execution);  }### Answer:
@Test public void updateRequestDbStatusComplete_Test() throws Exception { InfraActiveRequests mockedRequest = new InfraActiveRequests(); when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); flowCompletionTasks.updateRequestDbStatus(execution); verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); assertEquals(mockedRequest.getRequestStatus(), "COMPLETE"); }
@Test public void updateRequestDbStatusFailed_Test() throws Exception { WorkflowException workflowException = new WorkflowException("testProcessKey", 7000, "Error"); execution.setVariable("WorkflowException", workflowException); InfraActiveRequests mockedRequest = new InfraActiveRequests(); when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); flowCompletionTasks.updateRequestDbStatus(execution); verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); assertEquals(mockedRequest.getRequestStatus(), "FAILED"); }