### Question:
SessionClientImpl implements SessionClient { public void refreshToken(final RequestCallback<Tokens, AuthorizationException> cb) { cancelFuture(); mFutureTask = mDispatcher.submit(() -> { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); try { Tokens result = mSyncSessionClient.refreshToken(); mDispatcher.submitResults(() -> cb.onSuccess(result)); } 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 refreshToken() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); String nonce = CodeVerifierUtil.generateRandomState(); String jws = TestValues.getJwt(mEndPoint.getUrl(), nonce, mConfig.getClientId()); mEndPoint.enqueueTokenSuccess(jws); MockRequestCallback<Tokens, AuthorizationException> cb = new MockRequestCallback<>(latch); mSessionClient.refreshToken(cb); latch.await(); Tokens result = cb.getResult(); TokenResponse original = mGson.fromJson(String.format(TOKEN_SUCCESS, jws), TokenResponse.class); assertEquals(original.getIdToken(), result.getIdToken()); assertEquals(original.getRefreshToken(), result.getRefreshToken()); assertEquals(original.getIdToken(), result.getIdToken()); }
@Test public void refreshTokenFailure() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); mEndPoint.enqueueReturnInvalidClient(); MockRequestCallback<Tokens, AuthorizationException> cb = new MockRequestCallback<>(latch); mSessionClient.refreshToken(cb); latch.await(); assertNull(cb.getResult()); assertNotNull(cb.getException()); assertEquals(cb.getException().getMessage(), "Invalid status code 401 Client Error"); }