Search in sources :

Example 46 with InOrder

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

the class FlowableDelayTest method testDelayWithFlowableNormal1.

@Test
public void testDelayWithFlowableNormal1() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    final List<PublishProcessor<Integer>> delays = new ArrayList<PublishProcessor<Integer>>();
    final int n = 10;
    for (int i = 0; i < n; i++) {
        PublishProcessor<Integer> delay = PublishProcessor.create();
        delays.add(delay);
    }
    Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer t1) {
            return delays.get(t1);
        }
    };
    Subscriber<Object> o = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(o);
    source.delay(delayFunc).subscribe(o);
    for (int i = 0; i < n; i++) {
        source.onNext(i);
        delays.get(i).onNext(i);
        inOrder.verify(o).onNext(i);
    }
    source.onComplete();
    inOrder.verify(o).onComplete();
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder) PublishProcessor(io.reactivex.processors.PublishProcessor)

Example 47 with InOrder

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

the class FlowableDelayTest method testDelayWithFlowableDelayFunctionThrows.

@Test
public void testDelayWithFlowableDelayFunctionThrows() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer t1) {
            throw new TestException();
        }
    };
    Subscriber<Object> o = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(o);
    source.delay(delayFunc).subscribe(o);
    source.onNext(1);
    inOrder.verify(o).onError(any(TestException.class));
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onNext(any());
    verify(o, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder) TestException(io.reactivex.exceptions.TestException)

Example 48 with InOrder

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

the class FlowableDelayTest method testDelayWithError.

@Test
public void testDelayWithError() {
    Flowable<Long> source = Flowable.interval(1L, TimeUnit.SECONDS, scheduler).map(new Function<Long, Long>() {

        @Override
        public Long apply(Long value) {
            if (value == 1L) {
                throw new RuntimeException("error!");
            }
            return value;
        }
    });
    Flowable<Long> delayed = source.delay(1L, TimeUnit.SECONDS, scheduler);
    delayed.subscribe(observer);
    InOrder inOrder = inOrder(observer);
    scheduler.advanceTimeTo(1999L, TimeUnit.MILLISECONDS);
    verify(observer, never()).onNext(anyLong());
    verify(observer, never()).onComplete();
    verify(observer, never()).onError(any(Throwable.class));
    scheduler.advanceTimeTo(2000L, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, times(1)).onError(any(Throwable.class));
    inOrder.verify(observer, never()).onNext(anyLong());
    verify(observer, never()).onComplete();
    scheduler.advanceTimeTo(5000L, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, never()).onNext(anyLong());
    inOrder.verify(observer, never()).onError(any(Throwable.class));
    verify(observer, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder)

Example 49 with InOrder

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

the class FlowableDelayTest method testDelayWithFlowableSourceThrows.

@Test
public void testDelayWithFlowableSourceThrows() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    final PublishProcessor<Integer> delay = PublishProcessor.create();
    Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer t1) {
            return delay;
        }
    };
    Subscriber<Object> o = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(o);
    source.delay(delayFunc).subscribe(o);
    source.onNext(1);
    source.onError(new TestException());
    delay.onNext(1);
    inOrder.verify(o).onError(any(TestException.class));
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onNext(any());
    verify(o, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder) TestException(io.reactivex.exceptions.TestException)

Example 50 with InOrder

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

the class FlowableDelayTest method testDelayWithFlowableSubscriptionFunctionThrows.

@Test
public void testDelayWithFlowableSubscriptionFunctionThrows() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    final PublishProcessor<Integer> delay = PublishProcessor.create();
    Callable<Flowable<Integer>> subFunc = new Callable<Flowable<Integer>>() {

        @Override
        public Flowable<Integer> call() {
            throw new TestException();
        }
    };
    Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer t1) {
            return delay;
        }
    };
    Subscriber<Object> o = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(o);
    source.delay(Flowable.defer(subFunc), delayFunc).subscribe(o);
    source.onNext(1);
    delay.onNext(1);
    source.onNext(2);
    inOrder.verify(o).onError(any(TestException.class));
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onNext(any());
    verify(o, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder) TestException(io.reactivex.exceptions.TestException)

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