Search in sources :

Example 41 with CompletableSubject

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

the class CompletableDoOnLifecycleTest method onDisposeCrash.

@Test
public void onDisposeCrash() throws Throwable {
    TestHelper.withErrorTracking(errors -> {
        @SuppressWarnings("unchecked") Consumer<? super Disposable> onSubscribe = mock(Consumer.class);
        Action onDispose = mock(Action.class);
        doThrow(new TestException("First")).when(onDispose).run();
        CompletableSubject cs = CompletableSubject.create();
        TestObserver<Void> to = cs.doOnLifecycle(onSubscribe, onDispose).test();
        assertTrue(cs.hasObservers());
        to.dispose();
        assertFalse(cs.hasObservers());
        TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
        verify(onSubscribe).accept(any());
        verify(onDispose).run();
    });
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 42 with CompletableSubject

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

the class CompletableDoOnLifecycleTest method dispose.

@Test
public void dispose() throws Throwable {
    @SuppressWarnings("unchecked") Consumer<? super Disposable> onSubscribe = mock(Consumer.class);
    Action onDispose = mock(Action.class);
    CompletableSubject cs = CompletableSubject.create();
    TestObserver<Void> to = cs.doOnLifecycle(onSubscribe, onDispose).test();
    assertTrue(cs.hasObservers());
    to.dispose();
    assertFalse(cs.hasObservers());
    verify(onSubscribe).accept(any());
    verify(onDispose).run();
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 43 with CompletableSubject

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

the class CompletableTakeUntilTest method otherCompletes.

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

Example 44 with CompletableSubject

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

the class CompletableTakeUntilTest method isDisposed.

@Test
public void isDisposed() {
    CompletableSubject cs1 = CompletableSubject.create();
    CompletableSubject cs2 = CompletableSubject.create();
    TestHelper.checkDisposed(cs1.takeUntil(cs2));
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 45 with CompletableSubject

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

the class CompletableTakeUntilTest method otherErrors.

@Test
public void otherErrors() {
    CompletableSubject cs1 = CompletableSubject.create();
    CompletableSubject cs2 = CompletableSubject.create();
    TestObserver<Void> to = cs1.takeUntil(cs2).test();
    to.assertEmpty();
    assertTrue(cs1.hasObservers());
    assertTrue(cs2.hasObservers());
    cs2.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)

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