@Test void testOverallDelayBetweenSteps() { List<Activity> activities = List.of(Activity.of("intermediateCatchEvent", 5, 100), Activity.of("sequenceFlow", 3, 100), Activity.of("exclusiveGateway", 1, 1000), Activity.of("inclusiveGateway", 1, 1000), Activity.of("serviceTask", 5, 500)); long offset = currentTimeSupplier.getAsLong(); List<HistoricActivityInstance> processActivities = new ArrayList<>(); for (Activity activity : activities) { processActivities.addAll(mockActivitiesWithDelay(offset, activity, 10)); offset += (activity.numberOf * (activity.duration + 10)) + 10; } mockProcessStartAndEndTime(100); Mockito.when(historicActivityInstanceQueryMock.list()) .thenReturn(processActivities); ProcessTime processTime = processTimeCalculator.calculate(PROCESS_ID); assertEquals(2980, 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);  }