AccessTokenProviderChain chain = new AccessTokenProviderChain(Collections.<AccessTokenProvider> emptyList());
Mockito.when(clientTokenServices.getAccessToken(resource, user)).thenReturn(accessToken);
chain.setClientTokenServices(clientTokenServices);
AccessTokenRequest request = new DefaultAccessTokenRequest();
SecurityContextHolder.getContext().setAuthentication(user);
OAuth2AccessToken token = chain.obtainAccessToken(resource, request);
assertEquals(accessToken, token);
Mockito.verify(clientTokenServices).saveAccessToken(resource, user, token);
}