@Test
public void expiredToken_shouldThrow() throws Exception {

  JSONObject payload = new JSONObject();
  // Set the expiration time to 1 minute in the past.
  Instant instant = Instant.now().minus(Duration.ofMinutes(1));
  payload.put(JwtNames.CLAIM_EXPIRATION, instant.getEpochSecond());
  Jwt expiredToken = new Jwt(new JSONObject(), payload, Clock.systemUTC(), Duration.ZERO);
  assertThrows(JwtExpiredException.class, expiredToken::getIssuer);
  assertThrows(JwtExpiredException.class, expiredToken::getSubject);
  assertThrows(JwtExpiredException.class, expiredToken::getAudiences);
  assertThrows(JwtExpiredException.class, expiredToken::getJwtId);
  assertThrows(JwtExpiredException.class, () -> expiredToken.getClaim("blah"));
  assertThrows(JwtExpiredException.class, expiredToken::getAlgorithm);
  assertThrows(JwtExpiredException.class, expiredToken::getType);
  assertThrows(JwtExpiredException.class, expiredToken::getContentType);
  assertThrows(JwtExpiredException.class, expiredToken::getKeyId);
}