T - the value typepublic class TestSubscriber<T> extends io.reactivex.common.TestConsumer<T,TestSubscriber<T>> implements hu.akarnokd.reactivestreams.extensions.RelaxedSubscriber<T>, org.reactivestreams.Subscription, io.reactivex.common.Disposable
You can override the onSubscribe, onNext, onError, onComplete, request and cancel methods but not the others (this is by design).
The TestSubscriber implements Disposable for convenience where dispose calls cancel.
When calling the default request method, you are requesting on behalf of the wrapped actual subscriber.
| Constructor and Description |
|---|
TestSubscriber()
Constructs a non-forwarding TestSubscriber with an initial request value of Long.MAX_VALUE.
|
TestSubscriber(long initialRequest)
Constructs a non-forwarding TestSubscriber with the specified initial request value.
|
TestSubscriber(org.reactivestreams.Subscriber<? super T> actual)
Constructs a forwarding TestSubscriber but leaves the requesting to the wrapped subscriber.
|
TestSubscriber(org.reactivestreams.Subscriber<? super T> actual,
long initialRequest)
Constructs a forwarding TestSubscriber with the specified initial request value.
|
| Modifier and Type | Method and Description |
|---|---|
TestSubscriber<T> |
assertNotSubscribed()
Assert that the onSubscribe method hasn't been called at all.
|
TestSubscriber<T> |
assertOf(io.reactivex.common.functions.Consumer<? super TestSubscriber<T>> check)
Run a check consumer with this TestSubscriber instance.
|
TestSubscriber<T> |
assertSubscribed()
Assert that the onSubscribe method was called exactly once.
|
void |
cancel() |
static <T> TestSubscriber<T> |
create()
Creates a TestSubscriber with Long.MAX_VALUE initial request.
|
static <T> TestSubscriber<T> |
create(long initialRequested)
Creates a TestSubscriber with the given initial request.
|
static <T> TestSubscriber<T> |
create(org.reactivestreams.Subscriber<? super T> delegate)
Constructs a forwarding TestSubscriber.
|
void |
dispose() |
boolean |
hasSubscription()
Returns true if this TestSubscriber received a subscription.
|
boolean |
isCancelled()
Returns true if this TestSubscriber has been cancelled.
|
boolean |
isDisposed() |
void |
onComplete() |
void |
onError(java.lang.Throwable t) |
void |
onNext(T t) |
protected void |
onStart()
Called after the onSubscribe is called and handled.
|
void |
onSubscribe(org.reactivestreams.Subscription s) |
void |
request(long n) |
TestSubscriber<T> |
requestMore(long n)
Calls
request(long) and returns this. |
assertComplete, assertEmpty, assertError, assertError, assertError, assertErrorMessage, assertFailure, assertFailure, assertFailureAndMessage, assertNever, assertNever, assertNoErrors, assertNotComplete, assertNoTimeout, assertNotTerminated, assertNoValues, assertResult, assertTerminated, assertTimeout, assertValue, assertValue, assertValueAt, assertValueCount, assertValues, assertValueSequence, assertValueSet, await, await, awaitCount, awaitCount, awaitCount, awaitDone, awaitTerminalEvent, awaitTerminalEvent, clearTimeout, completions, errorCount, errors, fail, getEvents, isTerminated, isTimeout, lastThread, valueAndClass, valueCount, values, withTagpublic TestSubscriber()
public TestSubscriber(long initialRequest)
The TestSubscriber doesn't validate the initialRequest value so one can test sources with invalid values as well.
initialRequest - the initial request valuepublic TestSubscriber(org.reactivestreams.Subscriber<? super T> actual)
actual - the actual Subscriber to forward events topublic TestSubscriber(org.reactivestreams.Subscriber<? super T> actual, long initialRequest)
The TestSubscriber doesn't validate the initialRequest value so one can test sources with invalid values as well.
actual - the actual Subscriber to forward events toinitialRequest - the initial request valuepublic static <T> TestSubscriber<T> create()
T - the value typepublic static <T> TestSubscriber<T> create(long initialRequested)
T - the value typeinitialRequested - the initial requested amountpublic static <T> TestSubscriber<T> create(org.reactivestreams.Subscriber<? super T> delegate)
T - the value type receiveddelegate - the actual Subscriber to forward events topublic void onSubscribe(org.reactivestreams.Subscription s)
protected void onStart()
public void onError(java.lang.Throwable t)
onError in interface org.reactivestreams.Subscriber<T>public void onComplete()
onComplete in interface org.reactivestreams.Subscriber<T>public final void request(long n)
request in interface org.reactivestreams.Subscriptionpublic final void cancel()
cancel in interface org.reactivestreams.Subscriptionpublic final boolean isCancelled()
public final void dispose()
dispose in interface io.reactivex.common.Disposablepublic final boolean isDisposed()
isDisposed in interface io.reactivex.common.Disposablepublic final boolean hasSubscription()
public final TestSubscriber<T> assertSubscribed()
assertSubscribed in class io.reactivex.common.TestConsumer<T,TestSubscriber<T>>public final TestSubscriber<T> assertNotSubscribed()
assertNotSubscribed in class io.reactivex.common.TestConsumer<T,TestSubscriber<T>>public final TestSubscriber<T> assertOf(io.reactivex.common.functions.Consumer<? super TestSubscriber<T>> check)
check - the check consumer to runpublic final TestSubscriber<T> requestMore(long n)
request(long) and returns this.n - the request amount