public final class TestCompletableSubscriber extends java.lang.Object implements CompletableSource.Subscriber, Cancellable
CompletableSource.Subscriber
that can be used to verify the signals delivered by a CompletableSource
.
The Cancellable
received by onSubscribe(Cancellable)
is exposed through the Cancellable
interface methods.
TestCompletableSubscriber.Builder
Modifier and Type | Class and Description |
---|---|
static class |
TestCompletableSubscriber.Builder
Allows for creating
TestCompletableSubscriber s with non-default settings. |
IGNORE_CANCEL
Constructor and Description |
---|
TestCompletableSubscriber()
Create a
TestCompletableSubscriber with the defaults. |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the
Cancellable received by onSubscribe(Cancellable) . |
Cancellable |
cancellable()
Returns the
Cancellable received by onSubscribe(Cancellable) , or null if no
Cancellable has been received. |
boolean |
cancellableReceived()
|
java.lang.Throwable |
error()
Get the last
Throwable received by onError(Throwable) . |
boolean |
isCompleted()
|
boolean |
isErrored()
|
boolean |
isTerminated()
|
void |
onComplete()
Success terminal state.
|
void |
onError(java.lang.Throwable t)
Failed terminal state.
|
void |
onSubscribe(Cancellable s)
Called when the associated
CompletableSource is subscribed via
CompletableSource.subscribe(Subscriber) . |
java.lang.Throwable |
takeError()
Get the last
Throwable received by onError(Throwable) , and clears the internal value. |
TerminalNotification |
takeTerminal()
Get the last
TerminalNotification onError(Throwable) or onComplete() received, and
clears the internal value. |
TerminalNotification |
terminal()
|
public TestCompletableSubscriber()
TestCompletableSubscriber
with the defaults.TestCompletableSubscriber.Builder
public boolean cancellableReceived()
true
if onSubscribe(Cancellable)
has been called, false
otherwise.public Cancellable cancellable()
Cancellable
received by onSubscribe(Cancellable)
, or null
if no
Cancellable
has been received.Cancellable
received by onSubscribe(Cancellable)
, or null
if no
Cancellable
has been received.@Nullable public TerminalNotification terminal()
TerminalNotification
, or null
if none have been received.@Nullable public TerminalNotification takeTerminal()
TerminalNotification
onError(Throwable)
or onComplete()
received, and
clears the internal value.TerminalNotification
, or null
if none have been received.@Nullable public java.lang.Throwable error()
Throwable
received by onError(Throwable)
.Throwable
, or null
if none have been received.@Nullable public java.lang.Throwable takeError()
Throwable
received by onError(Throwable)
, and clears the internal value.Throwable
, or null
if none have been received.public boolean isCompleted()
true
if onComplete()
was the most recently received terminal signal, false
otherwise.public boolean isErrored()
true
if onError(Throwable)
was the most recently received terminal signal,
false
otherwise.public boolean isTerminated()
true
if either onComplete()
or onError(Throwable)
have been received,
false
otherwise.public void cancel()
Cancellable
received by onSubscribe(Cancellable)
.
If no Cancellable
has been received yet, the cancellation will be buffered, and the
Cancellable
will be cancelled when it is received.
cancel
in interface Cancellable
public void onSubscribe(Cancellable s)
CompletableSource.Subscriber
CompletableSource
is subscribed via
CompletableSource.subscribe(Subscriber)
.onSubscribe
in interface CompletableSource.Subscriber
s
- A Cancellable
that can be used to cancel the asynchronous computation for
this subscriber.public void onComplete()
CompletableSource.Subscriber
No further events will be sent.
onComplete
in interface CompletableSource.Subscriber
public void onError(java.lang.Throwable t)
CompletableSource.Subscriber
No further events will be sent.
onError
in interface CompletableSource.Subscriber
t
- the throwable signaled