ValidLease implements Lease { boolean expiresBefore(ValidLease newLease) { return leaseExpiry - newLease.leaseExpiry < 0; } ValidLease(long leaseExpiry); @Override boolean isExpired(long now); @Override boolean allowRenewal(); @Override String toString();  }
@Test public void compareTheExpiryOnTwoLeases() { ValidLease lease1 = new ValidLease(10L); ValidLease lease2 = new ValidLease(20L); assertTrue(lease1.expiresBefore(lease2)); assertFalse(lease2.expiresBefore(lease1)); assertFalse(lease1.expiresBefore(lease1)); assertFalse(lease2.expiresBefore(lease2)); }