TokenRefresher { public boolean invalidateToken(String token) { if (accountManager != null) { try { accountManager.invalidateAuthToken(GOOGLE_TYPE, token); return true; } catch (SecurityException e) { Log.w(TAG, e); } } return false; } TokenRefresher(Context context, OAuth2Client oauth2Client, AuthPreferences authPreferences);   TokenRefresher(@Nullable AccountManager accountManager, OAuth2Client oauth2Client,
                   AuthPreferences authPreferences); void refreshOAuth2Token(); boolean invalidateToken(String token);  }
@Test public void shouldInvalidateTokenManually() throws Exception { assertThat(refresher.invalidateToken("token")).isTrue(); verify(accountManager).invalidateAuthToken(GOOGLE_TYPE, "token"); }
@Test public void shouldHandleSecurityExceptionWhenInvalidatingToken() throws Exception { doThrow(new SecurityException()).when(accountManager).invalidateAuthToken(GOOGLE_TYPE, "token"); assertThat(refresher.invalidateToken("token")).isFalse(); }