class 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();
    }

    public  ProcessTimeCalculator(FlowableFacade flowableFacade);
      ProcessTimeCalculator(FlowableFacade flowableFacade, LongSupplier currentTimeSupplier);

}