Search in sources :

Example 11 with Functions

use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.

the class TestObserverTest method assertErrorMultiple.

@Test
public void assertErrorMultiple() {
    TestObserver<Integer> to = new TestObserver<>();
    TestException e = new TestException();
    to.onError(e);
    to.onError(new TestException());
    try {
        to.assertError(TestException.class);
        throw new RuntimeException("Should have thrown!");
    } catch (AssertionError ex) {
    // expected
    }
    try {
        to.assertError(e);
        throw new RuntimeException("Should have thrown!");
    } catch (AssertionError ex) {
    // expected
    }
    try {
        to.assertError(Functions.<Throwable>alwaysTrue());
        throw new RuntimeException("Should have thrown!");
    } catch (AssertionError ex) {
    // expected
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 12 with Functions

use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.

the class BoundedSubscriberTest method cancel.

@Test
public void cancel() {
    BoundedSubscriber<Integer> subscriber = new BoundedSubscriber<>(Functions.<Integer>emptyConsumer(), Functions.<Throwable>emptyConsumer(), Functions.EMPTY_ACTION, Functions.<Subscription>boundedConsumer(128), 128);
    BooleanSubscription bs = new BooleanSubscription();
    subscriber.onSubscribe(bs);
    subscriber.cancel();
    assertTrue(bs.isCancelled());
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 13 with Functions

use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.

the class BoundedSubscriberTest method dispose.

@Test
public void dispose() {
    BoundedSubscriber<Integer> subscriber = new BoundedSubscriber<>(Functions.<Integer>emptyConsumer(), Functions.<Throwable>emptyConsumer(), Functions.EMPTY_ACTION, Functions.<Subscription>boundedConsumer(128), 128);
    BooleanSubscription bs = new BooleanSubscription();
    subscriber.onSubscribe(bs);
    assertFalse(subscriber.isDisposed());
    subscriber.dispose();
    assertTrue(bs.isCancelled());
    assertTrue(subscriber.isDisposed());
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 14 with Functions

use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.

the class FlowableDematerializeTest method errorPassThru.

@Test
public void errorPassThru() {
    Exception exception = new Exception("test");
    Flowable<Notification<Integer>> flowable = Flowable.error(exception);
    Flowable<Integer> dematerialize = flowable.dematerialize(Functions.<Notification<Integer>>identity());
    Subscriber<Integer> subscriber = TestHelper.mockSubscriber();
    dematerialize.subscribe(subscriber);
    verify(subscriber, times(1)).onError(exception);
    verify(subscriber, times(0)).onComplete();
    verify(subscriber, times(0)).onNext(any(Integer.class));
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 15 with Functions

use of io.reactivex.rxjava3.internal.functions.Functions in project RxJava by ReactiveX.

the class FlowableDematerializeTest method honorsContractWhenThrows.

@Test
public void honorsContractWhenThrows() {
    Flowable<Integer> source = Flowable.error(new TestException());
    Flowable<Integer> result = source.materialize().dematerialize(Functions.<Notification<Integer>>identity());
    Subscriber<Integer> subscriber = TestHelper.mockSubscriber();
    result.subscribe(subscriber);
    verify(subscriber, never()).onNext(any(Integer.class));
    verify(subscriber, never()).onComplete();
    verify(subscriber).onError(any(TestException.class));
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)22 Test (org.junit.Test)22 IOException (java.io.IOException)6 Observable (io.reactivex.rxjava3.core.Observable)5 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)4 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)4 Disposable (io.reactivex.rxjava3.disposables.Disposable)1 ForEachWhileSubscriber (io.reactivex.rxjava3.internal.subscribers.ForEachWhileSubscriber)1 GroupedObservable (io.reactivex.rxjava3.observables.GroupedObservable)1