@Test void testAbortedProcessDelayBetweenSteps() { long currentTime = mockProcessStartTime(); processTimeCalculator = new ProcessTimeCalculator(flowableFacade, () -> currentTime + 500); List<Activity> activities = List.of(Activity.of("serviceTask", 5, 500)); List<HistoricActivityInstance> processActivities = mockProcessActivities(activities); HistoricActivityInstance unfinishedActivity = Mockito.mock(HistoricActivityInstance.class); Mockito.when(unfinishedActivity.getActivityType()) .thenReturn("sequenceFlow"); Mockito.when(unfinishedActivity.getStartTime()) .thenReturn(new Date(currentTime)); processActivities.add(unfinishedActivity); Mockito.when(historicActivityInstanceQueryMock.list()) .thenReturn(processActivities); ProcessTime processTime = processTimeCalculator.calculate(PROCESS_ID); assertEquals(500, processTime.getDelayBetweenSteps()); }
public ProcessTime calculate(String processInstanceId) { HistoricProcessInstance rootProcessInstance = flowableFacade.getHistoricProcessById(processInstanceId); List<HistoricActivityInstance> processActivities = flowableFacade.getProcessEngine() .getHistoryService() .createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .list(); long processDuration = calculateProcessDuration(rootProcessInstance); long sequenceFlowsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isSequenceFlow); long timerEventsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isTimerEvent); long gatewaysTime = calculateFilteredProcessActivitiesTime(processActivities, this::isGateway); long delayBetweenActivities = getDelayBetweenActivities(processActivities); return ImmutableProcessTime.builder() .processDuration(processDuration) .delayBetweenSteps(sequenceFlowsTime + timerEventsTime + gatewaysTime + delayBetweenActivities) .build(); }
ProcessTimeCalculator { public ProcessTime calculate(String processInstanceId) { HistoricProcessInstance rootProcessInstance = flowableFacade.getHistoricProcessById(processInstanceId); List<HistoricActivityInstance> processActivities = flowableFacade.getProcessEngine() .getHistoryService() .createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .list(); long processDuration = calculateProcessDuration(rootProcessInstance); long sequenceFlowsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isSequenceFlow); long timerEventsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isTimerEvent); long gatewaysTime = calculateFilteredProcessActivitiesTime(processActivities, this::isGateway); long delayBetweenActivities = getDelayBetweenActivities(processActivities); return ImmutableProcessTime.builder() .processDuration(processDuration) .delayBetweenSteps(sequenceFlowsTime + timerEventsTime + gatewaysTime + delayBetweenActivities) .build(); } }
ProcessTimeCalculator { public ProcessTime calculate(String processInstanceId) { HistoricProcessInstance rootProcessInstance = flowableFacade.getHistoricProcessById(processInstanceId); List<HistoricActivityInstance> processActivities = flowableFacade.getProcessEngine() .getHistoryService() .createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .list(); long processDuration = calculateProcessDuration(rootProcessInstance); long sequenceFlowsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isSequenceFlow); long timerEventsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isTimerEvent); long gatewaysTime = calculateFilteredProcessActivitiesTime(processActivities, this::isGateway); long delayBetweenActivities = getDelayBetweenActivities(processActivities); return ImmutableProcessTime.builder() .processDuration(processDuration) .delayBetweenSteps(sequenceFlowsTime + timerEventsTime + gatewaysTime + delayBetweenActivities) .build(); } ProcessTimeCalculator(FlowableFacade flowableFacade);   ProcessTimeCalculator(FlowableFacade flowableFacade, LongSupplier currentTimeSupplier); }
ProcessTimeCalculator { public ProcessTime calculate(String processInstanceId) { HistoricProcessInstance rootProcessInstance = flowableFacade.getHistoricProcessById(processInstanceId); List<HistoricActivityInstance> processActivities = flowableFacade.getProcessEngine() .getHistoryService() .createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .list(); long processDuration = calculateProcessDuration(rootProcessInstance); long sequenceFlowsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isSequenceFlow); long timerEventsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isTimerEvent); long gatewaysTime = calculateFilteredProcessActivitiesTime(processActivities, this::isGateway); long delayBetweenActivities = getDelayBetweenActivities(processActivities); return ImmutableProcessTime.builder() .processDuration(processDuration) .delayBetweenSteps(sequenceFlowsTime + timerEventsTime + gatewaysTime + delayBetweenActivities) .build(); } ProcessTimeCalculator(FlowableFacade flowableFacade);   ProcessTimeCalculator(FlowableFacade flowableFacade, LongSupplier currentTimeSupplier); ProcessTime calculate(String processInstanceId); }
ProcessTimeCalculator { public ProcessTime calculate(String processInstanceId) { HistoricProcessInstance rootProcessInstance = flowableFacade.getHistoricProcessById(processInstanceId); List<HistoricActivityInstance> processActivities = flowableFacade.getProcessEngine() .getHistoryService() .createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .list(); long processDuration = calculateProcessDuration(rootProcessInstance); long sequenceFlowsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isSequenceFlow); long timerEventsTime = calculateFilteredProcessActivitiesTime(processActivities, this::isTimerEvent); long gatewaysTime = calculateFilteredProcessActivitiesTime(processActivities, this::isGateway); long delayBetweenActivities = getDelayBetweenActivities(processActivities); return ImmutableProcessTime.builder() .processDuration(processDuration) .delayBetweenSteps(sequenceFlowsTime + timerEventsTime + gatewaysTime + delayBetweenActivities) .build(); } ProcessTimeCalculator(FlowableFacade flowableFacade);   ProcessTimeCalculator(FlowableFacade flowableFacade, LongSupplier currentTimeSupplier); ProcessTime calculate(String processInstanceId);  }