### Question:
AuthorizeRequestValidatorImpl implements AuthorizeRequestValidator { public void validateRequest(OAuth2Request request) throws InvalidClientException, InvalidRequestException, RedirectUriMismatchException, UnsupportedResponseTypeException, ServerException, NotFoundException { Reject.ifTrue(isEmpty(request.<String>getParameter(CLIENT_ID)), "Missing parameter, 'client_id'"); Reject.ifTrue(isEmpty(request.<String>getParameter(RESPONSE_TYPE)), "Missing parameter, 'response_type'"); final ClientRegistration clientRegistration = clientRegistrationStore.get(request.<String>getParameter("client_id"), request); if (request.getParameter(OAuth2Constants.DeviceCode.USER_CODE) == null) { redirectUriValidator.validate(clientRegistration, request.<String>getParameter(REDIRECT_URI)); } responseTypeValidator.validate(clientRegistration, splitResponseType(request.<String>getParameter(RESPONSE_TYPE)), providerSettingsFactory.get(request)); } @Inject  AuthorizeRequestValidatorImpl(ClientRegistrationStore clientRegistrationStore,
            RedirectUriValidator redirectUriValidator, OAuth2ProviderSettingsFactory providerSettingsFactory,
            ResponseTypeValidator responseTypeValidator); void validateRequest(OAuth2Request request);  }### Answer:
@Test public void shouldValidateValidRequest() throws Exception { OAuth2Request request = mock(OAuth2Request.class); given(request.getParameter("client_id")).willReturn("CLIENT_ID"); given(request.getParameter("response_type")).willReturn("RESPONSE_TYPE"); requestValidator.validateRequest(request); verify(redirectUriValidator).validate(Matchers.<ClientRegistration>anyObject(), anyString()); verify(responseTypeValidator).validate(Matchers.<ClientRegistration>anyObject(), anySetOf(String.class), Matchers.<OAuth2ProviderSettings>anyObject()); }
@Test public void shouldValidateRequestWithEmptyClientId() throws Exception { OAuth2Request request = mock(OAuth2Request.class); given(request.getParameter("client_id")).willReturn(""); try { requestValidator.validateRequest(request); fail(); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "Missing parameter, 'client_id'"); } }
@Test public void shouldValidateRequestWithMissingClientId() throws Exception { OAuth2Request request = mock(OAuth2Request.class); try { requestValidator.validateRequest(request); fail(); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "Missing parameter, 'client_id'"); } }
@Test public void shouldValidateRequestWithEmptyResponseType() throws Exception { OAuth2Request request = mock(OAuth2Request.class); given(request.getParameter("client_id")).willReturn("CLIENT_ID"); given(request.getParameter("response_type")).willReturn(""); try { requestValidator.validateRequest(request); fail(); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "Missing parameter, 'response_type'"); } }
@Test public void shouldValidateRequestWithMissingResponseType() throws Exception { OAuth2Request request = mock(OAuth2Request.class); given(request.getParameter("client_id")).willReturn("CLIENT_ID"); try { requestValidator.validateRequest(request); fail(); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "Missing parameter, 'response_type'"); } }