### Question:
AuthRequest { public void validate() throws OAuthException { if (!RESPONSE_TYPE_CODE.equals(responseType)) { throw new OAuthException(Response.RESPONSE_TYPE_NOT_SUPPORTED, HttpResponseStatus.BAD_REQUEST); } if (redirectUri != null && !isValidURI(redirectUri)) { throw new OAuthException(Response.INVALID_REDIRECT_URI, HttpResponseStatus.BAD_REQUEST); } } AuthRequest(HttpRequest request); String getClientId(); String getResponseType(); String getRedirectUri(); String getState(); String getScope(); String getUserId(); void setUserId(String userId); void validate();  }### Answer:
@Test public void when_validate_and_response_type_unsupported_return_errror() throws Exception { HttpRequest request = mock(HttpRequest.class); String responseType = "unsupported"; String clientId = "763273054098803"; String state = "xyz"; String scope = "basic"; given(request.getUri()).willReturn( "http: + clientId + "&state=" + state + "&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom&scope=" + scope); AuthRequest authReq = spy(new AuthRequest(request)); String errorMsg = null; try { authReq.validate(); } catch (OAuthException e) { errorMsg = e.getMessage(); } assertEquals(errorMsg, Response.RESPONSE_TYPE_NOT_SUPPORTED); }
@Test public void when_validate_and_redirect_uri_invalid_return_errror() throws Exception { HttpRequest request = mock(HttpRequest.class); String responseType = "code"; String clientId = "763273054098803"; String state = "xyz"; String scope = "basic"; given(request.getUri()).willReturn( "http: + clientId + "&state=" + state + "&redirect_uri=%3A%2F%2Fclient%2Eexample%2Ecom&scope=" + scope); AuthRequest authReq = spy(new AuthRequest(request)); String errorMsg = null; try { authReq.validate(); } catch (OAuthException e) { errorMsg = e.getMessage(); } assertEquals(errorMsg, Response.INVALID_REDIRECT_URI); }