use of io.reactivex.FlowableOperator in project RxJava by ReactiveX.
the class FlowableSwitchIfEmptyTest method testSwitchTriggerUnsubscribe.
@Test
public void testSwitchTriggerUnsubscribe() throws Exception {
final BooleanSubscription bs = new BooleanSubscription();
Flowable<Long> withProducer = Flowable.unsafeCreate(new Publisher<Long>() {
@Override
public void subscribe(final Subscriber<? super Long> subscriber) {
subscriber.onSubscribe(bs);
subscriber.onNext(42L);
}
});
Flowable.<Long>empty().switchIfEmpty(withProducer).lift(new FlowableOperator<Long, Long>() {
@Override
public Subscriber<? super Long> apply(final Subscriber<? super Long> child) {
return new DefaultSubscriber<Long>() {
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Long aLong) {
cancel();
}
};
}
}).subscribe();
assertTrue(bs.isCancelled());
// FIXME no longer assertable
// assertTrue(sub.isUnsubscribed());
}
Aggregations