Observer, MaybeObserver, SingleObserver and
CompletableObserver composite that can record events from
Observables, Maybes, Singles and Completables
and allows making assertions about them.
You can override the onSubscribe(Disposable), onNext(Object), onError(Throwable),
onComplete() and onSuccess(Object) methods but not the others (this is by design).
The TestObserver implements Disposable for convenience where dispose calls cancel.
io.reactivex.rxjava3.subscribers.TestSubscriber
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum | TestObserver.EmptyObserver
An observer that ignores all events and does not report errors. |
| Modifier and Type | Field and Description |
|---|---|
| private final Observer | downstream
The actual observer to forward events to. |
| private final AtomicReference | upstream
Holds the current subscription if any. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | TestObserver(@NonNull Observer<? super T>
the actual downstream)Observer to forward events toConstructs a forwarding |
| Modifier and Type | Method and Description |
|---|---|
| protected final @NonNull TestObserver | Returns: thisImplements abstract io. onSubscribe(Disposable) method was called exactly once.
|
| public static < the value type received T> @NonNull TestObserver | |
| public static < the value type received T> @NonNull TestObserver | |
| public final void | dispose()
Implements abstract io. Implements io. |
| public final boolean | Returns: true if thisTestObserver received a subscriptionReturns true if this |
| public final boolean | isDisposed()
Implements abstract io. Implements io. |
| public void | onComplete()
Implements io. Observer that the Observable has finished sending push-based notifications.
|
| public void | |
| public void | onNext(T
the item emitted by the Observable t)Implements io. Observer with a new item to observe.
|
| public void | |
| public void | onSuccess(T
the item emitted by the value)MaybeImplements io. MaybeObserver with one item and that the Maybe has finished sending
push-based notifications.
|
| downstream | back to summary |
|---|---|
| private final Observer<? super T> downstream The actual observer to forward events to. | |
| upstream | back to summary |
|---|---|
| private final AtomicReference<Disposable> upstream Holds the current subscription if any. | |
| TestObserver | back to summary |
|---|---|
| public TestObserver() Constructs a non-forwarding TestObserver. | |
| TestObserver | back to summary |
|---|---|
| public TestObserver(@NonNull Observer<? super T> downstream) Constructs a forwarding | |
| assertSubscribed | back to summary |
|---|---|
| protected final @NonNull TestObserver Implements abstract io. Assert that the
| |
| create | back to summary |
|---|---|
| public static <T> @NonNull TestObserver Constructs a non-forwarding
| |
| create | back to summary |
|---|---|
| public static <T> @NonNull TestObserver Constructs a forwarding | |
| dispose | back to summary |
|---|---|
| public final void dispose() Implements abstract io. Implements io. Doc from io. Dispose the resource, the operation should be idempotent.
| |
| hasSubscription | back to summary |
|---|---|
| public final boolean hasSubscription() Returns true if this
| |
| isDisposed | back to summary |
|---|---|
| public final boolean isDisposed() Implements abstract io. Implements io. Doc from io. Returns true if this resource has been disposed.
| |
| onComplete | back to summary |
|---|---|
| public void onComplete() Implements io. Doc from io. Notifies the
The
| |
| onError | back to summary |
|---|---|
public void onError(@NonNull Throwable t)
| |
| onNext | back to summary |
|---|---|
| public void onNext(T t) Implements io. Doc from io. Provides the
The
The
| |
| onSubscribe | back to summary |
|---|---|
public void onSubscribe(@NonNull Disposable d)
| |
| onSuccess | back to summary |
|---|---|
| public void onSuccess(T value) Implements io. Doc from io. Notifies the
The
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final TestObserver. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | onComplete()
Implements io. Observer that the Observable has finished sending push-based notifications.
|
| public void | |
| public void | onNext(Object
the item emitted by the Observable t)Implements io. Observer with a new item to observe.
|
| public void | |
| public static TestObserver. | |
| public static TestObserver. |
| INSTANCE | back to summary |
|---|---|
| public static final TestObserver. | |
| EmptyObserver | back to summary |
|---|---|
| private EmptyObserver() | |
| onComplete | back to summary |
|---|---|
| public void onComplete() Implements io. Doc from io. Notifies the
The
| |
| onError | back to summary |
|---|---|
public void onError(Throwable t)
| |
| onNext | back to summary |
|---|---|
| public void onNext(Object t) Implements io. Doc from io. Provides the
The
The | |
| onSubscribe | back to summary |
|---|---|
public void onSubscribe(Disposable d)
| |
| valueOf | back to summary |
|---|---|
| public static TestObserver. | |
| values | back to summary |
|---|---|
| public static TestObserver. | |