Top Description Fields Constructors Methods
rx.observers

public Class TestObserver<T>

extends Object
implements Observer<T>
Class Inheritance
All Implemented Interfaces
rx.Observer
Annotations
@Deprecated
Type Parameters
<T>
the observed value type
Imports
java.util.*, rx.Notification, .Observer, rx.exceptions.CompositeException

Deprecated

use the TestSubscriber instead.

Observer usable for unit testing to perform assertions, inspect received events or wrap a mocked Observer.

Field Summary

Modifier and TypeField and Description
private final Observer<T>
private static final Observer<Object>
private final List<Notification<T>>
private final List<Throwable>
private final List<T>

Constructor Summary

AccessConstructor and Description
public
TestObserver(Observer<T> delegate)

public

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
assertionError(String
the message to use for the error
message
)

Combines an assertion error message with the current completion and error state of this TestSubscriber, giving more information when some assertXXX check fails.

public void
assertReceivedOnNext(List<T>
the sequence of items expected to have been observed
items
)

Assert that a particular sequence of items was received in order.

public void
assertTerminalEvent()

Assert that a single terminal event occurred, either onCompleted or onError.

public List<Object>

Returns:

a List containing one item for each item or notification received by this observer, in the order in which they were observed or received
getEvents
()

Get a list containing all of the items and notifications received by this observer, where the items will be given as-is, any error notifications will be represented by their Throwables, and any sequence-complete notifications will be represented by their Notification objects.

public List<Notification<T>>

Returns:

a list of Notifications representing calls to this observer's onCompleted method
getOnCompletedEvents
()

Get the Notifications representing each time this observer was notified of sequence completion via onCompleted, as a List.

public List<Throwable>

Returns:

a list of Throwables passed to this observer's onError method
getOnErrorEvents
()

Get the Throwables this observer was notified of via onError as a List.

public List<T>

Returns:

a list of items observed by this observer, in the order in which they were observed
getOnNextEvents
()

Get the sequence of items observed by this observer, as an ordered List.

public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(T
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final Observer<T> delegate
INERTback to summary
private static final Observer<Object> INERT
onCompletedEventsback to summary
private final List<Notification<T>> onCompletedEvents
onErrorEventsback to summary
private final List<Throwable> onErrorEvents
onNextEventsback to summary
private final List<T> onNextEvents

Constructor Detail

TestObserverback to summary
public TestObserver(Observer<T> delegate)
TestObserverback to summary
public TestObserver()
Annotations
@SuppressWarnings:unchecked

Method Detail

assertionErrorback to summary
pack-priv final void assertionError(String message)

Combines an assertion error message with the current completion and error state of this TestSubscriber, giving more information when some assertXXX check fails.

Parameters
message:String

the message to use for the error

assertReceivedOnNextback to summary
public void assertReceivedOnNext(List<T> items)

Assert that a particular sequence of items was received in order.

Parameters
items:List<T>

the sequence of items expected to have been observed

Exceptions
AssertionError:
if the sequence of items observed does not exactly match items
assertTerminalEventback to summary
public void assertTerminalEvent()

Assert that a single terminal event occurred, either onCompleted or onError.

Exceptions
AssertionError:
if not exactly one terminal event notification was received
getEventsback to summary
public List<Object> getEvents()

Get a list containing all of the items and notifications received by this observer, where the items will be given as-is, any error notifications will be represented by their Throwables, and any sequence-complete notifications will be represented by their Notification objects.

Returns:List<Object>

a List containing one item for each item or notification received by this observer, in the order in which they were observed or received

getOnCompletedEventsback to summary
public List<Notification<T>> getOnCompletedEvents()

Get the Notifications representing each time this observer was notified of sequence completion via onCompleted, as a List.

Returns:List<Notification<T>>

a list of Notifications representing calls to this observer's onCompleted method

getOnErrorEventsback to summary
public List<Throwable> getOnErrorEvents()

Get the Throwables this observer was notified of via onError as a List.

Returns:List<Throwable>

a list of Throwables passed to this observer's onError method

getOnNextEventsback to summary
public List<T> getOnNextEvents()

Get the sequence of items observed by this observer, as an ordered List.

Returns:List<T>

a list of items observed by this observer, in the order in which they were observed

onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override