### Question:
IngOauth2Service { public URI getAuthorizationRequestUri(Oauth2Service.Parameters parameters) { requireValid(validateScope(parameters.getScope())); parameters.setScope(mapScope(parameters.getScope())); IngClientAuthentication clientAuthentication = getClientAuthentication(); IngAuthorizationURLResponse authorizationUrlResponse = oauth2Api.getAuthorizationUrl(clientAuthentication, parameters.getScope(), parameters.getRedirectUri()) .getBody(); parameters.setClientId(getClientId()); parameters.setResponseType(CODE.toString()); return URI.create(StringUri.withQuery(authorizationUrlResponse.getLocation(), parameters.asMap())); } IngOauth2Service(IngOauth2Api oauth2Api,
                            IngClientAuthenticationFactory clientAuthenticationFactory); URI getAuthorizationRequestUri(Oauth2Service.Parameters parameters); IngClientAuthentication getClientAuthentication(); IngTokenResponse getToken(Oauth2Service.Parameters parameters); IngClientAuthentication getClientAuthentication(String accessToken);  }### Answer:
@Test void getAuthorizationRequestUri_Failure_ScopeIsNotProvided() { Parameters parameters = new Parameters(); try { oauth2Service.getAuthorizationRequestUri(parameters); fail("Should not be reached as RequestValidationException is expected to be thrown before"); } catch (RequestValidationException e) { List<ValidationError> validationErrors = e.getValidationErrors(); assertNotNull(validationErrors); assertEquals(1, validationErrors.size()); ValidationError validationError = validationErrors.get(0); assertEquals(validationErrors.get(0), ValidationError.required(Oauth2Service.Parameters.SCOPE)); } }
@Test void getAuthorizationRequestUri_Failure_ScopeIsUnsupported() { Parameters parameters = new Parameters(); parameters.setScope(UNSUPPORTED_SCOPE); try { oauth2Service.getAuthorizationRequestUri(parameters); fail("Should not be reached as RequestValidationException is expected to be thrown before"); } catch (RequestValidationException e) { List<ValidationError> validationErrors = e.getValidationErrors(); assertNotNull(validationErrors); assertEquals(1, validationErrors.size()); ValidationError validationError = validationErrors.get(0); assertEquals(ValidationError.Code.NOT_SUPPORTED, validationError.getCode()); assertEquals(Oauth2Service.Parameters.SCOPE, validationError.getPath()); assertEquals(String.format(UNSUPPORTED_SCOPE_VALUE_ERROR_MESSAGE, UNSUPPORTED_SCOPE), validationError.getMessage()); } }