use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class FlowableAllTest method predicateThrows.
@Test
public void predicateThrows() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
subscriber.onNext(1);
subscriber.onNext(2);
subscriber.onError(new TestException());
subscriber.onComplete();
}
}.all(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).toFlowable().test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class FlowableFirstTest method firstWithPredicate.
@Test
public void firstWithPredicate() {
Maybe<Integer> maybe = Flowable.just(1, 2, 3, 4, 5, 6).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).firstElement();
maybe.subscribe(wm);
InOrder inOrder = inOrder(wm);
inOrder.verify(wm, times(1)).onSuccess(2);
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class FlowableFirstTest method firstWithPredicateAndEmpty.
@Test
public void firstWithPredicateAndEmpty() {
Maybe<Integer> maybe = Flowable.just(1).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).firstElement();
maybe.subscribe(wm);
InOrder inOrder = inOrder(wm);
inOrder.verify(wm).onComplete();
inOrder.verify(wm, never()).onError(any(Throwable.class));
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class FlowableFirstTest method firstOrDefaultWithPredicateAndEmpty.
@Test
public void firstOrDefaultWithPredicateAndEmpty() {
Single<Integer> single = Flowable.just(1).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).first(2);
single.subscribe(wo);
InOrder inOrder = inOrder(wo);
inOrder.verify(wo, times(1)).onSuccess(2);
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.rxjava3.functions.Predicate in project RxJava by ReactiveX.
the class ObservableTakeUntilPredicateTest method functionThrows.
@Test
public void functionThrows() {
Observer<Object> o = TestHelper.mockObserver();
Predicate<Integer> predicate = (new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
throw new TestException("Forced failure");
}
});
Observable.just(1, 2, 3).takeUntil(predicate).subscribe(o);
verify(o).onNext(1);
verify(o, never()).onNext(2);
verify(o, never()).onNext(3);
verify(o).onError(any(TestException.class));
verify(o, never()).onComplete();
}
Aggregations