use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableObserveOnTest method observeSameOnMultipleSchedulers.
@Test
public void observeSameOnMultipleSchedulers() {
TestScheduler scheduler1 = new TestScheduler();
TestScheduler scheduler2 = new TestScheduler();
Flowable<Integer> o = Flowable.just(1, 2, 3);
Flowable<Integer> o1 = o.observeOn(scheduler1);
Flowable<Integer> o2 = o.observeOn(scheduler2);
Subscriber<Object> observer1 = TestHelper.mockSubscriber();
Subscriber<Object> observer2 = TestHelper.mockSubscriber();
InOrder inOrder1 = inOrder(observer1);
InOrder inOrder2 = inOrder(observer2);
o1.subscribe(observer1);
o2.subscribe(observer2);
scheduler1.advanceTimeBy(1, TimeUnit.SECONDS);
scheduler2.advanceTimeBy(1, TimeUnit.SECONDS);
inOrder1.verify(observer1, times(1)).onNext(1);
inOrder1.verify(observer1, times(1)).onNext(2);
inOrder1.verify(observer1, times(1)).onNext(3);
inOrder1.verify(observer1, times(1)).onComplete();
verify(observer1, never()).onError(any(Throwable.class));
inOrder1.verifyNoMoreInteractions();
inOrder2.verify(observer2, times(1)).onNext(1);
inOrder2.verify(observer2, times(1)).onNext(2);
inOrder2.verify(observer2, times(1)).onNext(3);
inOrder2.verify(observer2, times(1)).onComplete();
verify(observer2, never()).onError(any(Throwable.class));
inOrder2.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableFirstTest method testFirstOrDefaultWithPredicateFlowable.
@Test
public void testFirstOrDefaultWithPredicateFlowable() {
Flowable<Integer> observable = Flowable.just(1, 2, 3, 4, 5, 6).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).first(8).toFlowable();
Subscriber<Integer> observer = TestHelper.mockSubscriber();
observable.subscribe(observer);
InOrder inOrder = inOrder(observer);
inOrder.verify(observer, times(1)).onNext(2);
inOrder.verify(observer, times(1)).onComplete();
inOrder.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableFirstTest method testFirstWithOneElement.
@Test
public void testFirstWithOneElement() {
Maybe<Integer> observable = Flowable.just(1).firstElement();
observable.subscribe(wm);
InOrder inOrder = inOrder(wm);
inOrder.verify(wm, times(1)).onSuccess(1);
inOrder.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableFirstTest method testFirstWithEmpty.
@Test
public void testFirstWithEmpty() {
Maybe<Integer> observable = Flowable.<Integer>empty().firstElement();
observable.subscribe(wm);
InOrder inOrder = inOrder(wm);
inOrder.verify(wm).onComplete();
inOrder.verify(wm, never()).onError(any(Throwable.class));
inOrder.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableFirstTest method testFirstOrDefaultWithPredicateAndOneElementFlowable.
@Test
public void testFirstOrDefaultWithPredicateAndOneElementFlowable() {
Flowable<Integer> observable = Flowable.just(1, 2).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).first(4).toFlowable();
Subscriber<Integer> observer = TestHelper.mockSubscriber();
observable.subscribe(observer);
InOrder inOrder = inOrder(observer);
inOrder.verify(observer, times(1)).onNext(2);
inOrder.verify(observer, times(1)).onComplete();
inOrder.verifyNoMoreInteractions();
}
Aggregations