  @Test
  public void setAutomaticDataCollectionEnabled_updatesSharedPreferences() {

    when(sharedPreferencesUtils.isPreferenceSet(DataCollectionHelper.AUTO_INIT_PREFERENCES))
        .thenReturn(false);
    when(sharedPreferencesUtils.isManifestSet(
            DataCollectionHelper.MANIFEST_METADATA_AUTO_INIT_ENABLED))
        .thenReturn(false);
    when(firebaseApp.isDataCollectionDefaultEnabled()).thenReturn(true);

    dataCollectionHelper =
        new DataCollectionHelper(firebaseApp, sharedPreferencesUtils, subscriber);
    dataCollectionHelper.setAutomaticDataCollectionEnabled(Boolean.FALSE);
    verify(sharedPreferencesUtils, times(1))
        .setBooleanPreference(DataCollectionHelper.AUTO_INIT_PREFERENCES, false);
    dataCollectionHelper.setAutomaticDataCollectionEnabled(null);
    verify(sharedPreferencesUtils, times(1))
        .clearPreference(DataCollectionHelper.AUTO_INIT_PREFERENCES);
  }