Search in sources :

Example 1 with ConditionalSubscriber

use of io.reactivex.rxjava3.operators.ConditionalSubscriber in project RxJava by ReactiveX.

the class ParallelMapTest method conditionalCancelIgnored.

@Test
public void conditionalCancelIgnored() {
    Flowable<Integer> f = new Flowable<Integer>() {

        @Override
        protected void subscribeActual(@NonNull Subscriber<@NonNull ? super @NonNull Integer> s) {
            @SuppressWarnings("unchecked") ConditionalSubscriber<Integer> subscriber = (ConditionalSubscriber<Integer>) s;
            subscriber.onSubscribe(new BooleanSubscription());
            subscriber.tryOnNext(1);
            subscriber.tryOnNext(2);
        }
    };
    ParallelFlowable.fromArray(f).map(v -> {
        throw new TestException();
    }).filter(v -> true).sequential().test().assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) io.reactivex.rxjava3.functions(io.reactivex.rxjava3.functions) ConditionalSubscriber(io.reactivex.rxjava3.operators.ConditionalSubscriber) Test(org.junit.Test) NonNull(io.reactivex.rxjava3.annotations.NonNull) TimeUnit(java.util.concurrent.TimeUnit) Schedulers(io.reactivex.rxjava3.schedulers.Schedulers) List(java.util.List) TestHelper(io.reactivex.rxjava3.testsupport.TestHelper) Functions(io.reactivex.rxjava3.internal.functions.Functions) io.reactivex.rxjava3.core(io.reactivex.rxjava3.core) Assert(org.junit.Assert) Subscriber(org.reactivestreams.Subscriber) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) RxJavaPlugins(io.reactivex.rxjava3.plugins.RxJavaPlugins) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.rxjava3.exceptions.TestException) ConditionalSubscriber(io.reactivex.rxjava3.operators.ConditionalSubscriber) Subscriber(org.reactivestreams.Subscriber) NonNull(io.reactivex.rxjava3.annotations.NonNull) ConditionalSubscriber(io.reactivex.rxjava3.operators.ConditionalSubscriber) Test(org.junit.Test)

Example 2 with ConditionalSubscriber

use of io.reactivex.rxjava3.operators.ConditionalSubscriber in project RxJava by ReactiveX.

the class FlowableFilterTest method sourceIgnoresCancelConditional.

@Test
public void sourceIgnoresCancelConditional() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        Flowable.fromPublisher(new Publisher<Integer>() {

            @Override
            public void subscribe(Subscriber<? super Integer> s) {
                ConditionalSubscriber<? super Integer> cs = (ConditionalSubscriber<? super Integer>) s;
                cs.onSubscribe(new BooleanSubscription());
                cs.tryOnNext(1);
                cs.tryOnNext(2);
                cs.onError(new IOException());
                cs.onComplete();
            }
        }).filter(new Predicate<Integer>() {

            @Override
            public boolean test(Integer v) throws Exception {
                return true;
            }
        }).filter(new Predicate<Integer>() {

            @Override
            public boolean test(Integer v) throws Exception {
                throw new TestException();
            }
        }).test().assertFailure(TestException.class);
        TestHelper.assertUndeliverable(errors, 0, IOException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.rxjava3.exceptions.TestException) ConditionalSubscriber(io.reactivex.rxjava3.operators.ConditionalSubscriber) IOException(java.io.IOException) TestException(io.reactivex.rxjava3.exceptions.TestException) IOException(java.io.IOException)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)2 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)2 ConditionalSubscriber (io.reactivex.rxjava3.operators.ConditionalSubscriber)2 NonNull (io.reactivex.rxjava3.annotations.NonNull)1 io.reactivex.rxjava3.core (io.reactivex.rxjava3.core)1 io.reactivex.rxjava3.functions (io.reactivex.rxjava3.functions)1 Functions (io.reactivex.rxjava3.internal.functions.Functions)1 RxJavaPlugins (io.reactivex.rxjava3.plugins.RxJavaPlugins)1 Schedulers (io.reactivex.rxjava3.schedulers.Schedulers)1 TestHelper (io.reactivex.rxjava3.testsupport.TestHelper)1 IOException (java.io.IOException)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 Subscriber (org.reactivestreams.Subscriber)1