Search in sources :

Example 66 with InOrder

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

Example 67 with InOrder

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

Example 68 with InOrder

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();
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) InOrder(org.mockito.InOrder) IOException(java.io.IOException) Test(org.junit.Test)

Example 69 with InOrder

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());
}
Also used : InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 70 with InOrder

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));
}
Also used : InOrder(org.mockito.InOrder) Test(org.junit.Test)

Aggregations

InOrder (org.mockito.InOrder)3292 Test (org.junit.Test)2308 Test (org.junit.jupiter.api.Test)377 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)108 HashMap (java.util.HashMap)104 ArrayList (java.util.ArrayList)98 Response (com.jayway.restassured.response.Response)79 Matchers.containsString (org.hamcrest.Matchers.containsString)69 IOException (java.io.IOException)64 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)63 SmallTest (org.mule.tck.size.SmallTest)62 List (java.util.List)57 CompletableFuture (java.util.concurrent.CompletableFuture)52 Cleanup (lombok.Cleanup)46 InvocationOnMock (org.mockito.invocation.InvocationOnMock)46 WireCommands (io.pravega.shared.protocol.netty.WireCommands)45 ProcessorInterceptor (org.mule.runtime.api.interception.ProcessorInterceptor)44 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)44 Metadata (io.grpc.Metadata)43 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)41