Package reactor.test
Class StepVerifierOptions
java.lang.Object
reactor.test.StepVerifierOptions
Options for a
StepVerifier, including the initial request amount,
VirtualTimeScheduler supplier and toggles for some checks.- Author:
- Simon Basle
-
Method Summary
Modifier and TypeMethodDescriptioncheckUnderRequesting(boolean enabled) Activate or deactivate theStepVerifiercheck of request amount being too low.copy()Make a copy of thisStepVerifierOptionsinstance.static StepVerifierOptionscreate()Create a new default set of options for aStepVerifierthat can be tuned using the various available non-getter methods (which can be chained).extractor(ValueFormatters.Extractor<T> extractor) Add anValueFormatters.Extractor, replacing any existingValueFormatters.Extractorthat targets the sameClass(as inValueFormatters.Extractor.getTargetClass()).Get the list of value extractors added to the options, including default ones at the end (unless they've been individually replaced).longGet the custom object formatter to use when producing messages.@Nullable Supplier<? extends VirtualTimeScheduler>initialRequest(long initialRequest) Set the amount theStepVerifiershould request initially.booleanscenarioName(@Nullable String scenarioName) Give a name to the whole scenario tested by the configuredStepVerifier.valueFormatter(@Nullable ValueFormatters.ToStringConverter valueFormatter) Set up a custom value formatter to be used in error messages when presenting expected and actual values.virtualTimeSchedulerSupplier(Supplier<? extends VirtualTimeScheduler> vtsLookup) Set a supplier for aVirtualTimeScheduler, which is mandatory for aStepVerifierto work with virtual time.withInitialContext(Context context) Set an initialContextto be propagated by theStepVerifierwhen it subscribes to the sequence under test.
-
Method Details
-
create
Create a new default set of options for aStepVerifierthat can be tuned using the various available non-getter methods (which can be chained). -
copy
Make a copy of thisStepVerifierOptionsinstance.- Returns:
- a copy of the options that can be further mutated without impacting the original
-
checkUnderRequesting
Activate or deactivate theStepVerifiercheck of request amount being too low. Defauts to true.- Parameters:
enabled- true if the check should be enabled.- Returns:
- this instance, to continue setting the options.
-
isCheckUnderRequesting
public boolean isCheckUnderRequesting()- Returns:
- true if the
StepVerifierreceiving these options should activate the check of request amount being too low.
-
initialRequest
Set the amount theStepVerifiershould request initially. Defaults to unbounded request (Long.MAX_VALUE).- Parameters:
initialRequest- the initial request amount.- Returns:
- this instance, to continue setting the options.
-
getInitialRequest
public long getInitialRequest()- Returns:
- the initial request amount to be made by the
StepVerifierreceiving these options.
-
valueFormatter
public StepVerifierOptions valueFormatter(@Nullable ValueFormatters.ToStringConverter valueFormatter) Set up a custom value formatter to be used in error messages when presenting expected and actual values. This is intended for classes that have obscureObject.toString()implementation that cannot be overridden.This is a
Functioncapable of formatting an arbitraryObjecttoString, with the intention of detecting elements from the sequence under test and applying customizedStringconversion to them (and simply callingObject.toString()on other objects).See
ValueFormattersfor factories of such functions.- Parameters:
valueFormatter- the custom value toStringformatter, or null to deactivate custom formatting- Returns:
- this instance, to continue setting the options
-
getValueFormatter
Get the custom object formatter to use when producing messages. The formatter should be able to work with anyObject, usually filtering types matching the content of the sequence under test, and applying a simpleStringconversion on other objects.- Returns:
- the custom value formatter, or null if no specific formatting has been defined.
-
extractor
Add anValueFormatters.Extractor, replacing any existingValueFormatters.Extractorthat targets the sameClass(as inValueFormatters.Extractor.getTargetClass()).Note that by default, default extractors for
Signal,IterableandObject[]are in place.- Type Parameters:
T- the type of container considered by this extractor- Parameters:
extractor- the extractor to add / set- Returns:
- this instance, to continue setting the options
-
getExtractors
Get the list of value extractors added to the options, including default ones at the end (unless they've been individually replaced).The
Collectionis a copy, and mutating the collection doesn't mutate the configured extractors in thisStepVerifierOptions.- Returns:
- the collection of value
ValueFormatters.Extractor
-
virtualTimeSchedulerSupplier
public StepVerifierOptions virtualTimeSchedulerSupplier(Supplier<? extends VirtualTimeScheduler> vtsLookup) Set a supplier for aVirtualTimeScheduler, which is mandatory for aStepVerifierto work with virtual time. Defaults to null.- Parameters:
vtsLookup- the supplier ofVirtualTimeSchedulerto use.- Returns:
- this instance, to continue setting the options.
-
getVirtualTimeSchedulerSupplier
- Returns:
- the supplier of
VirtualTimeSchedulerto be used by theStepVerifierreceiving these options.
-
withInitialContext
Set an initialContextto be propagated by theStepVerifierwhen it subscribes to the sequence under test.- Parameters:
context- theContextto propagate.- Returns:
- this instance, to continue setting the options.
-
getInitialContext
- Returns:
- the
Contextto be propagated initially by theStepVerifier.
-
scenarioName
Give a name to the whole scenario tested by the configuredStepVerifier. That name would be mentioned in exceptions and assertion errors raised by the StepVerifier, allowing to better distinguish error sources in unit tests where multiple StepVerifier are used.- Parameters:
scenarioName- the name of the scenario, null to deactivate- Returns:
- this instance, to continue setting the options.
-
getScenarioName
- Returns:
- the name given to the configured
StepVerifier, or null if none.
-