### Question:
SessionClientImpl implements SessionClient { public void getUserProfile(final RequestCallback<UserInfo, AuthorizationException> cb) { cancelFuture(); mFutureTask = mDispatcher.submit(() -> { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); try { UserInfo userInfo = mSyncSessionClient.getUserProfile(); mDispatcher.submitResults(() -> cb.onSuccess(userInfo)); } catch (AuthorizationException ae) { mDispatcher.submitResults(() -> cb.onError(ae.error, ae)); } catch (Exception ex) { mDispatcher.submitResults(() -> cb.onError(ex.getMessage(), new AuthorizationException(ex.getMessage(), ex))); } }); } SessionClientImpl(Executor callbackExecutor, SyncSessionClient syncSessionClient); void getUserProfile(final RequestCallback<UserInfo, AuthorizationException> cb); void introspectToken(String token, String tokenType,
                                final RequestCallback<IntrospectInfo, AuthorizationException> cb); void revokeToken(String token,
                            final RequestCallback<Boolean, AuthorizationException> cb); void refreshToken(final RequestCallback<Tokens, AuthorizationException> cb); @Override Tokens getTokens(); @Override void authorizedRequest(@NonNull Uri uri, @Nullable Map<String, String> properties,
                                  @Nullable Map<String, String> postParameters,
                                  @NonNull ConnectionParameters.RequestMethod method,
                                  final RequestCallback<JSONObject, AuthorizationException> cb); boolean isAuthenticated(); void clear(); @Override void cancel(); @Override void migrateTo(EncryptionManager manager);  }### Answer:
@Test public void getUserProfile() throws InterruptedException, JSONException { mEndPoint.enqueueUserInfoSuccess(); final CountDownLatch latch = new CountDownLatch(1); MockRequestCallback<UserInfo, AuthorizationException> cb = new MockRequestCallback<>(latch); mSessionClient.getUserProfile(cb); RecordedRequest recordedRequest = mEndPoint.takeRequest(); latch.await(); UserInfo result = cb.getResult(); 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.get("name")); assertEquals("Jimmy", result.get("nickname")); }
@Test public void getUserProfileFailure() throws InterruptedException, JSONException { mEndPoint.enqueueReturnUnauthorizedRevoked(); final CountDownLatch latch = new CountDownLatch(1); MockRequestCallback<UserInfo, AuthorizationException> cb = new MockRequestCallback<>(latch); mSessionClient.getUserProfile(cb); RecordedRequest recordedRequest = mEndPoint.takeRequest(); latch.await(); assertNull(cb.getResult()); assertNotNull(cb.getException()); assertThat(recordedRequest.getPath(), equalTo("/userinfo")); assertEquals(TYPE_GENERAL_ERROR, cb.getException().type); }