Search in sources :

Example 71 with InOrder

use of org.mockito.InOrder in project RxJava by ReactiveX.

the class FlowableRetryWithPredicateTest method testRetryOnSpecificException.

@Test
public void testRetryOnSpecificException() {
    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(new IOException());
                return;
            }
            t1.onNext(2);
            t1.onNext(3);
            t1.onComplete();
        }
    });
    @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).onComplete();
    verify(o, never()).onError(any(Throwable.class));
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) InOrder(org.mockito.InOrder) IOException(java.io.IOException) Test(org.junit.Test)

Example 72 with InOrder

use of org.mockito.InOrder in project RxJava by ReactiveX.

the class FlowableSampleTest method sampleWithSamplerThrows.

@Test
public void sampleWithSamplerThrows() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    PublishProcessor<Integer> sampler = PublishProcessor.create();
    Flowable<Integer> m = source.sample(sampler);
    m.subscribe(observer2);
    source.onNext(1);
    sampler.onNext(1);
    sampler.onError(new RuntimeException("Forced failure!"));
    InOrder inOrder = inOrder(observer2);
    inOrder.verify(observer2, times(1)).onNext(1);
    inOrder.verify(observer2, times(1)).onError(any(RuntimeException.class));
    verify(observer, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder)

Example 73 with InOrder

use of org.mockito.InOrder in project RxJava by ReactiveX.

the class FlowableLastTest method testLastOrDefault.

@Test
public void testLastOrDefault() {
    Single<Integer> observable = Flowable.just(1, 2, 3).last(4);
    SingleObserver<Integer> observer = TestHelper.mockSingleObserver();
    observable.subscribe(observer);
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onSuccess(3);
    //        inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 74 with InOrder

use of org.mockito.InOrder in project RxJava by ReactiveX.

the class FlowableLastTest method testLastOrDefaultWithEmpty.

@Test
public void testLastOrDefaultWithEmpty() {
    Single<Integer> observable = Flowable.<Integer>empty().last(1);
    SingleObserver<Integer> observer = TestHelper.mockSingleObserver();
    observable.subscribe(observer);
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onSuccess(1);
    //        inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 75 with InOrder

use of org.mockito.InOrder in project RxJava by ReactiveX.

the class FlowableLastTest method testLastWithPredicateAndOneElement.

@Test
public void testLastWithPredicateAndOneElement() {
    Maybe<Integer> observable = Flowable.just(1, 2).filter(new Predicate<Integer>() {

        @Override
        public boolean test(Integer t1) {
            return t1 % 2 == 0;
        }
    }).lastElement();
    MaybeObserver<Integer> observer = TestHelper.mockMaybeObserver();
    observable.subscribe(observer);
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onSuccess(2);
    //        inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
}
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