Search in sources :

Example 31 with CompletableSubject

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

the class FlowableSwitchMapCompletableTest method innerErrorDelayed.

@Test
public void innerErrorDelayed() {
    final PublishProcessor<Integer> pp = PublishProcessor.create();
    final CompletableSubject cs = CompletableSubject.create();
    TestObserver<Void> to = pp.switchMapCompletableDelayError(Functions.justFunction(cs)).test();
    pp.onNext(1);
    cs.onError(new TestException());
    to.assertEmpty();
    assertTrue(pp.hasSubscribers());
    pp.onComplete();
    to.assertFailure(TestException.class);
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 32 with CompletableSubject

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

the class FlowableSwitchMapCompletableTest method mainCompletesinnerErrorDelayed.

@Test
public void mainCompletesinnerErrorDelayed() {
    final PublishProcessor<Integer> pp = PublishProcessor.create();
    final CompletableSubject cs = CompletableSubject.create();
    TestObserver<Void> to = pp.switchMapCompletableDelayError(Functions.justFunction(cs)).test();
    pp.onNext(1);
    pp.onComplete();
    to.assertEmpty();
    cs.onError(new TestException());
    to.assertFailure(TestException.class);
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 33 with CompletableSubject

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

the class FlowableSwitchMapCompletableTest method checkDisposed.

@Test
public void checkDisposed() {
    PublishProcessor<Integer> pp = PublishProcessor.create();
    CompletableSubject cs = CompletableSubject.create();
    TestHelper.checkDisposed(pp.switchMapCompletable(Functions.justFunction(cs)));
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 34 with CompletableSubject

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

the class FlowableConcatMapCompletableTest method immediateError2.

@Test
public void immediateError2() {
    PublishProcessor<Integer> pp = PublishProcessor.create();
    CompletableSubject cs = CompletableSubject.create();
    TestObserver<Void> to = pp.concatMapCompletable(Functions.justFunction(cs)).test();
    to.assertEmpty();
    assertTrue(pp.hasSubscribers());
    assertFalse(cs.hasObservers());
    pp.onNext(1);
    assertTrue(cs.hasObservers());
    cs.onError(new TestException());
    assertFalse(pp.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 35 with CompletableSubject

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

the class FlowableConcatMapCompletableTest method disposeInDrainLoop.

@Test
public void disposeInDrainLoop() {
    for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
        final PublishProcessor<Integer> pp = PublishProcessor.create();
        final CompletableSubject cs = CompletableSubject.create();
        final TestObserver<Void> to = pp.concatMapCompletable(Functions.justFunction(cs)).test();
        pp.onNext(1);
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                pp.onNext(2);
            }
        };
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                cs.onComplete();
                to.dispose();
            }
        };
        TestHelper.race(r1, r2);
        to.assertEmpty();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)49 CompletableSubject (io.reactivex.rxjava3.subjects.CompletableSubject)41 TestException (io.reactivex.rxjava3.exceptions.TestException)14 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)1