public class TestSubscriberJson extends TestSubscriberGeneric<io.vertx.core.json.JsonObject>
Helper class as subscriber to the request methods extending TestSubscriberGeneric for use with JsonObject adds the ability to put expected results into a queue
TestSubscriberJson sub = new TestSubscriberJson()
.expectFailure()
.errorClass(SomeError.class)
.errorMessage(String message)
.expectedOnNextCount(42)
.minimumOnNextCount(3)
.maximumOnNextCount(100)
.expectEmpty(true)
.failOnAdditionalFieldsInActual(true)
.addfieldToExist("SomeName")
.setIgnoreMissingFieldsInActual(false);
When you specify an exact number, maximum and minimum don’t make sense, but will still get reported
_additionalTests
Constructor and Description |
---|
TestSubscriberJson()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
TestSubscriberJson |
addExpectedValue(io.vertx.core.json.JsonObject expected)
Add an expected entry onto a queue, expectation is a strict sequence in return
|
TestSubscriberJson |
addfieldToExist(java.lang.String fieldName)
CHecks for the existence of a field in JSON without checking type or content, Just the bare existence
|
TestSubscriberJson |
expectedOnNextCount(int expectedOnNextCount)
Sets the exact number of returned items we expect default is -1 = no expectations
|
TestSubscriberJson |
expectEmpty(boolean expectEmpty)
When set to true, an empty {} is acceptable in JSON default is false
|
TestSubscriberJson |
failOnAdditionalFieldsInActual(boolean failOnAdditionalFieldsInActual)
If we compare Json elements, actual might have more elements than expected, if we need to ensure that, we can set this property to true, default is false, additional fields get ignored
|
TestSubscriberJson |
ignoreMissingFieldsInActual(boolean ignoreMissingFieldsInActual)
By default missing fields in actual throw an error, setting this to true will only compared fields found.
|
TestSubscriberJson |
maximumOnNextCount(int maximumOnNextCount)
Sets the maximum of returned items we expect, default is -1 = no expectations
|
TestSubscriberJson |
minimumOnNextCount(int minimumOnNextCount)
Sets the minimum of returned items we expect, default is -1 = no expectations
|
void |
onNext(io.vertx.core.json.JsonObject actual) |
TestSubscriberJson |
setAdditionalTests(java.util.function.Consumer<io.vertx.core.json.JsonObject> additionalTests)
Callback to hook additional tests into the onNext phase of the Subscriber
|
close, expectFailure, externalErrorHandling, getDataCount, isDisposed, onComplete, onError, onSubscribe, serialize, setCancellable, setDisposable, tryOnError
public TestSubscriberJson addExpectedValue(@Nonnull io.vertx.core.json.JsonObject expected)
Add an expected entry onto a queue, expectation is a strict sequence in return
expected
- public TestSubscriberJson addfieldToExist(java.lang.String fieldName)
CHecks for the existence of a field in JSON without checking type or content, Just the bare existence
fieldName
- public TestSubscriberJson expectedOnNextCount(int expectedOnNextCount)
TestSubscriberGeneric
Sets the exact number of returned items we expect default is -1 = no expectations
expectedOnNextCount
in class TestSubscriberGeneric<io.vertx.core.json.JsonObject>
public TestSubscriberJson expectEmpty(boolean expectEmpty)
When set to true, an empty {} is acceptable in JSON default is false
expectEmpty
- true = accept {}, false = complaintpublic TestSubscriberJson failOnAdditionalFieldsInActual(boolean failOnAdditionalFieldsInActual)
If we compare Json elements, actual might have more elements than expected, if we need to ensure that, we can set this property to true, default is false, additional fields get ignored
failOnAdditionalFieldsInActual
- true for no extra fields, false for ignore extra fieldspublic TestSubscriberJson ignoreMissingFieldsInActual(boolean ignoreMissingFieldsInActual)
By default missing fields in actual throw an error, setting this to true will only compared fields found. Default = false
ignoreMissingFieldsInActual
- true: only fields in actual are compared, false throws and errorpublic TestSubscriberJson maximumOnNextCount(int maximumOnNextCount)
TestSubscriberGeneric
Sets the maximum of returned items we expect, default is -1 = no expectations
maximumOnNextCount
in class TestSubscriberGeneric<io.vertx.core.json.JsonObject>
public TestSubscriberJson minimumOnNextCount(int minimumOnNextCount)
TestSubscriberGeneric
Sets the minimum of returned items we expect, default is -1 = no expectations
minimumOnNextCount
in class TestSubscriberGeneric<io.vertx.core.json.JsonObject>
public void onNext(io.vertx.core.json.JsonObject actual)
onNext
in interface io.reactivex.Emitter<io.vertx.core.json.JsonObject>
onNext
in interface io.reactivex.Observer<io.vertx.core.json.JsonObject>
onNext
in class TestSubscriberGeneric<io.vertx.core.json.JsonObject>
public TestSubscriberJson setAdditionalTests(java.util.function.Consumer<io.vertx.core.json.JsonObject> additionalTests)
Callback to hook additional tests into the onNext phase of the Subscriber
setAdditionalTests
in class TestSubscriberGeneric<io.vertx.core.json.JsonObject>
additionalTests
- additional tests and assertions to run