### Question:
TimeBasedTokenSerializer implements TokenSerializer<String> { @Override public String deserialize(final String token) throws InvalidTokenException { validateTimestamp(token); String decodedToken = StringUtils.substringBeforeLast(token, TIMESTAMP_DEMILITER); if (StringUtils.isBlank(decodedToken)) { throw new InvalidTokenException("The token is blank."); } return decodedToken; }  @Override String deserialize(final String token); @Override String serialize(final String token);  }### Answer:
@Test public void deserialize_noTimestamp() { assertThatThrownBy(() -> serializer.deserialize("something")) .isInstanceOf(InvalidTokenException.class); }
@Test public void deserialize_timestampNonBase64() { assertThatThrownBy(() -> serializer.deserialize("&something")) .isInstanceOf(InvalidTokenException.class); }
@Test public void deserialize_tokenExpired() { Instant expiredInstant = Instant.now().minusSeconds(TOKEN_TTL_IN_SECOND + 1); assertThatThrownBy(() -> serializer.deserialize("something&" + expiredInstant.toString())) .isInstanceOf(InvalidTokenException.class); }
@Test public void deserialize_noToken() { assertThatThrownBy(() -> serializer.deserialize("&" + Instant.now().toString())) .isInstanceOf(InvalidTokenException.class); }