### Question:
OperationTimeAggregator { public ProcessTime computeOverallProcessTime(String correlationId, Map<String, ProcessTime> processTimes) { ProcessTime rootProcessTime = processTimes.get(correlationId); long overallDelayBetweenSteps = processTimes.values() .stream() .mapToLong(ProcessTime::getDelayBetweenSteps) .sum(); return ImmutableProcessTime.copyOf(rootProcessTime) .withDelayBetweenSteps(overallDelayBetweenSteps); } @Inject  OperationTimeAggregator(FlowableFacade flowableFacade); Map<String, ProcessTime> collectProcessTimes(String correlationId); ProcessTime computeOverallProcessTime(String correlationId, Map<String, ProcessTime> processTimes);  }### Answer:
@Test void testOperationTimeWithNoSubProcesses() { Map<String, ProcessTime> processTimes = new HashMap<>(); processTimes.put(CORRELATION_ID, createProcessTime(100, 200)); ProcessTime overallProcessTime = operationTimeAggregator.computeOverallProcessTime(CORRELATION_ID, processTimes); assertEquals(100, overallProcessTime.getProcessDuration()); assertEquals(200, overallProcessTime.getDelayBetweenSteps()); }
@Test void testOperationTimeWithInvalidInput() { assertThrows(NullPointerException.class, () -> operationTimeAggregator.computeOverallProcessTime(CORRELATION_ID, Collections.emptyMap())); }
@Test void testOperationTimeWithOneSubProcess() { Map<String, ProcessTime> processTimes = new HashMap<>(); processTimes.put(CORRELATION_ID, createProcessTime(100, 200)); processTimes.put("id-1", createProcessTime(50, 100)); ProcessTime overallProcessTime = operationTimeAggregator.computeOverallProcessTime(CORRELATION_ID, processTimes); assertEquals(100, overallProcessTime.getProcessDuration()); assertEquals(300, overallProcessTime.getDelayBetweenSteps()); }
@Test void testOperationTimeWithTwoSubProcesses() { Map<String, ProcessTime> processTimes = new HashMap<>(); processTimes.put(CORRELATION_ID, createProcessTime(100, 200)); processTimes.put("id-1", createProcessTime(50, 100)); processTimes.put("id-2", createProcessTime(70, 300)); ProcessTime overallProcessTime = operationTimeAggregator.computeOverallProcessTime(CORRELATION_ID, processTimes); assertEquals(100, overallProcessTime.getProcessDuration()); assertEquals(600, overallProcessTime.getDelayBetweenSteps()); }