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.Subscriberthat 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 voidawaitOnComplete()Block until a terminal signal is received, throws ifonError(Throwable)and returns normally ifonComplete().java.lang.ThrowableawaitOnError()Block until a terminal signal is received, throws ifonComplete()and returns normally ifonError(Throwable).CancellableawaitSubscription()Block untilonSubscribe(Cancellable).voidonComplete()Success terminal state.voidonError(java.lang.Throwable t)Failed terminal state.voidonSubscribe(Cancellable cancellable)Called when the associatedCompletableSourceis 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.SubscriberCalled when the associatedCompletableSourceis subscribed viaCompletableSource.subscribe(Subscriber).- Specified by:
onSubscribein interfaceCompletableSource.Subscriber- Parameters:
cancellable- ACancellablethat can be used to cancel the asynchronous computation for this subscriber.
-
onComplete
public void onComplete()
Description copied from interface:CompletableSource.SubscriberSuccess terminal state.No further events will be sent.
- Specified by:
onCompletein interfaceCompletableSource.Subscriber
-
onError
public void onError(java.lang.Throwable t)
Description copied from interface:CompletableSource.SubscriberFailed terminal state.No further events will be sent.
- Specified by:
onErrorin interfaceCompletableSource.Subscriber- Parameters:
t- the throwable signaled
-
awaitSubscription
public Cancellable awaitSubscription()
Block untilonSubscribe(Cancellable).- Returns:
- The
PublisherSource.SubscriptionfromonSubscribe(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:
nullif a the timeout expires before a terminal event is received. A non-nullSupplierthat returnsnullifonComplete(), or theThrowablefromonError(Throwable).
-
-