@Test public void testGetId_UnRegisteredId_IssueCreateIdCall() throws Exception { when(mockBackend.createFirebaseInstallation( anyString(), matches(TEST_FID_1), anyString(), anyString(), any())) .thenReturn(TEST_INSTALLATION_RESPONSE); persistedInstallation.insertOrUpdatePersistedInstallationEntry( PersistedInstallationEntry.INSTANCE.withUnregisteredFid(TEST_FID_1)); TestOnCompleteListener<String> onCompleteListener = new TestOnCompleteListener<>(); Task<String> task = firebaseInstallations.getId(); task.addOnCompleteListener(executor, onCompleteListener); String fid = onCompleteListener.await(); assertWithMessage("getId Task failed.").that(fid).isEqualTo(TEST_FID_1); executor.awaitTermination(500, TimeUnit.MILLISECONDS); verify(mockBackend) .createFirebaseInstallation( anyString(), matches(TEST_FID_1), anyString(), anyString(), any()); verify(mockBackend, never()) .generateAuthToken(anyString(), anyString(), anyString(), anyString()); PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); assertTrue("the entry doesn't have a registered fid: " + entry, entry.isRegistered()); }
@NonNull @Override public Task<String> getId() { preConditionChecks(); String fid = getCacheFid(); if (fid != null) { return Tasks.forResult(fid); } Task<String> task = addGetIdListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(false)); return task; }
FirebaseInstallations implements FirebaseInstallationsApi { @NonNull @Override public Task<String> getId() { preConditionChecks(); String fid = getCacheFid(); if (fid != null) { return Tasks.forResult(fid); } Task<String> task = addGetIdListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(false)); return task; } }
FirebaseInstallations implements FirebaseInstallationsApi { @NonNull @Override public Task<String> getId() { preConditionChecks(); String fid = getCacheFid(); if (fid != null) { return Tasks.forResult(fid); } Task<String> task = addGetIdListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(false)); 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<String> getId() { preConditionChecks(); String fid = getCacheFid(); if (fid != null) { return Tasks.forResult(fid); } Task<String> task = addGetIdListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(false)); 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<String> getId() { preConditionChecks(); String fid = getCacheFid(); if (fid != null) { return Tasks.forResult(fid); } Task<String> task = addGetIdListener(); backgroundExecutor.execute(() -> doRegistrationOrRefresh(false)); 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();  }