@Test
public void testSwitchWithSubsequenceComplete() {

    Observable<Observable<String>> source = Observable.create(new Observable.OnSubscribeFunc<Observable<String>>() {
        @Override
        public Subscription onSubscribe(Observer<? super Observable<String>> observer) {
            publishNext(observer, 50, Observable.create(new Observable.OnSubscribeFunc<String>() {
                @Override
                public Subscription onSubscribe(Observer<? super String> observer) {
                    publishNext(observer, 50, "one");
                    publishNext(observer, 100, "two");
                    return Subscriptions.empty();
                }
            }));
            publishNext(observer, 130, Observable.create(new Observable.OnSubscribeFunc<String>() {
                @Override
                public Subscription onSubscribe(Observer<? super String> observer) {
                    publishCompleted(observer, 0);
                    return Subscriptions.empty();
                }
            }));
            publishNext(observer, 150, Observable.create(new Observable.OnSubscribeFunc<String>() {
                @Override
                public Subscription onSubscribe(Observer<? super String> observer) {
                    publishNext(observer, 50, "three");
                    return Subscriptions.empty();
                }
            }));
            return Subscriptions.empty();
        }
    });
    Observable<String> sampled = Observable.create(OperationSwitch.switchDo(source));
    sampled.subscribe(observer);
    InOrder inOrder = inOrder(observer);
    scheduler.advanceTimeTo(90, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, never()).onNext(anyString());
    verify(observer, never()).onCompleted();
    verify(observer, never()).onError(any(Throwable.class));
    scheduler.advanceTimeTo(125, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, times(1)).onNext("one");
    verify(observer, never()).onCompleted();
    verify(observer, never()).onError(any(Throwable.class));
    scheduler.advanceTimeTo(250, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, times(1)).onNext("three");
    verify(observer, never()).onCompleted();
    verify(observer, never()).onError(any(Throwable.class));
}