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>
public final class TestSingleSubscriber<T> extends java.lang.Object implements SingleSource.Subscriber<T>
ASingleSource.Subscriber
that enqueues signals and provides blocking methods to consume them.
-
-
Constructor Summary
Constructors Constructor Description TestSingleSubscriber()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Throwable
awaitOnError()
Block until a terminal signal is received, throws ifonSuccess(Object)
and returns normally ifonError(Throwable)
.T
awaitOnSuccess()
Block until a terminal signal is received, throws ifonError(Throwable)
and returns normally ifonSuccess(Object)
.Cancellable
awaitSubscription()
Block untilonSubscribe(Cancellable)
.void
onError(java.lang.Throwable t)
Failed terminal state.void
onSubscribe(Cancellable cancellable)
Called when the associatedSingleSource
is subscribed viaSingleSource.subscribe(Subscriber)
.void
onSuccess(T result)
Success terminal state.java.util.function.Supplier<java.lang.Throwable>
pollTerminal(long timeout, java.util.concurrent.TimeUnit unit)
Block for a terminal event.
-
-
-
Method Detail
-
onSubscribe
public void onSubscribe(Cancellable cancellable)
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
public void onSuccess(@Nullable T result)
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
public void onError(java.lang.Throwable t)
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
public Cancellable awaitSubscription()
Block untilonSubscribe(Cancellable)
.- Returns:
- The
PublisherSource.Subscription
fromonSubscribe(Cancellable)
.
-
awaitOnError
public java.lang.Throwable awaitOnError()
Block until a terminal signal is received, throws ifonSuccess(Object)
and returns normally ifonError(Throwable)
.- Returns:
- the exception received by
onError(Throwable)
.
-
awaitOnSuccess
@Nullable public T awaitOnSuccess()
Block until a terminal signal is received, throws ifonError(Throwable)
and returns normally ifonSuccess(Object)
.- Returns:
- The value delivered to
onSuccess(Object)
.
-
pollTerminal
@Nullable public java.util.function.Supplier<java.lang.Throwable> pollTerminal(long timeout, java.util.concurrent.TimeUnit unit)
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)
.
-
-