Class TestCompletableSubscriber
- java.lang.Object
-
- io.servicetalk.concurrent.test.internal.TestCompletableSubscriber
-
- All Implemented Interfaces:
CompletableSource.Subscriber
public final class TestCompletableSubscriber extends java.lang.Object implements CompletableSource.Subscriber
ACompletableSource.Subscriber
that enqueues signals and provides blocking methods to consume them.
-
-
Constructor Summary
Constructors Constructor Description TestCompletableSubscriber()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
awaitOnComplete()
Block until a terminal signal is received, throws ifonError(Throwable)
and returns normally ifonComplete()
.java.lang.Throwable
awaitOnError()
Block until a terminal signal is received, throws ifonComplete()
and returns normally ifonError(Throwable)
.Cancellable
awaitSubscription()
Block untilonSubscribe(Cancellable)
.void
onComplete()
Success terminal state.void
onError(java.lang.Throwable t)
Failed terminal state.void
onSubscribe(Cancellable cancellable)
Called when the associatedCompletableSource
is subscribed viaCompletableSource.subscribe(Subscriber)
.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: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
public void onError(java.lang.Throwable t)
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
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 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
@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
ifonComplete()
, or theThrowable
fromonError(Throwable)
.
-
-