### Question:
DefaultTokenStateService implements TokenStateService { @Override public long getTokenExpiration(final JWT token) throws UnknownTokenException { long expiration = -1; try { expiration = getTokenExpiration(TokenUtils.getTokenId(token)); } catch (UnknownTokenException e) { if (permissiveValidationEnabled) { String exp = token.getExpires(); if (exp != null) { log.permissiveTokenHandling(TokenUtils.getTokenId(token), e.getMessage()); expiration = Long.parseLong(exp); } } if (expiration == -1) { throw e; } } return expiration; }  @Override void init(final GatewayConfig config, final Map<String, String> options); @Override void start(); @Override void stop(); @Override long getDefaultRenewInterval(); @Override long getDefaultMaxLifetimeDuration(); @Override void addToken(final JWTToken token, long issueTime); @Override void addToken(final String tokenId, long issueTime, long expiration); @Override void addToken(final String tokenId,
                             long   issueTime,
                             long   expiration,
                             long   maxLifetimeDuration); @Override long getTokenExpiration(final JWT token); @Override long getTokenExpiration(final String tokenId); @Override long getTokenExpiration(String tokenId, boolean validate); @Override long renewToken(final JWTToken token); @Override long renewToken(final JWTToken token, long renewInterval); @Override long renewToken(final String tokenId); @Override long renewToken(final String tokenId, long renewInterval); @Override void revokeToken(final JWTToken token); @Override void revokeToken(final String tokenId); @Override boolean isExpired(final JWTToken token);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testGetExpiration_NullToken() throws Exception { createTokenStateService().getTokenExpiration((String) null); }
@Test(expected = IllegalArgumentException.class) public void testGetExpiration_EmptyToken() throws Exception { createTokenStateService().getTokenExpiration(""); }
@Test(expected = UnknownTokenException.class) public void testGetExpiration_InvalidToken() throws Exception { final JWTToken token = createMockToken(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60)); createTokenStateService().getTokenExpiration(TokenUtils.getTokenId(token)); }
@Test(expected = UnknownTokenException.class) public void testGetExpiration_InvalidToken_WithoutValidation() throws Exception { final JWTToken token = createMockToken(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60)); createTokenStateService().getTokenExpiration(TokenUtils.getTokenId(token), false); }