Deadline implements Comparable<Deadline> { public static Deadline after(long duration, TimeUnit units) { return after(duration, units, SYSTEM_TICKER); } private  Deadline(Ticker ticker, long offset, boolean baseInstantAlreadyExpired); private  Deadline(Ticker ticker, long baseInstant, long offset,
      boolean baseInstantAlreadyExpired); static Deadline after(long duration, TimeUnit units); boolean isExpired(); boolean isBefore(Deadline other); Deadline minimum(Deadline other); Deadline offset(long offset, TimeUnit units); long timeRemaining(TimeUnit unit); ScheduledFuture<?> runOnExpiration(Runnable task, ScheduledExecutorService scheduler); @Override String toString(); @Override int compareTo(Deadline that);  }
@Test public void compareTo_greater() { Deadline d1 = Deadline.after(10, TimeUnit.SECONDS, ticker); ticker.increment(1, TimeUnit.NANOSECONDS); Deadline d2 = Deadline.after(10, TimeUnit.SECONDS, ticker); Truth.assertThat(d2).isGreaterThan(d1); }
@Test public void compareTo_less() { Deadline d1 = Deadline.after(10, TimeUnit.SECONDS, ticker); ticker.increment(1, TimeUnit.NANOSECONDS); Deadline d2 = Deadline.after(10, TimeUnit.SECONDS, ticker); Truth.assertThat(d1).isLessThan(d2); }
@Test public void compareTo_same() { Deadline d1 = Deadline.after(10, TimeUnit.SECONDS, ticker); Deadline d2 = Deadline.after(10, TimeUnit.SECONDS, ticker); Truth.assertThat(d1).isEquivalentAccordingToCompareTo(d2); }