MediatorLiveData extends MutableLiveData<T> { @MainThread public <S> void removeSource(LiveData<S> toRemote) { Source<?> source = mSources.remove(toRemote); if (source != null) { source.unplug(); } }  @MainThread void addSource(LiveData<S> source, Observer<S> onChanged); @MainThread void removeSource(LiveData<S> toRemote);  }
@Test public void testRemoveSource() { mSource.setValue("flatfoot"); Observer observer = mock(Observer.class); mMediator.addSource(mSource, observer); verify(observer).onChanged("flatfoot"); mMediator.removeSource(mSource); reset(observer); mSource.setValue("failure"); verify(observer, never()).onChanged(any()); }