T
- The class we expect from the actual class, mostly JSONpublic class TestSubscriberGeneric<T>
extends java.lang.Object
implements io.reactivex.ObservableEmitter<T>, io.reactivex.Observer<T>
Helper class as subscriber to the request methods allows to specify what behavior is expected by fluently add properties to the constructor e.g.
java TestSubscriberJson sub = new TestSubscriberJson()
.expectFailure()
.errorClass(SomeError.class)
.errorMessage(String message)
.expectedOnNextCount(42)
.minimumOnNextCount(3)
.maximumOnNextCount(100);
When you specify an exact number, maximum and minimum don’t make sense, but will still get reported
Modifier and Type | Field and Description |
---|---|
protected java.util.function.Consumer<T> |
_additionalTests |
Constructor and Description |
---|
TestSubscriberGeneric()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close connection to check if results are OK
|
TestSubscriberGeneric<T> |
expectedOnNextCount(int expectedOnNextCount)
Sets the exact number of returned items we expect default is -1 = no expectations
|
TestSubscriberGeneric<T> |
expectFailure(boolean expectFailure)
Specify if we expect the listener to succeed
|
TestSubscriberGeneric<T> |
externalErrorHandling(boolean externalFailureHandling)
Specify when an an external Error handler is capturing the error
|
int |
getDataCount() |
boolean |
isDisposed() |
TestSubscriberGeneric<T> |
maximumOnNextCount(int maximumOnNextCount)
Sets the maximum of returned items we expect, default is -1 = no expectations
|
TestSubscriberGeneric<T> |
minimumOnNextCount(int minimumOnNextCount)
Sets the minimum of returned items we expect, default is -1 = no expectations
|
void |
onComplete() |
void |
onError(java.lang.Throwable error) |
void |
onNext(T value) |
void |
onSubscribe(io.reactivex.disposables.Disposable disposable) |
io.reactivex.ObservableEmitter<T> |
serialize() |
TestSubscriberGeneric<T> |
setAdditionalTests(java.util.function.Consumer<T> additionalTests)
Callback to hook additional tests into the onNext phase of the Subscriber
|
void |
setCancellable(io.reactivex.functions.Cancellable c) |
void |
setDisposable(io.reactivex.disposables.Disposable d) |
boolean |
tryOnError(java.lang.Throwable t) |
protected java.util.function.Consumer<T> _additionalTests
public void close()
Close connection to check if results are OK
public TestSubscriberGeneric<T> expectedOnNextCount(int expectedOnNextCount)
Sets the exact number of returned items we expect default is -1 = no expectations
expectedOnNextCount
- public TestSubscriberGeneric<T> expectFailure(boolean expectFailure)
Specify if we expect the listener to succeed
expectFailure
- true if we expect onError but not onNextpublic TestSubscriberGeneric<T> externalErrorHandling(boolean externalFailureHandling)
Specify when an an external Error handler is capturing the error
externalFailureHandling
- true if we handle errors externallypublic int getDataCount()
public boolean isDisposed()
isDisposed
in interface io.reactivex.ObservableEmitter<T>
public TestSubscriberGeneric<T> maximumOnNextCount(int maximumOnNextCount)
Sets the maximum of returned items we expect, default is -1 = no expectations
maximumOnNextCount
- public TestSubscriberGeneric<T> minimumOnNextCount(int minimumOnNextCount)
Sets the minimum of returned items we expect, default is -1 = no expectations
minimumOnNextCount
- public void onComplete()
public void onError(java.lang.Throwable error)
public void onNext(T value)
public void onSubscribe(io.reactivex.disposables.Disposable disposable)
onSubscribe
in interface io.reactivex.Observer<T>
public io.reactivex.ObservableEmitter<T> serialize()
serialize
in interface io.reactivex.ObservableEmitter<T>
public TestSubscriberGeneric<T> setAdditionalTests(java.util.function.Consumer<T> additionalTests)
Callback to hook additional tests into the onNext phase of the Subscriber
additionalTests
- additional tests and assertions to runpublic void setCancellable(io.reactivex.functions.Cancellable c)
setCancellable
in interface io.reactivex.ObservableEmitter<T>
public void setDisposable(io.reactivex.disposables.Disposable d)
setDisposable
in interface io.reactivex.ObservableEmitter<T>
public boolean tryOnError(java.lang.Throwable t)
tryOnError
in interface io.reactivex.ObservableEmitter<T>