Search in sources :

Example 6 with CompletableSubject

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

the class CompletableTakeUntilTest method mainErrors.

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

Example 7 with CompletableSubject

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

the class CompletableDelaySubscriptionTest method disposeMain.

@Test
public void disposeMain() {
    CompletableSubject cs = CompletableSubject.create();
    TestScheduler scheduler = new TestScheduler();
    TestObserver<Void> to = cs.delaySubscription(1, TimeUnit.SECONDS, scheduler).test();
    assertFalse(cs.hasObservers());
    scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
    assertTrue(cs.hasObservers());
    to.dispose();
    assertFalse(cs.hasObservers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) TestScheduler(io.reactivex.rxjava3.schedulers.TestScheduler) Test(org.junit.Test)

Example 8 with CompletableSubject

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

the class CompletableToFutureTest method cancel2.

@Test
public void cancel2() {
    CompletableSubject cs = CompletableSubject.create();
    Future<Void> f = cs.toFuture();
    assertTrue(cs.hasObservers());
    f.cancel(false);
    assertFalse(cs.hasObservers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 9 with CompletableSubject

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

the class CompletableToFutureTest method cancel.

@Test
public void cancel() {
    CompletableSubject cs = CompletableSubject.create();
    Future<Void> f = cs.toFuture();
    assertTrue(cs.hasObservers());
    f.cancel(true);
    assertFalse(cs.hasObservers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 10 with CompletableSubject

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

the class FlowableSwitchMapCompletableTest method innerError.

@Test
public void innerError() {
    PublishProcessor<Integer> pp = PublishProcessor.create();
    CompletableSubject cs = CompletableSubject.create();
    TestObserver<Void> to = pp.switchMapCompletable(Functions.justFunction(cs)).test();
    assertTrue(pp.hasSubscribers());
    assertFalse(cs.hasObservers());
    pp.onNext(1);
    assertTrue(cs.hasObservers());
    to.assertEmpty();
    cs.onError(new TestException());
    to.assertFailure(TestException.class);
    assertFalse(pp.hasSubscribers());
    assertFalse(cs.hasObservers());
}
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