### Question:
OAuth2Helper { public Credential refreshCredential(Credential credential) throws IOException { if (isCredentialRefreshable(credential)) { if (!callRefreshToken(credential)) { libLogger.warn("OAuth2 token could not be refreshed. " + "Add a refreshListener to the Credential to capture this failure."); } } return credential; } @Inject  OAuth2Helper(@Named("libLogger") Logger libLogger,
      @Named("oAuth2RefreshWindow") Long refreshWindowSeconds); Credential refreshCredential(Credential credential);  }### Answer:
@Test public void testRefreshCredential_noRefreshToken() throws Exception { credential.setAccessToken(ACCESS_TOKEN); credential.setRefreshToken(null); credential.setExpiresInSeconds(null); assertSame(credential, oAuth2Helper.refreshCredential(credential)); }
@Test public void testRefreshCredential_notSoonEnough() throws Exception { credential.setAccessToken(ACCESS_TOKEN); credential.setRefreshToken(REFRESH_TOKEN); credential.setExpiresInSeconds(REFRESH_WINDOW_SECS * 2L); assertSame(credential, oAuth2Helper.refreshCredential(credential)); }