ContentObservables { @NonNull public static Observable sharedPreferencesObservable(@NonNull final SharedPreferences preferences, @NonNull final String... keys) { return new SharedPreferencesObservable(preferences, keys); } private  ContentObservables(); @NonNull static Observable broadcastObservable(@NonNull final Context context,
      @NonNull final String... actions); @NonNull static Observable sharedPreferencesObservable(@NonNull final SharedPreferences preferences,
      @NonNull final String... keys);  }
@Test public void shouldUpdateSharedPreferencesWhenKeyChanges() { updatable.addToObservable(sharedPreferencesObservable(sharedPreferences, TEST_KEY)); sharedPreferenceListenerCaptor.getValue() .onSharedPreferenceChanged(sharedPreferences, TEST_KEY); assertThat(updatable, wasUpdated()); }
@Test public void shouldNotUpdateSharedPreferencesWhenOtherKeyChanges() { updatable.addToObservable(sharedPreferencesObservable(sharedPreferences, TEST_KEY)); sharedPreferenceListenerCaptor.getValue() .onSharedPreferenceChanged(sharedPreferences, NOT_TEST_KEY); assertThat(updatable, UpdatableUpdated.wasNotUpdated()); }