### Question:
SyncSessionClientImpl implements SyncSessionClient { AuthorizedRequest userProfileRequest(ProviderConfiguration providerConfiguration, TokenResponse tokenResponse) throws AuthorizationException { if (mOidcConfig.isOAuth2Configuration()) { throw new AuthorizationException("Invalid operation. " + "Please check your configuration. OAuth2 authorization servers does not" + "support /userinfo endpoint ", new RuntimeException()); } return HttpRequestBuilder.newProfileRequest() .tokenResponse(tokenResponse) .providerConfiguration(providerConfiguration) .config(mOidcConfig) .createRequest(); } SyncSessionClientImpl(OIDCConfig oidcConfig, OktaState oktaState,
                          OktaHttpClient httpClient); JSONObject authorizedRequest(@NonNull Uri uri,
                                        @Nullable Map<String, String> properties,
                                        @Nullable Map<String, String> postParameters,
                                        @NonNull ConnectionParameters.RequestMethod method); @Override UserInfo getUserProfile(); @Override IntrospectInfo introspectToken(String token, String tokenType); @Override Boolean revokeToken(String token); @Override Tokens refreshToken(); @Override Tokens getTokens(); @Override boolean isAuthenticated(); @Override void clear(); @Override void cancel(); @Override void migrateTo(EncryptionManager manager);  }### Answer:
@Test public void userProfileRequest() throws InterruptedException, JSONException, AuthorizationException, OktaRepository.EncryptionException { mOktaState.save(mTokenResponse); mEndPoint.enqueueUserInfoSuccess(); AuthorizedRequest request = mSyncSessionClientImpl.userProfileRequest(mOktaState.getProviderConfiguration(), mTokenResponse); JSONObject result = request.executeRequest(mHttpClient); RecordedRequest recordedRequest = mEndPoint.takeRequest(); assertThat(recordedRequest.getHeader("Authorization"), is("Bearer " + ACCESS_TOKEN)); assertThat(recordedRequest.getHeader("Accept"), is(ConnectionParameters.JSON_CONTENT_TYPE)); assertThat(recordedRequest.getPath(), equalTo("/userinfo")); assertNotNull(result); assertEquals("John Doe", result.getString("name")); assertEquals("Jimmy", result.getString("nickname")); }
@Test public void userProfileRequestOAuth2() throws AuthorizationException, OktaRepository.EncryptionException { mExpectedEx.expect(AuthorizationException.class); OIDCConfig oauth2Config = TestValues .getConfigWithUrl(mEndPoint.getUrl() + "/oauth2/default/"); SyncWebAuthClient syncWebAuthClient = new Okta.SyncWebAuthBuilder() .withConfig(oauth2Config) .withOktaHttpClient(mHttpClient) .withContext(mContext) .withStorage(new SharedPreferenceStorage(mContext, "oauth2prefs")) .withEncryptionManager(new EncryptionManagerStub()) .create(); SyncSessionClientImpl sessionClient = (SyncSessionClientImpl) syncWebAuthClient .getSessionClient(); AuthorizedRequest request = sessionClient.userProfileRequest(mOktaState.getProviderConfiguration(), mOktaState.getTokenResponse()); request.executeRequest(mHttpClient); }
@Test public void userProfileRequestFailure() throws InterruptedException, AuthorizationException, OktaRepository.EncryptionException { mOktaState.save(mTokenResponse); mExpectedEx.expect(AuthorizationException.class); mEndPoint.enqueueReturnUnauthorizedRevoked(); AuthorizedRequest request = mSyncSessionClientImpl.userProfileRequest(mOktaState.getProviderConfiguration(), mTokenResponse); JSONObject result = request.executeRequest(mHttpClient); RecordedRequest recordedRequest = mEndPoint.takeRequest(); assertNull(result); assertThat(recordedRequest.getPath(), equalTo("/userinfo")); }