@Test
public void testSwitchMap2() {

    LiveData<Integer> trigger = new MutableLiveData<>();
    final LiveData<String> first = new MutableLiveData<>();
    final LiveData<String> second = new MutableLiveData<>();
    LiveData<String> result = Transformations.switchMap(trigger,
            new Function<Integer, LiveData<String>>() {
                @Override
                public LiveData<String> apply(Integer input) {
                    if (input == 1) {
                        return first;
                    } else {
                        return second;
                    }
                }
            });
    Observer<String> observer = mock(Observer.class);
    result.observe(mOwner, observer);
    verify(observer, never()).onChanged(anyString());
    trigger.setValue(1);
    verify(observer, never()).onChanged(anyString());
    first.setValue("fi");
    verify(observer).onChanged("fi");
    first.setValue("rst");
    verify(observer).onChanged("rst");
    second.setValue("second");
    reset(observer);
    verify(observer, never()).onChanged(anyString());
    trigger.setValue(2);
    verify(observer).onChanged("second");
    reset(observer);
    first.setValue("failure");
    verify(observer, never()).onChanged(anyString());
}