use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableFirstTest method testFirstOrDefaultWithPredicateAndEmpty.
@Test
public void testFirstOrDefaultWithPredicateAndEmpty() {
Single<Integer> observable = Flowable.just(1).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).first(2);
observable.subscribe(wo);
InOrder inOrder = inOrder(wo);
inOrder.verify(wo, times(1)).onSuccess(2);
inOrder.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableFirstTest method testFirstFlowable.
@Test
public void testFirstFlowable() {
Flowable<Integer> observable = Flowable.just(1, 2, 3).firstElement().toFlowable();
Subscriber<Integer> observer = TestHelper.mockSubscriber();
observable.subscribe(observer);
InOrder inOrder = inOrder(observer);
inOrder.verify(observer, times(1)).onNext(1);
inOrder.verify(observer, times(1)).onComplete();
inOrder.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableRetryWithPredicateTest method testRetryOnSpecificExceptionAndNotOther.
@Test
public void testRetryOnSpecificExceptionAndNotOther() {
final IOException ioe = new IOException();
final TestException te = new TestException();
Flowable<Integer> source = Flowable.unsafeCreate(new Publisher<Integer>() {
int count;
@Override
public void subscribe(Subscriber<? super Integer> t1) {
t1.onSubscribe(new BooleanSubscription());
count++;
t1.onNext(0);
t1.onNext(1);
if (count == 1) {
t1.onError(ioe);
return;
}
t1.onNext(2);
t1.onNext(3);
t1.onError(te);
}
});
@SuppressWarnings("unchecked") DefaultSubscriber<Integer> o = mock(DefaultSubscriber.class);
InOrder inOrder = inOrder(o);
source.retry(retryOnTestException).subscribe(o);
inOrder.verify(o).onNext(0);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(0);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(2);
inOrder.verify(o).onNext(3);
inOrder.verify(o).onError(te);
verify(o, never()).onError(ioe);
verify(o, never()).onComplete();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableRetryWithPredicateTest method testUnsubscribeAfterError.
@Test(timeout = 10000)
public void testUnsubscribeAfterError() {
Subscriber<Long> observer = TestHelper.mockSubscriber();
// Flowable that always fails after 100ms
FlowableRetryTest.SlowFlowable so = new FlowableRetryTest.SlowFlowable(100, 0);
Flowable<Long> o = Flowable.unsafeCreate(so).retry(retry5);
FlowableRetryTest.AsyncObserver<Long> async = new FlowableRetryTest.AsyncObserver<Long>(observer);
o.subscribe(async);
async.await();
InOrder inOrder = inOrder(observer);
// Should fail once
inOrder.verify(observer, times(1)).onError(any(Throwable.class));
inOrder.verify(observer, never()).onComplete();
assertEquals("Start 6 threads, retry 5 then fail on 6", 6, so.efforts.get());
assertEquals("Only 1 active subscription", 1, so.maxActive.get());
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableRetryWithPredicateTest method testWithNothingToRetry.
@Test
public void testWithNothingToRetry() {
Flowable<Integer> source = Flowable.range(0, 3);
Subscriber<Integer> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.retry(retryTwice).subscribe(o);
inOrder.verify(o).onNext(0);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(2);
inOrder.verify(o).onComplete();
verify(o, never()).onError(any(Throwable.class));
}
Aggregations