GuestAuthToken extends OAuth2Token { @Override public boolean isExpired() { return System.currentTimeMillis() >= this.createdAt + EXPIRES_IN_MS; } GuestAuthToken(String tokenType, String accessToken, String guestToken);  GuestAuthToken(String tokenType, String accessToken, String guestToken, long createdAt); String getGuestToken(); @Override boolean isExpired(); @Override boolean equals(Object o); @Override int hashCode(); static final String HEADER_GUEST_TOKEN; }
@Test public void testIsExpired_newToken() { final GuestAuthToken token = new GuestAuthToken(TOKEN_TYPE, ACCESS_TOKEN, GUEST_TOKEN); assertFalse(token.isExpired()); }
@Test public void testIsExpired_oneHourOld() { final GuestAuthToken token = new GuestAuthToken(TOKEN_TYPE, ACCESS_TOKEN, GUEST_TOKEN, ONE_HOUR_AGE); assertFalse(token.isExpired()); }
@Test public void testIsExpired_threeHoursOld() { final GuestAuthToken token = new GuestAuthToken(TOKEN_TYPE, ACCESS_TOKEN, GUEST_TOKEN, THREE_HOURS_AGO); assertTrue(token.isExpired()); }
@Test public void testIsExpired_createdAtZero() { final GuestAuthToken token = new GuestAuthToken(TOKEN_TYPE, ACCESS_TOKEN, GUEST_TOKEN, 0); assertTrue(token.isExpired()); }