TwitterAuthClient { public void requestEmail(TwitterSession session, final Callback<String> callback) { final Call<User> verifyRequest = twitterCore.getApiClient(session).getAccountService() .verifyCredentials(false, false, true); verifyRequest.enqueue(new Callback<User>() { @Override public void success(Result<User> result) { callback.success(new Result<>(result.data.email, null)); } @Override public void failure(TwitterException exception) { callback.failure(exception); } }); } TwitterAuthClient();   TwitterAuthClient(TwitterCore twitterCore, TwitterAuthConfig authConfig,
                      SessionManager<TwitterSession> sessionManager, AuthState authState); int getRequestCode(); void authorize(Activity activity, Callback<TwitterSession> callback); void cancelAuthorize(); void onActivityResult(int requestCode, int resultCode, Intent data); void requestEmail(TwitterSession session, final Callback<String> callback);  }
@Test public void testRequestEmail_withSuccess() { final User user = new UserBuilder().setEmail(TEST_EMAIL).build(); final Call<User> call = Calls.response(user); setupMockAccountService(call); authClient.requestEmail(mock(TwitterSession.class), new Callback<String>() { @Override public void success(Result<String> result) { assertEquals(TEST_EMAIL, result.data); } @Override public void failure(TwitterException exception) { fail("Expected Callback#success to be called"); } }); }
@Test public void testRequestEmail_withFailure() { final IOException networkException = new IOException("Network failure"); final Call<User> call = Calls.failure(networkException); setupMockAccountService(call); authClient.requestEmail(mock(TwitterSession.class), new Callback<String>() { @Override public void success(Result<String> result) { fail("Expected Callback#failure to be called"); } @Override public void failure(TwitterException exception) { assertEquals(exception.getCause(), networkException); } }); }