Search in sources :

Example 1 with CompletableSubject

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

the class CompletableToCompletionStageTest method completableManualCompleteExceptionallyCancels.

@Test
public void completableManualCompleteExceptionallyCancels() throws Exception {
    CompletableSubject source = CompletableSubject.create();
    CompletableFuture<Object> cf = source.toCompletionStage(null).toCompletableFuture();
    assertTrue(source.hasObservers());
    cf.completeExceptionally(new TestException());
    assertTrue(cf.isDone());
    assertTrue(cf.isCompletedExceptionally());
    assertFalse(cf.isCancelled());
    assertFalse(source.hasObservers());
    TestHelper.assertError(cf, TestException.class);
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 2 with CompletableSubject

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

the class CompletableToCompletionStageTest method completableManualCompleteCancels.

@Test
public void completableManualCompleteCancels() throws Exception {
    CompletableSubject source = CompletableSubject.create();
    CompletableFuture<Object> cf = source.toCompletionStage(null).toCompletableFuture();
    assertTrue(source.hasObservers());
    cf.complete(1);
    assertTrue(cf.isDone());
    assertFalse(cf.isCompletedExceptionally());
    assertFalse(cf.isCancelled());
    assertFalse(source.hasObservers());
    assertEquals(1, cf.get());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 3 with CompletableSubject

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

the class CompletableSwitchOnNextTest method delaySwitch.

@Test
public void delaySwitch() {
    PublishProcessor<Completable> pp = PublishProcessor.create();
    TestObserver<Void> to = Completable.switchOnNextDelayError(pp).test();
    assertTrue(pp.hasSubscribers());
    to.assertEmpty();
    CompletableSubject cs1 = CompletableSubject.create();
    CompletableSubject cs2 = CompletableSubject.create();
    pp.onNext(cs1);
    assertTrue(cs1.hasObservers());
    pp.onNext(cs2);
    assertFalse(cs1.hasObservers());
    assertTrue(cs2.hasObservers());
    assertTrue(cs2.hasObservers());
    cs2.onError(new TestException());
    assertTrue(pp.hasSubscribers());
    to.assertEmpty();
    pp.onComplete();
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 4 with CompletableSubject

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

the class CompletableAmbTest method untilCompletableOtherError.

@Test
public void untilCompletableOtherError() {
    CompletableSubject main = CompletableSubject.create();
    CompletableSubject other = CompletableSubject.create();
    TestObserver<Void> to = main.ambWith(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 5 with CompletableSubject

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

the class CompletableMergeTest method iterableCompleteLater.

@Test
public void iterableCompleteLater() {
    CompletableSubject cs = CompletableSubject.create();
    TestObserver<Void> to = Completable.mergeDelayError(Arrays.asList(cs, cs, cs)).test();
    to.assertEmpty();
    cs.onComplete();
    to.assertResult();
}
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