@Test public void testGetAuthToken_expiredAuthToken_fetchedNewTokenFromFIS() throws Exception { persistedInstallation.insertOrUpdatePersistedInstallationEntry( PersistedInstallationEntry.INSTANCE.withRegisteredFid( TEST_FID_1, TEST_REFRESH_TOKEN, utils.currentTimeInSecs() - TEST_TOKEN_EXPIRATION_TIMESTAMP + TimeUnit.MINUTES.toSeconds(30), TEST_AUTH_TOKEN, TEST_TOKEN_EXPIRATION_TIMESTAMP)); fakeClock.advanceTimeBySeconds( TEST_TOKEN_EXPIRATION_TIMESTAMP - TimeUnit.MINUTES.toSeconds(30)); when(mockBackend.generateAuthToken(anyString(), anyString(), anyString(), anyString())) .thenReturn(TEST_TOKEN_RESULT); TestOnCompleteListener<InstallationTokenResult> onCompleteListener = new TestOnCompleteListener<>(); Task<InstallationTokenResult> task = firebaseInstallations.getToken(false); task.addOnCompleteListener(executor, onCompleteListener); InstallationTokenResult installationTokenResult = onCompleteListener.await(); assertWithMessage("Persisted Auth Token doesn't match") .that(installationTokenResult.getToken()) .isEqualTo(TEST_AUTH_TOKEN_2); }
@NonNull @Override public Task<InstallationTokenResult> getToken(boolean forceRefresh) { preConditionChecks(); Task<InstallationTokenResult> task = addGetAuthTokenListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(forceRefresh)); return task; }
FirebaseInstallations implements FirebaseInstallationsApi { @NonNull @Override public Task<InstallationTokenResult> getToken(boolean forceRefresh) { preConditionChecks(); Task<InstallationTokenResult> task = addGetAuthTokenListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(forceRefresh)); return task; } }
FirebaseInstallations implements FirebaseInstallationsApi { @NonNull @Override public Task<InstallationTokenResult> getToken(boolean forceRefresh) { preConditionChecks(); Task<InstallationTokenResult> task = addGetAuthTokenListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(forceRefresh)); return task; } FirebaseInstallations(
      FirebaseApp firebaseApp,
      @NonNull Provider<UserAgentPublisher> publisher,
      @NonNull Provider<HeartBeatInfo> heartbeatInfo);   FirebaseInstallations(
      ExecutorService backgroundExecutor,
      FirebaseApp firebaseApp,
      FirebaseInstallationServiceClient serviceClient,
      PersistedInstallation persistedInstallation,
      Utils utils,
      IidStore iidStore,
      RandomFidGenerator fidGenerator); }
FirebaseInstallations implements FirebaseInstallationsApi { @NonNull @Override public Task<InstallationTokenResult> getToken(boolean forceRefresh) { preConditionChecks(); Task<InstallationTokenResult> task = addGetAuthTokenListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(forceRefresh)); return task; } FirebaseInstallations(
      FirebaseApp firebaseApp,
      @NonNull Provider<UserAgentPublisher> publisher,
      @NonNull Provider<HeartBeatInfo> heartbeatInfo);   FirebaseInstallations(
      ExecutorService backgroundExecutor,
      FirebaseApp firebaseApp,
      FirebaseInstallationServiceClient serviceClient,
      PersistedInstallation persistedInstallation,
      Utils utils,
      IidStore iidStore,
      RandomFidGenerator fidGenerator); @NonNull static FirebaseInstallations getInstance(); @NonNull static FirebaseInstallations getInstance(@NonNull FirebaseApp app); @NonNull @Override Task<String> getId(); @NonNull @Override Task<InstallationTokenResult> getToken(boolean forceRefresh); @NonNull @Override Task<Void> delete(); }
FirebaseInstallations implements FirebaseInstallationsApi { @NonNull @Override public Task<InstallationTokenResult> getToken(boolean forceRefresh) { preConditionChecks(); Task<InstallationTokenResult> task = addGetAuthTokenListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(forceRefresh)); return task; } FirebaseInstallations(
      FirebaseApp firebaseApp,
      @NonNull Provider<UserAgentPublisher> publisher,
      @NonNull Provider<HeartBeatInfo> heartbeatInfo);   FirebaseInstallations(
      ExecutorService backgroundExecutor,
      FirebaseApp firebaseApp,
      FirebaseInstallationServiceClient serviceClient,
      PersistedInstallation persistedInstallation,
      Utils utils,
      IidStore iidStore,
      RandomFidGenerator fidGenerator); @NonNull static FirebaseInstallations getInstance(); @NonNull static FirebaseInstallations getInstance(@NonNull FirebaseApp app); @NonNull @Override Task<String> getId(); @NonNull @Override Task<InstallationTokenResult> getToken(boolean forceRefresh); @NonNull @Override Task<Void> delete();  }