@Test
public void addSourceDuringOnActive() {

    mRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP);
    mSource.setValue("a");
    mMediator.addSource(mSource, new Observer<String>() {
        @Override
        public void onChanged(@Nullable String s) {
            MutableLiveData<String> source = new MutableLiveData<>();
            source.setValue("b");
            mMediator.addSource(source, new Observer<String>() {
                @Override
                public void onChanged(@Nullable String s) {
                    mMediator.setValue("c");
                }
            });
        }
    });
    mRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START);
    assertThat(mMediator.getValue(), is("c"));
}