Class TestCompletableSubscriber
java.lang.Object
io.servicetalk.concurrent.test.internal.TestCompletableSubscriber
- All Implemented Interfaces:
CompletableSource.Subscriber
A
CompletableSource.Subscriber
that enqueues signals and provides blocking methods to consume them.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Block until a terminal signal is received, throws ifonError(Throwable)
and returns normally ifonComplete()
.Block until a terminal signal is received, throws ifonComplete()
and returns normally ifonError(Throwable)
.Block untilonSubscribe(Cancellable)
.void
Success terminal state.void
Failed terminal state.void
onSubscribe
(Cancellable cancellable) Called when the associatedCompletableSource
is subscribed viaCompletableSource.subscribe(Subscriber)
.pollTerminal
(long timeout, TimeUnit unit) Block for a terminal event.
-
Constructor Details
-
TestCompletableSubscriber
public TestCompletableSubscriber()
-
-
Method Details
-
onSubscribe
Description copied from interface:CompletableSource.Subscriber
Called when the associatedCompletableSource
is subscribed viaCompletableSource.subscribe(Subscriber)
.- Specified by:
onSubscribe
in interfaceCompletableSource.Subscriber
- Parameters:
cancellable
- ACancellable
that can be used to cancel the asynchronous computation for this subscriber.
-
onComplete
public void onComplete()Description copied from interface:CompletableSource.Subscriber
Success terminal state.No further events will be sent.
- Specified by:
onComplete
in interfaceCompletableSource.Subscriber
-
onError
Description copied from interface:CompletableSource.Subscriber
Failed terminal state.No further events will be sent.
- Specified by:
onError
in interfaceCompletableSource.Subscriber
- Parameters:
t
- the throwable signaled
-
awaitSubscription
Block untilonSubscribe(Cancellable)
.- Returns:
- The
PublisherSource.Subscription
fromonSubscribe(Cancellable)
.
-
awaitOnError
Block until a terminal signal is received, throws ifonComplete()
and returns normally ifonError(Throwable)
.- Returns:
- the exception received by
onError(Throwable)
.
-
awaitOnComplete
public void awaitOnComplete()Block until a terminal signal is received, throws ifonError(Throwable)
and returns normally ifonComplete()
. -
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
ifonComplete()
, or theThrowable
fromonError(Throwable)
.
-