public interface StepVerifier
StepVerifier
is a verifiable, blocking script usually produced by
terminal expectations of the said script.
StepVerifier
builder using create(org.reactivestreams.Publisher<? extends T>)
or withVirtualTime(java.util.function.Supplier<? extends org.reactivestreams.Publisher<? extends T>>)
StepVerifier.Step.expectNext(T...)
, StepVerifier.Step.expectNextMatches(Predicate)
,
StepVerifier.Step.expectNextCount(long)
or
StepVerifier.Step.expectNextSequence(Iterable)
.thenRequest(long)
or thenCancel()
. StepVerifier
using StepVerifier.LastStep.expectComplete()
,
StepVerifier.LastStep.expectError()
, expectError(Class)
, expectErrorMatches(Predicate)
, or StepVerifier.LastStep.thenCancel()
. StepVerifier
to a Publisher
.verify()
or verify(Duration)
.AssertionError
will be thrown indicating the failures.For example:
StepVerifier.create(Flux.just("foo", "bar")) .expectNext("foo") .expectNext("bar") .expectComplete() .verify();
Modifier and Type | Interface and Description |
---|---|
static interface |
StepVerifier.Assertions
Exposes post-verification state assertions.
|
static interface |
StepVerifier.FirstStep<T>
Define a builder for explicitly expecting an initializing
Subscription as
first signal. |
static interface |
StepVerifier.LastStep
Define a builder for terminal states.
|
static interface |
StepVerifier.Step<T>
Define a builder for expecting main sequence individual signals.
|
Modifier and Type | Method and Description |
---|---|
static <T> StepVerifier.FirstStep<T> |
create(Publisher<? extends T> publisher)
Prepare a new
StepVerifier in an uncontrolled environment: Expect non-virtual
blocking
wait via
StepVerifier.Step.thenAwait() . |
static <T> StepVerifier.FirstStep<T> |
create(Publisher<? extends T> publisher,
long n)
Prepare a new
StepVerifier in an uncontrolled environment: Expect non-virtual
blocking
wait via
StepVerifier.Step.thenAwait() . |
static <T> StepVerifier.FirstStep<T> |
create(Publisher<? extends T> publisher,
StepVerifierOptions options)
Prepare a new
StepVerifier in an uncontrolled environment: Expect non-virtual
blocking wait via StepVerifier.Step.thenAwait() . |
StepVerifier |
log()
Activate debug logging of a description of the test scenario, as well as
some details about certain verification steps.
|
java.time.Duration |
verify()
Verify the signals received by this subscriber.
|
java.time.Duration |
verify(java.time.Duration duration)
Verify the signals received by this subscriber.
|
StepVerifier.Assertions |
verifyThenAssertThat()
Verifies the signals received by this subscriber, then exposes
various assertion methods on the final state. |
static <T> StepVerifier.FirstStep<T> |
withVirtualTime(long n,
java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier)
Deprecated.
to be removed in 3.1.0 for parameter ordering harmonization. Please
use
withVirtualTime(Supplier, long) instead. |
static <T> StepVerifier.FirstStep<T> |
withVirtualTime(long n,
java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier,
java.util.function.Supplier<? extends VirtualTimeScheduler> vtsLookup)
Deprecated.
to be removed in 3.1.0 for parameter ordering harmonization. Please
use
withVirtualTime(Supplier, Supplier, long) instead. |
static <T> StepVerifier.FirstStep<T> |
withVirtualTime(java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier)
Prepare a new
StepVerifier in a controlled environment using
VirtualTimeScheduler to schedule and expect virtual wait via
StepVerifier.Step.thenAwait() . |
static <T> StepVerifier.FirstStep<T> |
withVirtualTime(java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier,
long n)
Prepare a new
StepVerifier in a controlled environment using
VirtualTimeScheduler to schedule and expect virtual wait via
StepVerifier.Step.thenAwait() . |
static <T> StepVerifier.FirstStep<T> |
withVirtualTime(java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier,
StepVerifierOptions options)
Create a new
StepVerifier in a parameterized environment using
passed VirtualTimeScheduler to schedule and expect virtual wait via
StepVerifier.Step.thenAwait() . |
static <T> StepVerifier.FirstStep<T> |
withVirtualTime(java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier,
java.util.function.Supplier<? extends VirtualTimeScheduler> vtsLookup,
long n)
Create a new
StepVerifier in a parameterized environment using
passed
VirtualTimeScheduler to schedule and expect virtual wait via
StepVerifier.Step.thenAwait() . |
static <T> StepVerifier.FirstStep<T> create(Publisher<? extends T> publisher)
StepVerifier
in an uncontrolled environment: Expect non-virtual
blocking
wait via
StepVerifier.Step.thenAwait()
. Each verify()
will fully (re)play the
scenario.publisher
- the publisher to subscribe toDuration
of the verificationAssertionError
- in case of expectation failuresstatic <T> StepVerifier.FirstStep<T> create(Publisher<? extends T> publisher, long n)
StepVerifier
in an uncontrolled environment: Expect non-virtual
blocking
wait via
StepVerifier.Step.thenAwait()
. Each verify()
will fully (re)play the
scenario. The verification will request a
specified amount of
values.publisher
- the publisher to subscribe ton
- the amount of items to requestDuration
of the verificationAssertionError
- in case of expectation failures, or when the verification
times outstatic <T> StepVerifier.FirstStep<T> create(Publisher<? extends T> publisher, StepVerifierOptions options)
StepVerifier
in an uncontrolled environment: Expect non-virtual
blocking wait via StepVerifier.Step.thenAwait()
. Each verify()
will fully (re)play the
scenario. The verification will request a specified amount of values according to
the options
passed.publisher
- the publisher to subscribe tooptions
- the options for the verificationDuration
of the verificationAssertionError
- in case of expectation failures, or when the verification
times outstatic <T> StepVerifier.FirstStep<T> withVirtualTime(java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier)
StepVerifier
in a controlled environment using
VirtualTimeScheduler
to schedule and expect virtual wait via
StepVerifier.Step.thenAwait()
. Each verify()
will fully (re)play the
scenario. The verification will request an unbounded amount of values.T
- the type of the subscriberscenarioSupplier
- a mandatory supplier of the Publisher
to test@Deprecated static <T> StepVerifier.FirstStep<T> withVirtualTime(long n, java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier)
withVirtualTime(Supplier, long)
instead.static <T> StepVerifier.FirstStep<T> withVirtualTime(java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier, long n)
StepVerifier
in a controlled environment using
VirtualTimeScheduler
to schedule and expect virtual wait via
StepVerifier.Step.thenAwait()
. Each verify()
will fully (re)play the
scenario. The verification will request a specified amount of values.T
- the type of the subscriberscenarioSupplier
- a mandatory supplier of the Publisher
to testn
- the amount of items to request (must be >= 0)@Deprecated static <T> StepVerifier.FirstStep<T> withVirtualTime(long n, java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier, java.util.function.Supplier<? extends VirtualTimeScheduler> vtsLookup)
withVirtualTime(Supplier, Supplier, long)
instead.static <T> StepVerifier.FirstStep<T> withVirtualTime(java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier, java.util.function.Supplier<? extends VirtualTimeScheduler> vtsLookup, long n)
StepVerifier
in a parameterized environment using
passed
VirtualTimeScheduler
to schedule and expect virtual wait via
StepVerifier.Step.thenAwait()
. Each verify()
will fully (re)play the
scenario. The verification will request a specified amount of values.T
- the type of the subscriberscenarioSupplier
- a mandatory supplier of the Publisher
to testvtsLookup
- a mandatory VirtualTimeScheduler
lookup to use in thenAwait
n
- the amount of items to request (must be >= 0)static <T> StepVerifier.FirstStep<T> withVirtualTime(java.util.function.Supplier<? extends Publisher<? extends T>> scenarioSupplier, StepVerifierOptions options)
StepVerifier
in a parameterized environment using
passed VirtualTimeScheduler
to schedule and expect virtual wait via
StepVerifier.Step.thenAwait()
. Each verify()
will fully (re)play the
scenario. The verification will request a specified amount of values according to
the provided options
.T
- the type of the subscriberscenarioSupplier
- a mandatory supplier of the Publisher
to testoptions
- the verification options, including a mandatory
VirtualTimeScheduler
lookup to use in thenAwait
StepVerifier log()
verify()
calljava.time.Duration verify() throws AssertionError
Subscriber.onComplete()
, Subscriber.onError(Throwable)
or
Subscription.cancel()
).Duration
of the verificationAssertionError
- in case of expectation failuresjava.time.Duration verify(java.time.Duration duration) throws AssertionError
Subscriber.onComplete()
,
Subscriber.onError(Throwable)
or
Subscription.cancel()
).Duration
of the verificationAssertionError
- in case of expectation failures, or when the verification
times outStepVerifier.Assertions verifyThenAssertThat()
Verifies
the signals received by this subscriber, then exposes
various assertion methods
on the final state.
Note this method will block indefinitely until the stream has
been terminated (either through Subscriber.onComplete()
,
Subscriber.onError(Throwable)
or Subscription.cancel()
).
Duration
of the verificationAssertionError
- in case of expectation failures