Search in sources :

Example 11 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class XFlatMapTest method flowableSingle.

@Test
public void flowableSingle() throws Exception {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestSubscriber<Integer> ts = Flowable.just(1).subscribeOn(Schedulers.io()).flatMapSingle(new Function<Integer, Single<Integer>>() {

            @Override
            public Single<Integer> apply(Integer v) throws Exception {
                sleep();
                return Single.<Integer>error(new TestException());
            }
        }).test();
        cb.await();
        Thread.sleep(50);
        ts.cancel();
        Thread.sleep(SLEEP_AFTER_CANCEL);
        ts.assertEmpty();
        assertTrue(errors.toString(), errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : Function(io.reactivex.functions.Function) TestException(io.reactivex.exceptions.TestException)

Example 12 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class XFlatMapTest method observableFlowable.

@Test
public void observableFlowable() throws Exception {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserver<Integer> ts = Observable.just(1).subscribeOn(Schedulers.io()).flatMap(new Function<Integer, Observable<Integer>>() {

            @Override
            public Observable<Integer> apply(Integer v) throws Exception {
                sleep();
                return Observable.<Integer>error(new TestException());
            }
        }).test();
        cb.await();
        Thread.sleep(50);
        ts.cancel();
        Thread.sleep(SLEEP_AFTER_CANCEL);
        ts.assertEmpty();
        assertTrue(errors.toString(), errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : Function(io.reactivex.functions.Function) TestException(io.reactivex.exceptions.TestException)

Example 13 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class XFlatMapTest method singleCompletable.

@Test
public void singleCompletable() throws Exception {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserver<Void> ts = Single.just(1).subscribeOn(Schedulers.io()).flatMapCompletable(new Function<Integer, Completable>() {

            @Override
            public Completable apply(Integer v) throws Exception {
                sleep();
                return Completable.error(new TestException());
            }
        }).test();
        cb.await();
        Thread.sleep(50);
        ts.cancel();
        Thread.sleep(SLEEP_AFTER_CANCEL);
        ts.assertEmpty();
        assertTrue(errors.toString(), errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : Function(io.reactivex.functions.Function) TestException(io.reactivex.exceptions.TestException)

Example 14 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class XFlatMapTest method observerMaybe.

@Test
public void observerMaybe() throws Exception {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserver<Integer> ts = Observable.just(1).subscribeOn(Schedulers.io()).flatMapMaybe(new Function<Integer, Maybe<Integer>>() {

            @Override
            public Maybe<Integer> apply(Integer v) throws Exception {
                sleep();
                return Maybe.<Integer>error(new TestException());
            }
        }).test();
        cb.await();
        Thread.sleep(50);
        ts.cancel();
        Thread.sleep(SLEEP_AFTER_CANCEL);
        ts.assertEmpty();
        assertTrue(errors.toString(), errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : Function(io.reactivex.functions.Function) TestException(io.reactivex.exceptions.TestException)

Example 15 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class XFlatMapTest method maybeCompletable.

@Test
public void maybeCompletable() throws Exception {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserver<Void> ts = Maybe.just(1).subscribeOn(Schedulers.io()).flatMapCompletable(new Function<Integer, Completable>() {

            @Override
            public Completable apply(Integer v) throws Exception {
                sleep();
                return Completable.error(new TestException());
            }
        }).test();
        cb.await();
        Thread.sleep(50);
        ts.cancel();
        Thread.sleep(SLEEP_AFTER_CANCEL);
        ts.assertEmpty();
        assertTrue(errors.toString(), errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : Function(io.reactivex.functions.Function) TestException(io.reactivex.exceptions.TestException)

Aggregations

TestException (io.reactivex.exceptions.TestException)417 Test (org.junit.Test)255 InOrder (org.mockito.InOrder)35 IOException (java.io.IOException)28 BooleanSubscription (io.reactivex.internal.subscriptions.BooleanSubscription)26 TestObserver (io.reactivex.observers.TestObserver)26 Observable (io.reactivex.Observable)24 Function (io.reactivex.functions.Function)24 TestSubscriber (io.reactivex.subscribers.TestSubscriber)24 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)23 TestScheduler (io.reactivex.schedulers.TestScheduler)11 Observer (io.reactivex.Observer)8 QueueDisposable (io.reactivex.internal.fuseable.QueueDisposable)8 Disposable (io.reactivex.disposables.Disposable)7 CrashingIterable (io.reactivex.internal.util.CrashingIterable)6 Action (io.reactivex.functions.Action)5 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 ObserveOnObserver (io.reactivex.internal.operators.observable.ObservableObserveOn.ObserveOnObserver)2 ScalarDisposable (io.reactivex.internal.operators.observable.ObservableScalarXMap.ScalarDisposable)2 FutureSubscriber (io.reactivex.internal.subscribers.FutureSubscriber)2