### Question:
SubjectTypeValidator implements AuthorizeRequestValidator { @Override public void validateRequest(OAuth2Request request) throws InvalidClientException, NotFoundException, ServerException { final OAuth2ProviderSettings settings = providerSettingsFactory.get(request); final Set<String> subjectTypesSupported = settings.getSupportedSubjectTypes(); final String subjectType = clientRegistrationStore.get((String) request.getParameter(OAuth2Constants.Params.CLIENT_ID), request).getSubjectType().toLowerCase(); for (String supported : subjectTypesSupported) { if (supported.toLowerCase().equals(subjectType)) { return; } } throw failureFactory.getException(request, "Server does not support this client's subject type."); } @Inject  SubjectTypeValidator(OAuth2ProviderSettingsFactory providerSettingsFactory,
            OpenIdConnectClientRegistrationStore clientRegistrationStore, ClientAuthenticationFailureFactory failureFactory); @Override void validateRequest(OAuth2Request request);  }### Answer:
@Test public void shouldValidateRequest() throws InvalidClientException, NotFoundException, ServerException { OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class); OAuth2Request mockRequest = mock(OAuth2Request.class); OpenIdConnectClientRegistration mockClientRegistration = mock(OpenIdConnectClientRegistration.class); Set<String> subjectTypesSupported = new HashSet<String>(); subjectTypesSupported.add("public"); given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings); given(mockProviderSettings.getSupportedSubjectTypes()).willReturn(subjectTypesSupported); given(mockRequest.getParameter(OAuth2Constants.Params.CLIENT_ID)).willReturn("CLIENT_ID"); given(mockClientRegistrationStore.get("CLIENT_ID", mockRequest)).willReturn(mockClientRegistration); given(mockClientRegistration.getSubjectType()).willReturn("public"); subjectTypeValidator.validateRequest(mockRequest); }
@Test (expectedExceptions = InvalidClientException.class) public void shouldFailSubjectTypeNotSupported() throws InvalidClientException, NotFoundException, ServerException { OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class); OAuth2Request mockRequest = mock(OAuth2Request.class); OpenIdConnectClientRegistration mockClientRegistration = mock(OpenIdConnectClientRegistration.class); Set<String> subjectTypesSupported = new HashSet<String>(); subjectTypesSupported.add("public"); given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings); given(mockProviderSettings.getSupportedSubjectTypes()).willReturn(subjectTypesSupported); given(mockRequest.getParameter(OAuth2Constants.Params.CLIENT_ID)).willReturn("CLIENT_ID"); given(mockClientRegistrationStore.get("CLIENT_ID", mockRequest)).willReturn(mockClientRegistration); given(mockClientRegistration.getSubjectType()).willReturn("pairwise"); subjectTypeValidator.validateRequest(mockRequest); }