Delays { public static long compareTime(TimeDelay timeDelayA, TimeDelay timeDelayB) { return compareTimeAndDelay(timeDelayA != null ? TimeDelay.of(timeDelayA.getExpectedTime()) : null, timeDelayB != null ? TimeDelay.of(timeDelayB.getExpectedTime()) : null); }  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 testCompareTime() throws Exception { LocalTime departureA = LocalTime.now(); TimeDelay departureB = TimeDelay.of(departureA, 15L); Assert.assertThat(Delays.compareTime(departureA, departureB), is(equalTo(0L))); }
@Test public void testRevertedCompareTimeGreater() throws Exception { LocalTime departureA = LocalTime.parse("14:00"); TimeDelay departureB = TimeDelay.of(LocalTime.parse("15:00"), 15L); Assert.assertThat(Delays.compareTime(departureB, departureA), is(equalTo(3600L * 1000))); }
@Test public void testCompareNullTime() throws Exception { LocalTime departureA = LocalTime.now(); TimeDelay departureB = TimeDelay.of(null, 0L); Assert.assertThat(Delays.compareTime(departureA, departureB), is(greaterThan(0L))); }
@Test public void testCompareTimeEquals() throws Exception { TimeDelay departureA = TimeDelay.of(LocalTime.parse("15:00"), 15L); TimeDelay departureB = TimeDelay.of(LocalTime.parse("15:00"), 5L); Assert.assertThat(Delays.compareTime(departureA, departureB), is(equalTo(0L))); }
@Test public void testCompareTimeGreater() throws Exception { LocalTime departureA = LocalTime.parse("15:00"); TimeDelay departureB = TimeDelay.of(LocalTime.parse("14:00"), 0L); Assert.assertThat(Delays.compareTime(departureA, departureB), is(equalTo(3600L * 1000))); }
@Test public void testCompareTimeLess() throws Exception { LocalTime departureA = LocalTime.parse("14:00"); TimeDelay departureB = TimeDelay.of(LocalTime.parse("15:00"), 0L); Assert.assertThat(Delays.compareTime(departureA, departureB), is(equalTo(-3600L * 1000))); }
@Test public void testCompareTimeWithTwoEqualsDates() throws Exception { LocalTime departureA = LocalTime.now(); Assert.assertThat(Delays.compareTime(departureA, departureA), is(equalTo(0L))); }