@Test public void testGetAuthToken_serverError_failure() throws Exception { persistedInstallation.insertOrUpdatePersistedInstallationEntry( PersistedInstallationEntry.INSTANCE.withRegisteredFid( TEST_FID_1, TEST_REFRESH_TOKEN, utils.currentTimeInSecs(), TEST_AUTH_TOKEN, TEST_TOKEN_EXPIRATION_TIMESTAMP)); when(mockBackend.generateAuthToken(anyString(), anyString(), anyString(), anyString())) .thenReturn( TokenResult.builder().setResponseCode(TokenResult.ResponseCode.BAD_CONFIG).build()); try { TestOnCompleteListener<InstallationTokenResult> onCompleteListener = new TestOnCompleteListener<>(); Task<InstallationTokenResult> task = firebaseInstallations.getToken(true); task.addOnCompleteListener(executor, onCompleteListener); onCompleteListener.await(); fail( "getAuthToken() succeeded but should have failed due to the BAD_CONFIG error " + "returned by the network call."); } catch (ExecutionException expected) { assertWithMessage("Exception class doesn't match") .that(expected) .hasCauseThat() .isInstanceOf(FirebaseInstallationsException.class); assertWithMessage("Exception status doesn't match") .that(((FirebaseInstallationsException) expected.getCause()).getStatus()) .isEqualTo(Status.BAD_CONFIG); } }
@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();  }