Search in sources :

Example 36 with InOrder

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

the class FlowableConcatTest method concatVeryLongObservableOfObservables.

@Test
public void concatVeryLongObservableOfObservables() {
    final int n = 10000;
    Flowable<Flowable<Integer>> source = Flowable.range(0, n).map(new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer v) {
            return Flowable.just(v);
        }
    });
    Single<List<Integer>> result = Flowable.concat(source).toList();
    SingleObserver<List<Integer>> o = TestHelper.mockSingleObserver();
    InOrder inOrder = inOrder(o);
    result.subscribe(o);
    List<Integer> list = new ArrayList<Integer>(n);
    for (int i = 0; i < n; i++) {
        list.add(i);
    }
    inOrder.verify(o).onSuccess(list);
    verify(o, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder)

Example 37 with InOrder

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

the class FlowableConcatTest method testMultipleObservers.

@Test
public void testMultipleObservers() {
    Subscriber<Object> o1 = TestHelper.mockSubscriber();
    Subscriber<Object> o2 = TestHelper.mockSubscriber();
    TestScheduler s = new TestScheduler();
    Flowable<Long> timer = Flowable.interval(500, TimeUnit.MILLISECONDS, s).take(2);
    Flowable<Long> o = Flowable.concat(timer, timer);
    o.subscribe(o1);
    o.subscribe(o2);
    InOrder inOrder1 = inOrder(o1);
    InOrder inOrder2 = inOrder(o2);
    s.advanceTimeBy(500, TimeUnit.MILLISECONDS);
    inOrder1.verify(o1, times(1)).onNext(0L);
    inOrder2.verify(o2, times(1)).onNext(0L);
    s.advanceTimeBy(500, TimeUnit.MILLISECONDS);
    inOrder1.verify(o1, times(1)).onNext(1L);
    inOrder2.verify(o2, times(1)).onNext(1L);
    s.advanceTimeBy(500, TimeUnit.MILLISECONDS);
    inOrder1.verify(o1, times(1)).onNext(0L);
    inOrder2.verify(o2, times(1)).onNext(0L);
    s.advanceTimeBy(500, TimeUnit.MILLISECONDS);
    inOrder1.verify(o1, times(1)).onNext(1L);
    inOrder2.verify(o2, times(1)).onNext(1L);
    inOrder1.verify(o1, times(1)).onComplete();
    inOrder2.verify(o2, times(1)).onComplete();
    verify(o1, never()).onError(any(Throwable.class));
    verify(o2, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder)

Example 38 with InOrder

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

the class FlowableConcatTest method concatVeryLongObservableOfObservablesTakeHalf.

@Test
public void concatVeryLongObservableOfObservablesTakeHalf() {
    final int n = 10000;
    Flowable<Flowable<Integer>> source = Flowable.range(0, n).map(new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer v) {
            return Flowable.just(v);
        }
    });
    Single<List<Integer>> result = Flowable.concat(source).take(n / 2).toList();
    SingleObserver<List<Integer>> o = TestHelper.mockSingleObserver();
    InOrder inOrder = inOrder(o);
    result.subscribe(o);
    List<Integer> list = new ArrayList<Integer>(n);
    for (int i = 0; i < n / 2; i++) {
        list.add(i);
    }
    inOrder.verify(o).onSuccess(list);
    verify(o, never()).onError(any(Throwable.class));
}
Also used : InOrder(org.mockito.InOrder)

Example 39 with InOrder

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

the class FlowableAmbTest method testAmb3.

@Test
public void testAmb3() {
    Flowable<String> Flowable1 = createFlowable(new String[] { "1" }, 2000, null);
    Flowable<String> Flowable2 = createFlowable(new String[] {}, 1000, null);
    Flowable<String> Flowable3 = createFlowable(new String[] { "3" }, 3000, null);
    @SuppressWarnings("unchecked") Flowable<String> o = Flowable.ambArray(Flowable1, Flowable2, Flowable3);
    @SuppressWarnings("unchecked") DefaultSubscriber<String> observer = mock(DefaultSubscriber.class);
    o.subscribe(observer);
    scheduler.advanceTimeBy(100000, TimeUnit.MILLISECONDS);
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder)

Example 40 with InOrder

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

the class FlowableAmbTest method testAmb.

@Test
public void testAmb() {
    Flowable<String> Flowable1 = createFlowable(new String[] { "1", "11", "111", "1111" }, 2000, null);
    Flowable<String> Flowable2 = createFlowable(new String[] { "2", "22", "222", "2222" }, 1000, null);
    Flowable<String> Flowable3 = createFlowable(new String[] { "3", "33", "333", "3333" }, 3000, null);
    @SuppressWarnings("unchecked") Flowable<String> o = Flowable.ambArray(Flowable1, Flowable2, Flowable3);
    @SuppressWarnings("unchecked") DefaultSubscriber<String> observer = mock(DefaultSubscriber.class);
    o.subscribe(observer);
    scheduler.advanceTimeBy(100000, TimeUnit.MILLISECONDS);
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onNext("2");
    inOrder.verify(observer, times(1)).onNext("22");
    inOrder.verify(observer, times(1)).onNext("222");
    inOrder.verify(observer, times(1)).onNext("2222");
    inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
}
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