Search in sources :

Example 16 with CompletableSubject

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

the class FlowableConcatMapCompletableTest method doneButNotEmpty.

@Test
public void doneButNotEmpty() {
    final PublishProcessor<Integer> pp = PublishProcessor.create();
    final CompletableSubject cs = CompletableSubject.create();
    final TestObserver<Void> to = pp.concatMapCompletable(Functions.justFunction(cs)).test();
    pp.onNext(1);
    pp.onNext(2);
    pp.onComplete();
    cs.onComplete();
    to.assertResult();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 17 with CompletableSubject

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

the class SingleTakeUntilTest method untilCompletableMainError.

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

Example 18 with CompletableSubject

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

the class SingleTakeUntilTest method untilCompletableOtherError.

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

Example 19 with CompletableSubject

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

the class CompletableToCompletionStageTest method completableFutureCancels.

@Test
public void completableFutureCancels() throws Exception {
    CompletableSubject source = CompletableSubject.create();
    CompletableFuture<Object> cf = source.toCompletionStage(null).toCompletableFuture();
    assertTrue(source.hasObservers());
    cf.cancel(true);
    assertTrue(cf.isCancelled());
    assertFalse(source.hasObservers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 20 with CompletableSubject

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

the class FlowableMergeWithCompletableTest method completeRace.

@Test
public void completeRace() {
    for (int i = 0; i < 1000; i++) {
        final PublishProcessor<Integer> pp = PublishProcessor.create();
        final CompletableSubject cs = CompletableSubject.create();
        TestSubscriber<Integer> ts = pp.mergeWith(cs).test();
        Runnable r1 = new Runnable() {

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

            @Override
            public void run() {
                cs.onComplete();
            }
        };
        TestHelper.race(r1, r2);
        ts.assertResult(1);
    }
}
Also used : 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