public class TestSubscriber<T> extends Subscriber<T>
| Constructor and Description |
|---|
TestSubscriber() |
TestSubscriber(Observer<T> delegate) |
TestSubscriber(Subscriber<T> delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertReceivedOnNext(java.util.List<T> items)
Assert that a particular sequence of items was received in order.
|
void |
assertTerminalEvent()
Assert that a single terminal event occurred, either
TestSubscriber.onCompleted() or TestSubscriber.onError(java.lang.Throwable). |
void |
assertUnsubscribed()
Assert that this
Subscriber is unsubscribed. |
void |
awaitTerminalEvent() |
void |
awaitTerminalEvent(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
awaitTerminalEventAndUnsubscribeOnTimeout(long timeout,
java.util.concurrent.TimeUnit unit) |
java.lang.Thread |
getLastSeenThread() |
java.util.List<Notification<T>> |
getOnCompletedEvents()
Get the
Notifications representing each time this subscriber was notified of sequence completion
via TestSubscriber.onCompleted(), as a List. |
java.util.List<java.lang.Throwable> |
getOnErrorEvents()
Get the
Throwables this subscriber was notified of via TestSubscriber.onError(java.lang.Throwable) as a List. |
java.util.List<T> |
getOnNextEvents()
Get the sequence of items observed by this subscriber, as an ordered
List. |
void |
onCompleted()
Notifies the Observer that the
Observable has finished sending push-based notifications. |
void |
onError(java.lang.Throwable e)
Notifies the Observer that the
Observable has experienced an error condition. |
void |
onNext(T t)
Provides the Observer with a new item to observe.
|
add, isUnsubscribed, unsubscribepublic TestSubscriber(Subscriber<T> delegate)
public TestSubscriber()
public void onCompleted()
ObserverObservable has finished sending push-based notifications.
The Observable will not call this method if it calls Observer.onError(java.lang.Throwable).
public java.util.List<Notification<T>> getOnCompletedEvents()
Notifications representing each time this subscriber was notified of sequence completion
via TestSubscriber.onCompleted(), as a List.TestSubscriber.onCompleted() methodpublic void onError(java.lang.Throwable e)
ObserverObservable has experienced an error condition.
If the Observable calls this method, it will not thereafter call Observer.onNext(T) or
Observer.onCompleted().
e - the exception encountered by the Observablepublic java.util.List<java.lang.Throwable> getOnErrorEvents()
Throwables this subscriber was notified of via TestSubscriber.onError(java.lang.Throwable) as a List.TestSubscriber.onError(java.lang.Throwable) methodpublic void onNext(T t)
Observer
The Observable may call this closure 0 or more times.
The Observable will not call this closure again after it calls either Observer.onCompleted() or
Observer.onError(java.lang.Throwable).
t - the item emitted by the Observablepublic java.util.List<T> getOnNextEvents()
List.public void assertReceivedOnNext(java.util.List<T> items)
items - the sequence of items expected to have been observedjava.lang.AssertionError - if the sequence of items observed does not exactly match itemspublic void assertTerminalEvent()
TestSubscriber.onCompleted() or TestSubscriber.onError(java.lang.Throwable).java.lang.AssertionError - if not exactly one terminal event notification was receivedpublic void assertUnsubscribed()
Subscriber is unsubscribed.java.lang.AssertionError - if this Subscriber is not unsubscribedpublic void awaitTerminalEvent()
public void awaitTerminalEvent(long timeout,
java.util.concurrent.TimeUnit unit)
public void awaitTerminalEventAndUnsubscribeOnTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
public java.lang.Thread getLastSeenThread()