### Question:
TokenAuthentication extends AbstractAuthenticationToken { public static TokenAuthentication createAuthenticated(String username, String token) { final TokenAuthentication out = new TokenAuthentication(username, token); out.setAuthenticated(true); return out; } TokenAuthentication(String token);  TokenAuthentication(String username, String token); @Override String getCredentials(); @Override String getPrincipal(); static TokenAuthentication createAuthenticated(String username, String token);  }### Answer:
@Test public void testCreateAuthenticated() { TokenAuthentication ta = TokenAuthentication.createAuthenticated("user", "token"); assertEquals("user", ta.getPrincipal()); assertEquals("token", ta.getCredentials()); assertTrue(ta.isAuthenticated()); }