use of io.reactivex.functions.Predicate in project RxJava by ReactiveX.
the class ObservableFirstTest method testFirstOrDefaultWithPredicate.
@Test
public void testFirstOrDefaultWithPredicate() {
Single<Integer> o = Observable.just(1, 2, 3, 4, 5, 6).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).first(8);
o.subscribe(wo);
InOrder inOrder = inOrder(wo);
inOrder.verify(wo, times(1)).onSuccess(2);
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.functions.Predicate in project RxJava by ReactiveX.
the class ObservableFirstTest method testFirstOrDefaultWithPredicateAndEmpty.
@Test
public void testFirstOrDefaultWithPredicateAndEmpty() {
Single<Integer> o = Observable.just(1).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).first(2);
o.subscribe(wo);
InOrder inOrder = inOrder(wo);
inOrder.verify(wo, times(1)).onSuccess(2);
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.functions.Predicate in project RxJava by ReactiveX.
the class ObservableFirstTest method testFirstWithPredicateAndOneElement.
@Test
public void testFirstWithPredicateAndOneElement() {
Maybe<Integer> o = Observable.just(1, 2).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).firstElement();
o.subscribe(wm);
InOrder inOrder = inOrder(wm);
inOrder.verify(wm, times(1)).onSuccess(2);
inOrder.verifyNoMoreInteractions();
}