### Question:
GatewayTokenProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) { TokenAuthentication tokenAuthentication = (TokenAuthentication) authentication; QueryResponse queryResponse = gatewaySecurityService.query(tokenAuthentication.getCredentials()); TokenAuthentication validTokenAuthentication = new TokenAuthentication(queryResponse.getUserId(), tokenAuthentication.getCredentials()); validTokenAuthentication.setAuthenticated(true); return validTokenAuthentication; }  @Override Authentication authenticate(Authentication authentication); @Override boolean supports(Class<?> authentication);  }### Answer:
@Test public void shouldAuthenticateValidToken() { when(gatewaySecurityService.query(VALID_TOKEN)).thenReturn(new QueryResponse(DOMAIN, USER, new Date(), new Date(), QueryResponse.Source.ZOWE)); TokenAuthentication tokenAuthentication = new TokenAuthentication(VALID_TOKEN); Authentication processedAuthentication = gatewayTokenProvider.authenticate(tokenAuthentication); assertTrue(processedAuthentication instanceof TokenAuthentication); assertTrue(processedAuthentication.isAuthenticated()); assertEquals(VALID_TOKEN, processedAuthentication.getCredentials()); assertEquals(USER, processedAuthentication.getName()); }