### Question:
ProcessHelper { public Operation.State computeProcessState(String processId) { if (isInAbortedState(processId)) { return State.ABORTED; } if (isInErrorState(processId)) { return State.ERROR; } if (isInReceiveTask(processId)) { return State.ACTION_REQUIRED; } if (isInRunningState(processId)) { return State.RUNNING; } return State.FINISHED; } @Inject  ProcessHelper(FlowableFacade flowableFacade, HistoricOperationEventService historicOperationEventService); Operation.State computeProcessState(String processId); List<HistoricOperationEvent> getHistoricOperationEventByProcessId(String processId);  }### Answer:
@Test void testIsProcessAtReceiveTask() { Mockito.when(flowableFacade.isProcessInstanceAtReceiveTask(PROCESS_ID)) .thenReturn(true); Assertions.assertEquals(State.ACTION_REQUIRED, processHelper.computeProcessState(PROCESS_ID)); }
@Test void testIsProcessInErrorState() { Mockito.when(flowableFacade.hasDeadLetterJobs(PROCESS_ID)) .thenReturn(true); Assertions.assertEquals(State.ERROR, processHelper.computeProcessState(PROCESS_ID)); }
@Test void testIsProcessAbortedWhenThereIsAbortedProcess() { Mockito.when(historicOperationEventQuery.list()) .thenReturn(List.of(ImmutableHistoricOperationEvent.builder() .type(HistoricOperationEvent.EventType.ABORTED) .processId(PROCESS_ID) .build())); Assertions.assertEquals(State.ABORTED, processHelper.computeProcessState(PROCESS_ID)); }
@Test void testIsProcessAbortedWhenThereIsNotAbortedProcess() { mockHistoricEventsWithTypes(HistoricOperationEvent.EventType.FINISHED); Assertions.assertEquals(State.FINISHED, processHelper.computeProcessState(PROCESS_ID)); }