use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class ObservableTakeUntilPredicateTest method sourceThrows.
@Test
public void sourceThrows() {
Observer<Object> o = TestHelper.mockObserver();
Observable.just(1).concatWith(Observable.<Integer>error(new TestException())).concatWith(Observable.just(2)).takeUntil(new Predicate<Integer>() {
@Override
public boolean test(Integer v) {
return false;
}
}).subscribe(o);
verify(o).onNext(1);
verify(o, never()).onNext(2);
verify(o).onError(any(TestException.class));
verify(o, never()).onComplete();
}
use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class FlowableRetryPredicate method subscribeActual.
@Override
public void subscribeActual(Subscriber<? super T> s) {
SubscriptionArbiter sa = new SubscriptionArbiter(false);
s.onSubscribe(sa);
RetrySubscriber<T> rs = new RetrySubscriber<>(s, count, predicate, sa, source);
rs.subscribeNext();
}
use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class ObservableRetryBiPredicate method subscribeActual.
@Override
public void subscribeActual(Observer<? super T> observer) {
SequentialDisposable sa = new SequentialDisposable();
observer.onSubscribe(sa);
RetryBiObserver<T> rs = new RetryBiObserver<>(observer, predicate, sa, source);
rs.subscribeNext();
}
use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class FlowableTakeUntilPredicateTest method errorIncludesLastValueAsCause.
@Test
public void errorIncludesLastValueAsCause() {
TestSubscriberEx<String> ts = new TestSubscriberEx<>();
final TestException e = new TestException("Forced failure");
Predicate<String> predicate = new Predicate<String>() {
@Override
public boolean test(String t) {
throw e;
}
};
Flowable.just("abc").takeUntil(predicate).subscribe(ts);
ts.assertTerminated();
ts.assertNotComplete();
ts.assertError(TestException.class);
// FIXME last cause value is not saved
// assertTrue(ts.errors().get(0).getCause().getMessage().contains("abc"));
}
use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class FlowableTakeWhileTest method unsubscribeAfterTake.
@Test
public void unsubscribeAfterTake() {
Subscription s = mock(Subscription.class);
TestFlowable w = new TestFlowable(s, "one", "two", "three");
Subscriber<String> subscriber = TestHelper.mockSubscriber();
Flowable<String> take = Flowable.unsafeCreate(w).takeWhile(new Predicate<String>() {
int index;
@Override
public boolean test(String s) {
return index++ < 1;
}
});
take.subscribe(subscriber);
// wait for the Flowable to complete
try {
w.t.join();
} catch (Throwable e) {
e.printStackTrace();
fail(e.getMessage());
}
System.out.println("TestFlowable thread finished");
verify(subscriber, times(1)).onNext("one");
verify(subscriber, never()).onNext("two");
verify(subscriber, never()).onNext("three");
verify(s, times(1)).cancel();
}
Aggregations