Class TestSingleSubscriber<T>
java.lang.Object
io.servicetalk.concurrent.test.internal.TestSingleSubscriber<T>
- Type Parameters:
T
- The type of data inonSuccess(Object)
.
- All Implemented Interfaces:
SingleSource.Subscriber<T>
A
SingleSource.Subscriber
that enqueues signals and provides blocking methods to consume them.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBlock until a terminal signal is received, throws ifonSuccess(Object)
and returns normally ifonError(Throwable)
.Block until a terminal signal is received, throws ifonError(Throwable)
and returns normally ifonSuccess(Object)
.Block untilonSubscribe(Cancellable)
.void
Failed terminal state.void
onSubscribe
(Cancellable cancellable) Called when the associatedSingleSource
is subscribed viaSingleSource.subscribe(Subscriber)
.void
Success terminal state.pollTerminal
(long timeout, TimeUnit unit) Block for a terminal event.
-
Constructor Details
-
TestSingleSubscriber
public TestSingleSubscriber()
-
-
Method Details
-
onSubscribe
Description copied from interface:SingleSource.Subscriber
Called when the associatedSingleSource
is subscribed viaSingleSource.subscribe(Subscriber)
.- Specified by:
onSubscribe
in interfaceSingleSource.Subscriber<T>
- Parameters:
cancellable
- ACancellable
that can be used to cancel the asynchronous computation for this subscriber.
-
onSuccess
Description copied from interface:SingleSource.Subscriber
Success terminal state.No further events will be sent.
- Specified by:
onSuccess
in interfaceSingleSource.Subscriber<T>
- Parameters:
result
- of theSingleSource
.
-
onError
Description copied from interface:SingleSource.Subscriber
Failed terminal state.No further events will be sent.
- Specified by:
onError
in interfaceSingleSource.Subscriber<T>
- Parameters:
t
- the throwable signaled.
-
awaitSubscription
Block untilonSubscribe(Cancellable)
.- Returns:
- The
PublisherSource.Subscription
fromonSubscribe(Cancellable)
.
-
awaitOnError
Block until a terminal signal is received, throws ifonSuccess(Object)
and returns normally ifonError(Throwable)
.- Returns:
- the exception received by
onError(Throwable)
.
-
awaitOnSuccess
Block until a terminal signal is received, throws ifonError(Throwable)
and returns normally ifonSuccess(Object)
.- Returns:
- The value delivered to
onSuccess(Object)
.
-
pollTerminal
Block for a terminal event.- Parameters:
timeout
- The duration of time to wait.unit
- The unit of time to apply to the duration.- Returns:
null
if a the timeout expires before a terminal event is received. A non-null
Supplier
that returnsnull
ifonSuccess(Object)
, or theThrowable
fromonError(Throwable)
.
-