Search in sources :

Example 46 with CompletableSubject

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

the class CompletableTakeUntilTest method consumerDisposes.

@Test
public void consumerDisposes() {
    CompletableSubject cs1 = CompletableSubject.create();
    CompletableSubject cs2 = CompletableSubject.create();
    TestObserver<Void> to = cs1.takeUntil(cs2).test();
    to.assertEmpty();
    assertTrue(cs1.hasObservers());
    assertTrue(cs2.hasObservers());
    to.dispose();
    assertFalse(cs1.hasObservers());
    assertFalse(cs2.hasObservers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 47 with CompletableSubject

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

the class CompletableTakeUntilTest method mainCompletes.

@Test
public void mainCompletes() {
    CompletableSubject cs1 = CompletableSubject.create();
    CompletableSubject cs2 = CompletableSubject.create();
    TestObserver<Void> to = cs1.takeUntil(cs2).test();
    to.assertEmpty();
    assertTrue(cs1.hasObservers());
    assertTrue(cs2.hasObservers());
    cs1.onComplete();
    assertFalse(cs1.hasObservers());
    assertFalse(cs2.hasObservers());
    to.assertResult();
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 48 with CompletableSubject

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

the class CompletableSwitchOnNextTest method noDelaySwitch.

@Test
public void noDelaySwitch() {
    PublishProcessor<Completable> pp = PublishProcessor.create();
    TestObserver<Void> to = Completable.switchOnNext(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());
    pp.onComplete();
    assertTrue(cs2.hasObservers());
    cs2.onComplete();
    to.assertResult();
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 49 with CompletableSubject

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

the class ObservableConcatWithCompletableTest method cancelOther.

@Test
public void cancelOther() {
    CompletableSubject other = CompletableSubject.create();
    TestObserver<Object> to = Observable.empty().concatWith(other).test();
    assertTrue(other.hasObservers());
    to.dispose();
    assertFalse(other.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