Search in sources :

Example 51 with InOrder

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

the class FlowableDelayTest method testDelayWithFlowableSubscriptionNormal.

@Test
public void testDelayWithFlowableSubscriptionNormal() {
    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(delay, delayFunc).subscribe(o);
    source.onNext(1);
    delay.onNext(1);
    source.onNext(2);
    delay.onNext(2);
    inOrder.verify(o).onNext(2);
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onError(any(Throwable.class));
    verify(o, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder)

Example 52 with InOrder

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

the class FlowableDelayTest method testDelayWithMultipleSubscriptions.

@Test
public void testDelayWithMultipleSubscriptions() {
    Flowable<Long> source = Flowable.interval(1L, TimeUnit.SECONDS, scheduler).take(3);
    Flowable<Long> delayed = source.delay(500L, TimeUnit.MILLISECONDS, scheduler);
    delayed.subscribe(observer);
    delayed.subscribe(observer2);
    InOrder inOrder = inOrder(observer);
    InOrder inOrder2 = inOrder(observer2);
    scheduler.advanceTimeTo(1499L, TimeUnit.MILLISECONDS);
    verify(observer, never()).onNext(anyLong());
    verify(observer2, never()).onNext(anyLong());
    scheduler.advanceTimeTo(1500L, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, times(1)).onNext(0L);
    inOrder2.verify(observer2, times(1)).onNext(0L);
    scheduler.advanceTimeTo(2499L, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, never()).onNext(anyLong());
    inOrder2.verify(observer2, never()).onNext(anyLong());
    scheduler.advanceTimeTo(2500L, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, times(1)).onNext(1L);
    inOrder2.verify(observer2, times(1)).onNext(1L);
    verify(observer, never()).onComplete();
    verify(observer2, never()).onComplete();
    scheduler.advanceTimeTo(3500L, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, times(1)).onNext(2L);
    inOrder2.verify(observer2, times(1)).onNext(2L);
    inOrder.verify(observer, never()).onNext(anyLong());
    inOrder2.verify(observer2, never()).onNext(anyLong());
    inOrder.verify(observer, times(1)).onComplete();
    inOrder2.verify(observer2, times(1)).onComplete();
    verify(observer, never()).onError(any(Throwable.class));
    verify(observer2, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder)

Example 53 with InOrder

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

the class FlowableDelayTest method testDelayWithFlowableEmptyDelayer.

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

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

Example 54 with InOrder

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

the class FlowableDistinctTest method testDistinctOfNormalSourceWithKeySelector.

@Test
public void testDistinctOfNormalSourceWithKeySelector() {
    Flowable<String> src = Flowable.just("a", "B", "c", "C", "c", "B", "b", "a", "E");
    src.distinct(TO_UPPER_WITH_EXCEPTION).subscribe(w);
    InOrder inOrder = inOrder(w);
    inOrder.verify(w, times(1)).onNext("a");
    inOrder.verify(w, times(1)).onNext("B");
    inOrder.verify(w, times(1)).onNext("c");
    inOrder.verify(w, times(1)).onNext("E");
    inOrder.verify(w, times(1)).onComplete();
    inOrder.verify(w, never()).onNext(anyString());
    verify(w, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder)

Example 55 with InOrder

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

the class FlowableDistinctTest method testDistinctOfNormalSource.

@Test
public void testDistinctOfNormalSource() {
    Flowable<String> src = Flowable.just("a", "b", "c", "c", "c", "b", "b", "a", "e");
    src.distinct().subscribe(w);
    InOrder inOrder = inOrder(w);
    inOrder.verify(w, times(1)).onNext("a");
    inOrder.verify(w, times(1)).onNext("b");
    inOrder.verify(w, times(1)).onNext("c");
    inOrder.verify(w, times(1)).onNext("e");
    inOrder.verify(w, times(1)).onComplete();
    inOrder.verify(w, never()).onNext(anyString());
    verify(w, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder)

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