Search in sources :

Example 26 with Functions

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

the class ObservableDematerializeTest method eventsAfterDematerializedTerminal.

@Test
public void eventsAfterDematerializedTerminal() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        new Observable<Notification<Object>>() {

            @Override
            protected void subscribeActual(Observer<? super Notification<Object>> observer) {
                observer.onSubscribe(Disposable.empty());
                observer.onNext(Notification.createOnComplete());
                observer.onNext(Notification.<Object>createOnNext(1));
                observer.onNext(Notification.createOnError(new TestException("First")));
                observer.onError(new TestException("Second"));
            }
        }.dematerialize(Functions.<Notification<Object>>identity()).test().assertResult();
        TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
        TestHelper.assertUndeliverable(errors, 1, TestException.class, "Second");
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 27 with Functions

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

the class SingleSubscribeTest method consumerDispose.

@Test
public void consumerDispose() {
    PublishSubject<Integer> ps = PublishSubject.create();
    Disposable d = ps.single(-99).subscribe(Functions.<Integer>emptyConsumer());
    assertFalse(d.isDisposed());
    d.dispose();
    assertTrue(d.isDisposed());
    assertFalse(ps.hasObservers());
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable) 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