Delays { public static long computeDelay(LocalTime expectedTime, LocalTime effectiveTime) { long result = 0; if (expectedTime != null && effectiveTime != null) { Duration duration = Duration.between(expectedTime, effectiveTime); result = duration.toMillis(); } return result; }  static long compareTimeAndDelay(TimeDelay startInclusive, TimeDelay endExclusive); static long compareTimeAndDelay(LocalTime time, TimeDelay timeDelay); static long compareTimeAndDelay(TimeDelay timeDelay, LocalTime time); static long compareTime(TimeDelay timeDelayA, TimeDelay timeDelayB); static long compareTime(TimeDelay timeDelay, LocalTime time); static long compareTime(LocalTime time, TimeDelay timeDelay); static long compareTime(LocalTime timeA, LocalTime timeB); static long computeDelay(LocalTime expectedTime, LocalTime effectiveTime); static LocalTime toLocalTime(Date date); static Long toMinutes(Long delay); static Long toMillis(Long delay); static final LocalDate DATE; }
@Test public void testComputeZeroDelay() throws Exception { LocalTime departureA = LocalTime.now(); LocalTime departureB = departureA; Assert.assertThat(Delays.computeDelay(departureA, departureB), is(equalTo(0L))); }
@Test public void testComputeNonZeroDelay() throws Exception { LocalTime departureA = LocalTime.now(); LocalTime departureB = TimeDelay.of(departureA, 15L).getEffectiveTime(); Assert.assertThat(Delays.computeDelay(departureA, departureB), is(equalTo(15L))); }