### Question:
AccessTokenService { public AccessToken requestAccessToken(OAuth2Request request) throws RedirectUriMismatchException, InvalidClientException, InvalidRequestException, InvalidCodeException, InvalidGrantException, ServerException, UnauthorizedClientException, InvalidScopeException, NotFoundException, AuthorizationPendingException, ExpiredTokenException, AuthorizationDeclinedException, BadRequestException { final String grantType = request.getParameter(GRANT_TYPE); final GrantTypeHandler grantTypeHandler = grantTypeHandlers.get(grantType); if (grantTypeHandler == null) { throw new InvalidGrantException("Unknown Grant Type, " + grantType); } return grantTypeHandler.handle(request); } @Inject  AccessTokenService(Map<String, GrantTypeHandler> grantTypeHandlers,
            final ClientAuthenticator clientAuthenticator, final TokenStore tokenStore,
            final OAuth2ProviderSettingsFactory providerSettingsFactory, OAuth2UrisFactory urisFactory,
            IdentityManager identityManager); AccessToken requestAccessToken(OAuth2Request request); AccessToken refreshToken(OAuth2Request request);  }### Answer:
@Test public void shouldRequestAccessToken() throws Exception { OAuth2Request request = mock(OAuth2Request.class); given(request.getParameter("grant_type")).willReturn("GRANT_TYPE"); accessTokenService.requestAccessToken(request); verify(grantTypeHandler).handle(request); }
@Test (expectedExceptions = InvalidGrantException.class) public void requestAccessTokenShouldThrowInvalidGrantExceptionWhenGrantTypeDoesNotMatchHandler() throws Exception { OAuth2Request request = mock(OAuth2Request.class); given(request.getParameter("grant_type")).willReturn("UNKNOWN_GRANT_TYPE"); accessTokenService.requestAccessToken(request); }