Search in sources :

Example 56 with InOrder

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

the class FlowableDistinctUntilChangedTest method testDistinctUntilChangedOfNormalSource.

@Test
public void testDistinctUntilChangedOfNormalSource() {
    Flowable<String> src = Flowable.just("a", "b", "c", "c", "c", "b", "b", "a", "e");
    src.distinctUntilChanged().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("b");
    inOrder.verify(w, times(1)).onNext("a");
    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 57 with InOrder

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

the class FlowableDistinctUntilChangedTest method testDistinctUntilChangedOfNormalSourceWithKeySelector.

@Test
public void testDistinctUntilChangedOfNormalSourceWithKeySelector() {
    Flowable<String> src = Flowable.just("a", "b", "c", "C", "c", "B", "b", "a", "e");
    src.distinctUntilChanged(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("B");
    inOrder.verify(w, times(1)).onNext("a");
    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 58 with InOrder

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

the class FlowableLastTest method testLastWithOneElement.

@Test
public void testLastWithOneElement() {
    Maybe<Integer> observable = Flowable.just(1).lastElement();
    MaybeObserver<Integer> observer = TestHelper.mockMaybeObserver();
    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 59 with InOrder

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

the class FlowableObserveOnTest method testDelayedErrorDeliveryWhenSafeSubscriberUnsubscribes.

@Test
public void testDelayedErrorDeliveryWhenSafeSubscriberUnsubscribes() {
    TestScheduler testScheduler = new TestScheduler();
    Flowable<Integer> source = Flowable.concat(Flowable.<Integer>error(new TestException()), Flowable.just(1));
    @SuppressWarnings("unchecked") DefaultSubscriber<Integer> o = mock(DefaultSubscriber.class);
    InOrder inOrder = inOrder(o);
    source.observeOn(testScheduler).subscribe(o);
    inOrder.verify(o, never()).onError(any(TestException.class));
    testScheduler.advanceTimeBy(1, TimeUnit.SECONDS);
    inOrder.verify(o).onError(any(TestException.class));
    inOrder.verify(o, never()).onNext(anyInt());
    inOrder.verify(o, never()).onComplete();
}
Also used : InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 60 with InOrder

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

the class FlowableObserveOnTest method testOrdering.

@Test
public void testOrdering() throws InterruptedException {
    //        Flowable<String> obs = Flowable.just("one", null, "two", "three", "four");
    // FIXME null values not allowed
    Flowable<String> obs = Flowable.just("one", "null", "two", "three", "four");
    Subscriber<String> observer = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(observer);
    TestSubscriber<String> ts = new TestSubscriber<String>(observer);
    obs.observeOn(Schedulers.computation()).subscribe(ts);
    ts.awaitTerminalEvent(1000, TimeUnit.MILLISECONDS);
    if (ts.errors().size() > 0) {
        for (Throwable t : ts.errors()) {
            t.printStackTrace();
        }
        fail("failed with exception");
    }
    inOrder.verify(observer, times(1)).onNext("one");
    inOrder.verify(observer, times(1)).onNext("null");
    inOrder.verify(observer, times(1)).onNext("two");
    inOrder.verify(observer, times(1)).onNext("three");
    inOrder.verify(observer, times(1)).onNext("four");
    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