### Question:
AbstractToken implements Token { @Override public boolean isExpired() { return getExpiration() == null ? true : getExpiration().isBefore(LocalDateTime.now().toInstant(ZoneOffset.UTC)); } AbstractToken(@Nonnull DecodedJwt decodedJwt);  AbstractToken(@Nonnull String jwtToken); @Nullable @Override String getHeaderParameterAsString(@Nonnull String headerName); @Override boolean hasClaim(@Nonnull String claimName); @Override boolean hasHeaderParameter(@Nonnull String parameterName); @Nullable @Override String getClaimAsString(@Nonnull String claimName); @Nullable @Override List<String> getClaimAsStringList(@Nonnull String claimName); @Nullable @Override JsonObject getClaimAsJsonObject(String claimName); @Nullable @Override Instant getExpiration(); @Override boolean isExpired(); @Nullable @Override Instant getNotBefore(); @Override String getTokenValue(); @Override Set<String> getAudiences(); @Override boolean equals(Object o); @Override int hashCode(); @Override String getZoneId(); @Override String toString();  }### Answer:
@Test public void tokenWithExpirationInTheFuture_isNotExpired() { AbstractToken doesNotExpireSoon = new MockTokenBuilder().withExpiration(MockTokenBuilder.NO_EXPIRE_DATE) .build(); when(doesNotExpireSoon.isExpired()).thenCallRealMethod(); assertThat(doesNotExpireSoon.isExpired()).isFalse(); }
@Test public void tokenWithExpirationInThePast_isExpired() { assertThat(cut.isExpired()).isTrue(); }
@Test public void tokenWithoutExpirationDate_isExpired() { AbstractToken tokenWithoutExpiration = new MockTokenBuilder().withExpiration(null).build(); when(tokenWithoutExpiration.isExpired()).thenCallRealMethod(); assertThat(tokenWithoutExpiration.isExpired()).isTrue(); }
@Test public void tokenWithLongExpiration_isNotExpired() { AbstractToken tokenWithNoExpiration = new MockTokenBuilder().withExpiration(MockTokenBuilder.NO_EXPIRE_DATE) .build(); when(tokenWithNoExpiration.isExpired()).thenCallRealMethod(); assertThat(tokenWithNoExpiration.isExpired()).isFalse(); }