AuthToken { public boolean isExpired() { return now().getTime() - receivedAt.getTime() > DAYS.toMillis(10); } AuthToken(String value); String getValue(); Date getReceivedAt(); boolean isExpired(); String toHeaderString();  }
@Test public void testNewAuthTokenExpiration() { AuthToken token = new AuthToken("token_value"); assert !token.isExpired(); }
@Test public void testOutdatedAuthTokenExpiration() { AuthToken token = spy(new AuthToken("token_value")); final int SPENT_FUTURE_DAYS = 30; setCurrentDateInFuture(token, SPENT_FUTURE_DAYS); assert token.isExpired(); }