Search in sources :

Example 6 with MaybeSubject

use of io.reactivex.rxjava3.subjects.MaybeSubject in project RxJava by ReactiveX.

the class FlowableMergeWithMaybeTest method cancelOtherOnMainError.

@Test
public void cancelOtherOnMainError() {
    PublishProcessor<Integer> pp = PublishProcessor.create();
    MaybeSubject<Integer> ms = MaybeSubject.create();
    TestSubscriber<Integer> ts = pp.mergeWith(ms).test();
    assertTrue(pp.hasSubscribers());
    assertTrue(ms.hasObservers());
    pp.onError(new TestException());
    ts.assertFailure(TestException.class);
    assertFalse("main has observers!", pp.hasSubscribers());
    assertFalse("other has observers", ms.hasObservers());
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 7 with MaybeSubject

use of io.reactivex.rxjava3.subjects.MaybeSubject in project RxJava by ReactiveX.

the class ObservableMergeWithMaybeTest method cancelOtherOnMainError.

@Test
public void cancelOtherOnMainError() {
    PublishSubject<Integer> ps = PublishSubject.create();
    MaybeSubject<Integer> ms = MaybeSubject.create();
    TestObserver<Integer> to = ps.mergeWith(ms).test();
    assertTrue(ps.hasObservers());
    assertTrue(ms.hasObservers());
    ps.onError(new TestException());
    to.assertFailure(TestException.class);
    assertFalse("main has observers!", ps.hasObservers());
    assertFalse("other has observers", ms.hasObservers());
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 8 with MaybeSubject

use of io.reactivex.rxjava3.subjects.MaybeSubject in project RxJava by ReactiveX.

the class MaybeSwitchOnNextTest method delaySwitch.

@Test
public void delaySwitch() {
    PublishProcessor<Maybe<Integer>> pp = PublishProcessor.create();
    TestSubscriber<Integer> ts = Maybe.switchOnNextDelayError(pp).test();
    assertTrue(pp.hasSubscribers());
    ts.assertEmpty();
    MaybeSubject<Integer> ms1 = MaybeSubject.create();
    MaybeSubject<Integer> ms2 = MaybeSubject.create();
    pp.onNext(ms1);
    assertTrue(ms1.hasObservers());
    pp.onNext(ms2);
    assertFalse(ms1.hasObservers());
    assertTrue(ms2.hasObservers());
    assertTrue(ms2.hasObservers());
    ms2.onError(new TestException());
    assertTrue(pp.hasSubscribers());
    ts.assertEmpty();
    pp.onComplete();
    ts.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 9 with MaybeSubject

use of io.reactivex.rxjava3.subjects.MaybeSubject in project RxJava by ReactiveX.

the class MaybeTakeUntilTest method untilPublisherOtherError.

@Test
public void untilPublisherOtherError() {
    MaybeSubject<Integer> main = MaybeSubject.create();
    PublishProcessor<Integer> other = PublishProcessor.create();
    TestObserver<Integer> to = main.takeUntil(other).test();
    assertTrue("Main no observers?", main.hasObservers());
    assertTrue("Other no observers?", other.hasSubscribers());
    other.onError(new TestException());
    assertFalse("Main has observers?", main.hasObservers());
    assertFalse("Other has observers?", other.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 10 with MaybeSubject

use of io.reactivex.rxjava3.subjects.MaybeSubject in project RxJava by ReactiveX.

the class MaybeDoOnLifecycleTest method onDisposeCrash.

@Test
public void onDisposeCrash() throws Throwable {
    TestHelper.withErrorTracking(errors -> {
        @SuppressWarnings("unchecked") Consumer<? super Disposable> onSubscribe = mock(Consumer.class);
        Action onDispose = mock(Action.class);
        doThrow(new TestException("First")).when(onDispose).run();
        MaybeSubject<Integer> ms = MaybeSubject.create();
        TestObserver<Integer> to = ms.doOnLifecycle(onSubscribe, onDispose).test();
        assertTrue(ms.hasObservers());
        to.dispose();
        assertFalse(ms.hasObservers());
        TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
        verify(onSubscribe).accept(any());
        verify(onDispose).run();
    });
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)10 Test (org.junit.Test)10