T - the value typepublic classTestObserver<T>extendsBaseTestConsumer<T,TestObserver<T>>implementsObserver<T>,Disposable,MaybeObserver<T>,SingleObserver<T>,CompletableObserver
You can override the onSubscribe, onNext, onError, onComplete, onSuccess and cancel methods but not the others (this is by design).
The TestObserver implements Disposable for convenience where dispose calls cancel.
BaseTestConsumer.TestWaitStrategycheckSubscriptionOnce,completions,done,errors,establishedFusionMode,initialFusionMode,lastThread,tag,timeout,values| Constructor and Description |
|---|
TestObserver()Constructs a non-forwarding TestObserver. |
TestObserver(Observer<? superT> downstream)Constructs a forwarding TestObserver. |
| Modifier and Type | Method and Description |
|---|---|
TestObserver<T> | assertNotSubscribed()Assert that the onSubscribe method hasn't been called at all. |
TestObserver<T> | assertOf(Consumer<? superTestObserver<T>> check)Run a check consumer with this TestObserver instance. |
TestObserver<T> | assertSubscribed()Assert that the onSubscribe method was called exactly once. |
void | cancel()Cancels the TestObserver (before or after the subscription happened). |
static <T> TestObserver<T> | create()Constructs a non-forwarding TestObserver. |
static <T> TestObserver<T> | create(Observer<? super T> delegate)Constructs a forwarding TestObserver. |
void | dispose()Dispose the resource, the operation should be idempotent. |
boolean | hasSubscription()Returns true if this TestObserver received a subscription. |
boolean | isCancelled()Returns true if this TestObserver has been cancelled. |
boolean | isDisposed()Returns true if this resource has been disposed. |
void | onComplete()Notifies the Observer that the Observable has finished sending push-based notifications. |
void | onError(Throwable t)Notifies the Observer that the Observable has experienced an error condition. |
void | onNext(T t)Provides the Observer with a new item to observe. |
void | onSubscribe(Disposable d)Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within Observer.onNext(Object)) and asynchronous manner. |
void | onSuccess(T value)Notifies the MaybeObserver with one item and that the Maybe has finished sending push-based notifications. |
assertComplete,assertEmpty,assertError,assertError,assertError,assertErrorMessage,assertFailure,assertFailure,assertFailureAndMessage,assertNever,assertNever,assertNoErrors,assertNotComplete,assertNoTimeout,assertNotTerminated,assertNoValues,assertResult,assertTerminated,assertTimeout,assertValue,assertValue,assertValueAt,assertValueAt,assertValueCount,assertValues,assertValueSequence,assertValueSequenceOnly,assertValueSet,assertValueSetOnly,assertValuesOnly,await,await,awaitCount,awaitCount,awaitCount,awaitDone,awaitTerminalEvent,awaitTerminalEvent,clearTimeout,completions,errorCount,errors,fail,getEvents,isTerminated,isTimeout,lastThread,valueAndClass,valueCount,values,withTagpublic static <T> TestObserver<T> create()
T - the value type receivedpublic static <T> TestObserver<T> create(Observer<? super T> delegate)
T - the value type receiveddelegate - the actual Observer to forward events topublic void onSubscribe(Disposable d)
ObserverObserver.onNext(Object)) and asynchronous manner.onSubscribe in interface CompletableObserveronSubscribe in interface MaybeObserver<T>onSubscribe in interface Observer<T>onSubscribe in interface SingleObserver<T>d - the Disposable instance whoseDisposable.dispose() can be called anytime to cancel the connectionpublic void onNext(T t)
Observer TheObservable may call this method 0 or more times.
TheObservable will not call this method again after it calls eitherObserver.onComplete() orObserver.onError(java.lang.Throwable).
public void onError(Throwable t)
ObserverObservable has experienced an error condition. If theObservable calls this method, it will not thereafter callObserver.onNext(T) orObserver.onComplete().
onError in interface CompletableObserveronError in interface MaybeObserver<T>onError in interface Observer<T>onError in interface SingleObserver<T>t - the exception encountered by the Observablepublic void onComplete()
ObserverObservable has finished sending push-based notifications. TheObservable will not call this method if it callsObserver.onError(java.lang.Throwable).
onComplete in interface CompletableObserveronComplete in interface MaybeObserver<T>onComplete in interface Observer<T>public final boolean isCancelled()
public final void cancel()
This operation is thread-safe.
This method is provided as a convenience when converting Flowable tests that cancel.
public final void dispose()
Disposabledispose in interface Disposablepublic final boolean isDisposed()
DisposableisDisposed in interface Disposablepublic final boolean hasSubscription()
public final TestObserver<T> assertSubscribed()
assertSubscribed in class BaseTestConsumer<T,TestObserver<T>>public final TestObserver<T> assertNotSubscribed()
assertNotSubscribed in class BaseTestConsumer<T,TestObserver<T>>public final TestObserver<T> assertOf(Consumer<? superTestObserver<T>> check)
check - the check consumer to runpublic void onSuccess(T value)
MaybeObserverMaybe has finished sending push-based notifications. TheMaybe will not call this method if it callsMaybeObserver.onError(java.lang.Throwable).
onSuccess in interface MaybeObserver<T>onSuccess in interface SingleObserver<T>value - the item emitted by the Maybe