Search in sources :

Example 11 with Predicate

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();
}
Also used : InOrder(org.mockito.InOrder) Predicate(io.reactivex.functions.Predicate)

Example 12 with Predicate

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();
}
Also used : InOrder(org.mockito.InOrder) Predicate(io.reactivex.functions.Predicate)

Example 13 with Predicate

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();
}
Also used : InOrder(org.mockito.InOrder) Predicate(io.reactivex.functions.Predicate)

Aggregations

Predicate (io.reactivex.functions.Predicate)13 InOrder (org.mockito.InOrder)12