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);
}
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());
}
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);
}
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);
}
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();
}
Aggregations