Search in sources :

Example 91 with TestObserver

use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.

the class MaybeTimeoutTest method otherError.

@Test
public void otherError() {
    PublishProcessor<Integer> pp1 = PublishProcessor.create();
    PublishProcessor<Integer> pp2 = PublishProcessor.create();
    TestObserver<Integer> to = pp1.singleElement().timeout(pp2.singleElement()).test();
    assertTrue(pp1.hasSubscribers());
    assertTrue(pp2.hasSubscribers());
    pp2.onError(new TestException());
    assertFalse(pp1.hasSubscribers());
    assertFalse(pp2.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 92 with TestObserver

use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.

the class SingleFlatMapObservableTest method errorOther.

@Test
public void errorOther() {
    SingleSubject<Integer> ss = SingleSubject.create();
    PublishSubject<Integer> ps = PublishSubject.create();
    TestObserver<Integer> to = ss.flatMapObservable(Functions.justFunction(ps)).test();
    assertTrue(ss.hasObservers());
    assertFalse(ps.hasObservers());
    ss.onSuccess(1);
    assertFalse(ss.hasObservers());
    assertTrue(ps.hasObservers());
    ps.onError(new TestException());
    assertFalse(ss.hasObservers());
    assertFalse(ps.hasObservers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 93 with TestObserver

use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.

the class MaybeZipArrayTest method middleError.

@Test
public void middleError() {
    PublishProcessor<Integer> pp0 = PublishProcessor.create();
    PublishProcessor<Integer> pp1 = PublishProcessor.create();
    TestObserver<Object> to = Maybe.zip(pp0.singleElement(), pp1.singleElement(), pp0.singleElement(), addString3).test();
    pp1.onError(new TestException());
    assertFalse(pp0.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 94 with TestObserver

use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.

the class CompletableAndThenObservableTest method errorMain.

@Test
public void errorMain() {
    CompletableSubject cs = CompletableSubject.create();
    PublishSubject<Integer> ps = PublishSubject.create();
    TestObserver<Integer> to = cs.andThen(ps).test();
    assertTrue(cs.hasObservers());
    assertFalse(ps.hasObservers());
    cs.onError(new TestException());
    assertFalse(cs.hasObservers());
    assertFalse(ps.hasObservers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 95 with TestObserver

use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.

the class CompletableAndThenObservableTest method errorOther.

@Test
public void errorOther() {
    CompletableSubject cs = CompletableSubject.create();
    PublishSubject<Integer> ps = PublishSubject.create();
    TestObserver<Integer> to = cs.andThen(ps).test();
    assertTrue(cs.hasObservers());
    assertFalse(ps.hasObservers());
    cs.onComplete();
    assertFalse(cs.hasObservers());
    assertTrue(ps.hasObservers());
    ps.onError(new TestException());
    assertFalse(cs.hasObservers());
    assertFalse(ps.hasObservers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)225 TestException (io.reactivex.rxjava3.exceptions.TestException)169 TestObserver (io.reactivex.rxjava3.observers.TestObserver)90 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)35 Disposable (io.reactivex.rxjava3.disposables.Disposable)34 CompletableSubject (io.reactivex.rxjava3.subjects.CompletableSubject)27 TargetApi (android.annotation.TargetApi)21 Observable (io.reactivex.rxjava3.core.Observable)19 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)19 IOException (java.io.IOException)19 Matchers.anyString (org.mockito.Matchers.anyString)16 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)13 Action (io.reactivex.rxjava3.functions.Action)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 InOrder (org.mockito.InOrder)7 io.reactivex.rxjava3.core (io.reactivex.rxjava3.core)6 RxJavaPlugins (io.reactivex.rxjava3.plugins.RxJavaPlugins)6 List (java.util.List)6 Assert (org.junit.Assert)6 Activity (android.app.Activity)5