class TestSubscriber[T] extends Subscriber[T]
A TestSubscriber is a variety of Subscriber that you can use for unit testing, to perform assertions, inspect received events, or wrap a mocked Subscriber.
- Alphabetic
- By Inheritance
- TestSubscriber
- Subscriber
- Subscription
- Observer
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
add(u: ⇒ Unit): Unit
Create a Subscription using
uand add it to this Subscriber's list of Subscriptions if this list is not marked as unsubscribed.Create a Subscription using
uand add it to this Subscriber's list of Subscriptions if this list is not marked as unsubscribed. If the list **is** marked as unsubscribed, it will callu.- u
callback to run when unsubscribed
- Definition Classes
- Subscriber
-
final
def
add(s: Subscription): Unit
Add a Subscription to this Subscriber's list of Subscriptions if this list is not marked as unsubscribed.
Add a Subscription to this Subscriber's list of Subscriptions if this list is not marked as unsubscribed. If the list **is** marked as unsubscribed, it will unsubscribe the new Subscription as well.
- s
the Subscription to add
- Definition Classes
- Subscriber
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
assertCompleted(): Unit
EXPERIMENTAL Assert if there is exactly a single completion event.
EXPERIMENTAL Assert if there is exactly a single completion event.
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif there were zero, or more than one, onCompleted events
-
def
assertError(throwable: Throwable): Unit
EXPERIMENTAL Assert there is a single onError event with the exact exception.
EXPERIMENTAL Assert there is a single onError event with the exact exception.
- throwable
the throwable to check
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif there were zero, or more than one, onError events, or if the single onError event did not carry an error that matches the specified throwable
-
def
assertError(clazz: Class[_ <: Throwable]): Unit
EXPERIMENTAL Assert if there is exactly one error event which is a subclass of the given class.
EXPERIMENTAL Assert if there is exactly one error event which is a subclass of the given class.
- clazz
the class to check the error against.
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif there were zero, or more than one, onError events, or if the single onError event did not carry an error of a subclass of the given class
-
def
assertNoErrors(): Unit
Assert that this Subscriber has received no
onErrornotifications.Assert that this Subscriber has received no
onErrornotifications.- Annotations
- @throws( ... )
- Exceptions thrown
java.lang.AssertionErrorif this Subscriber has received one or moreonErrornotifications
-
def
assertNoTerminalEvent(): Unit
EXPERIMENTAL Assert for no onError and onCompleted events.
EXPERIMENTAL Assert for no onError and onCompleted events.
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif there was either an onError or onCompleted event
-
def
assertNoValues(): Unit
EXPERIMENTAL Assert if there are no onNext events received.
EXPERIMENTAL Assert if there are no onNext events received.
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif there were any onNext events
-
def
assertNotCompleted(): Unit
EXPERIMENTAL Assert if there is no completion event.
EXPERIMENTAL Assert if there is no completion event.
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif there were one or more than one onCompleted events
-
def
assertTerminalEvent(): Unit
Assert that a single terminal event occurred, either
onCompletedoronError.Assert that a single terminal event occurred, either
onCompletedoronError.- Annotations
- @throws( ... )
- Exceptions thrown
java.lang.AssertionErrorif not exactly one terminal event notification was received
-
def
assertUnsubscribed(): Unit
Assert that this Subscriber is unsubscribed.
Assert that this Subscriber is unsubscribed.
- Annotations
- @throws( ... )
- Exceptions thrown
java.lang.AssertionErrorif this Subscriber is not unsubscribed
-
def
assertValue(value: T): Unit
EXPERIMENTAL Assert if there is only a single received onNext event and that it marks the emission of a specific item.
EXPERIMENTAL Assert if there is only a single received onNext event and that it marks the emission of a specific item.
- value
the item to check
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif the Observable does not emit only the single item specified byvalue
-
def
assertValueCount(count: Int): Unit
EXPERIMENTAL Assert if the given number of onNext events are received.
EXPERIMENTAL Assert if the given number of onNext events are received.
- count
the expected number of onNext events
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif there were more or fewer onNext events than specified bycount
-
def
assertValues(values: T*): Unit
EXPERIMENTAL Assert if the received onNext events, in order, are the specified items.
EXPERIMENTAL Assert if the received onNext events, in order, are the specified items.
- values
the items to check
- Annotations
- @Experimental() @throws( ... )
- Since
(if this graduates from "Experimental" replace this parenthetical with the release number)
- Exceptions thrown
java.lang.AssertionErrorif the items emitted do not exactly match those specified byvalues
-
def
assertValuesAndClear(expectedFirstValue: T, expectedRestValues: T*): Unit
EXPERIMENTAL Assert that the TestSubscriber contains the given first and optional rest values exactly and if so, clears the internal list of values.
EXPERIMENTAL Assert that the TestSubscriber contains the given first and optional rest values exactly and if so, clears the internal list of values.
val ts = TestSubscriber() ts.onNext(1) ts.assertValuesAndClear(1) ts.onNext(2) ts.onNext(3) ts.assertValuesAndClear(2, 3) // no mention of 1
- expectedFirstValue
the expected first value
- expectedRestValues
the optional rest values
- Annotations
- @Experimental()
-
def
awaitTerminalEvent(timeout: Duration): Unit
Blocks until this Subscriber receives a notification that the Observable is complete (either an
onCompletedoronErrornotification), or until a timeout expires.Blocks until this Subscriber receives a notification that the Observable is complete (either an
onCompletedoronErrornotification), or until a timeout expires.- timeout
the duration of the timeout
- Annotations
- @throws( ... )
- Exceptions thrown
java.lang.RuntimeExceptionif the Subscriber is interrupted before the Observable is able to complete
-
def
awaitTerminalEvent(): Unit
Blocks until this Subscriber receives a notification that the Observable is complete (either an
onCompletedoronErrornotification).Blocks until this Subscriber receives a notification that the Observable is complete (either an
onCompletedoronErrornotification).- Annotations
- @throws( ... )
- Exceptions thrown
java.lang.RuntimeExceptionif the Subscriber is interrupted before the Observable is able to complete
-
def
awaitTerminalEventAndUnsubscribeOnTimeout(timeout: Duration): Unit
Blocks until this Subscriber receives a notification that the Observable is complete (either an
onCompletedoronErrornotification), or until a timeout expires; if the Subscriber is interrupted before either of these events take place, this method unsubscribes the Subscriber from the Observable).Blocks until this Subscriber receives a notification that the Observable is complete (either an
onCompletedoronErrornotification), or until a timeout expires; if the Subscriber is interrupted before either of these events take place, this method unsubscribes the Subscriber from the Observable).- timeout
the duration of the timeout
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
completions: Int
EXPERIMENTAL Returns the number of times onCompleted was called on this TestSubscriber.
EXPERIMENTAL Returns the number of times onCompleted was called on this TestSubscriber.
- returns
the number of times onCompleted was called on this TestSubscriber.
- Annotations
- @Experimental()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
getLastSeenThread: Thread
Returns the last thread that was in use when an item or notification was received by this Subscriber.
Returns the last thread that was in use when an item or notification was received by this Subscriber.
- returns
the
Threadon which this Subscriber last received an item or notification from the Observable it is subscribed to
-
def
getOnErrorEvents: Seq[Throwable]
Get the
Throwables this Subscriber was notified of via onErrorGet the
Throwables this Subscriber was notified of via onError- returns
a sequence of the
Throwables that were passed to the Subscriber.onError method
-
def
getOnNextEvents: Seq[T]
Get the sequence of items observed by this Subscriber.
Get the sequence of items observed by this Subscriber.
- returns
a sequence of items observed by this Subscriber, in the order in which they were observed
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
isUnsubscribed: Boolean
Indicates whether this Subscriber has unsubscribed from its list of Subscriptions.
Indicates whether this Subscriber has unsubscribed from its list of Subscriptions.
- returns
trueif this Subscriber has unsubscribed from its Subscriptions,falseotherwise
- Definition Classes
- Subscriber → Subscription
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
onCompleted(): Unit
Notifies the Observer that the rx.lang.scala.Observable has finished sending push-based notifications.
Notifies the Observer that the rx.lang.scala.Observable has finished sending push-based notifications.
The rx.lang.scala.Observable will not call this method if it calls
onError.- Definition Classes
- TestSubscriber → Observer
-
def
onError(error: Throwable): Unit
Notifies the Observer that the rx.lang.scala.Observable has experienced an error condition.
Notifies the Observer that the rx.lang.scala.Observable has experienced an error condition.
If the rx.lang.scala.Observable calls this method, it will not thereafter call
onNextoronCompleted.- Definition Classes
- TestSubscriber → Observer
-
def
onNext(value: T): Unit
Provides the Observer with new data.
Provides the Observer with new data.
The rx.lang.scala.Observable calls this closure 0 or more times.
The rx.lang.scala.Observable will not call this method again after it calls either
onCompletedoronError.- Definition Classes
- TestSubscriber → Observer
-
def
onStart(): Unit
This method is invoked when the Subscriber and Observable have been connected but the Observable has not yet begun to emit items or send notifications to the Subscriber.
This method is invoked when the Subscriber and Observable have been connected but the Observable has not yet begun to emit items or send notifications to the Subscriber. Override this method to add any useful initialization to your subscription, for instance to initiate backpressure.
Observable.just(1, 2, 3).subscribe(new Subscriber[Int]() { override def onStart(): Unit = request(1) override def onNext(v: Int): Unit = { println(v) request(1) } override def onError(e: Throwable): Unit = e.printStackTrace() override def onCompleted(): Unit = {} })
- Definition Classes
- Subscriber
-
final
def
request(n: Long): Unit
Request a certain maximum number of emitted items from the Observable this Subscriber is subscribed to.
Request a certain maximum number of emitted items from the Observable this Subscriber is subscribed to. This is a way of requesting backpressure. To disable backpressure, pass
Long.MaxValueto this method.- n
the maximum number of items you want the Observable to emit to the Subscriber at this time, or
Long.MaxValueif you want the Observable to emit items at its own pace
- Attributes
- protected[this]
- Definition Classes
- Subscriber
-
def
requestMore(n: Long): Unit
Allow calling the protected request from unit tests.
Allow calling the protected request from unit tests.
- n
the maximum number of items you want the Observable to emit to the Subscriber at this time, or
Long.MaxValueif you want the Observable to emit items at its own pace
-
def
setProducer(producer: (Long) ⇒ Unit): Unit
- Definition Classes
- Subscriber
-
def
setProducer(producer: Producer): Unit
- Definition Classes
- Subscriber
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
unsubscribe(): Unit
Unsubscribe all Subscriptions added to this Subscriber's .
Unsubscribe all Subscriptions added to this Subscriber's .
- Definition Classes
- Subscriber → Subscription
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )