use of org.forgerock.oauth2.core.AccessTokenService in project OpenAM by OpenRock.
the class TokenEndpointResourceTest method testToken.
@Test
public void testToken() throws Exception {
//Given
Context context = new Context();
Request request = new Request();
Response response = new Response(request);
tokenEndpointResource.init(context, request, response);
doReturn(new AccessToken(null, OAUTH_ACCESS_TOKEN, null)).when(accessTokenService).requestAccessToken(any(OAuth2Request.class));
//When
tokenEndpointResource.token(new EmptyRepresentation());
//Then
verify(hook).afterTokenHandling(any(OAuth2Request.class), eq(request), eq(response));
}
use of org.forgerock.oauth2.core.AccessTokenService in project OpenAM by OpenRock.
the class TokenEndpointResourceTest method setUp.
@BeforeClass
@SuppressWarnings("unchecked")
public void setUp() {
JacksonRepresentationFactory jacksonRepresentationFactory = new JacksonRepresentationFactory(new ObjectMapper());
requestFactory = mock(OAuth2RequestFactory.class);
accessTokenService = mock(AccessTokenService.class);
OAuth2Representation representation = new OAuth2Representation(null);
exceptionHandler = new ExceptionHandler(representation, null, null, jacksonRepresentationFactory);
hook = mock(TokenRequestHook.class);
tokenEndpointResource = new TokenEndpointResource(requestFactory, accessTokenService, exceptionHandler, CollectionUtils.asSet(hook), jacksonRepresentationFactory);
}
Aggregations