T
- the type of values that the subscriber containspublic static interface StepVerifier.Step<T> extends StepVerifier.LastStep
Modifier and Type | Method and Description |
---|---|
StepVerifier.Step<T> |
as(String description)
Set a description for the previous verification step.
|
default StepVerifier.Step<T> |
assertNext(Consumer<? super T> assertionConsumer)
Expect an element and consume it with the given consumer, usually performing
assertions on it (eg.
|
StepVerifier.Step<T> |
consumeNextWith(Consumer<? super T> consumer)
Expect an element and consume with the given consumer.Any
AssertionError s thrown by the consumer will be rethrown during verification. |
StepVerifier.Step<T> |
consumeRecordedWith(Consumer<? super Collection<T>> consumer)
Expect a recording session started via
recordWith(java.util.function.Supplier<? extends java.util.Collection<T>>) , end it and verify
it by applying the given consumer. |
StepVerifier.Step<T> |
consumeSubscriptionWith(Consumer<? super Subscription> consumer)
Expect a
Subscription and consume with the given consumer. |
StepVerifier.ContextExpectations<T> |
expectAccessibleContext()
Expect that after the
Subscription step, a Context has been
propagated. |
StepVerifier.Step<T> |
expectNext(T... ts)
Expect the next elements received to be equal to the given values.
|
StepVerifier.Step<T> |
expectNext(T t)
Expect the next element received to be equal to the given value.
|
StepVerifier.Step<T> |
expectNext(T t1,
T t2)
Expect the next elements received to be equal to the given values.
|
StepVerifier.Step<T> |
expectNext(T t1,
T t2,
T t3)
Expect the next elements received to be equal to the given values.
|
StepVerifier.Step<T> |
expectNext(T t1,
T t2,
T t3,
T t4)
Expect the next elements received to be equal to the given values.
|
StepVerifier.Step<T> |
expectNext(T t1,
T t2,
T t3,
T t4,
T t5)
Expect the next elements received to be equal to the given values.
|
StepVerifier.Step<T> |
expectNext(T t1,
T t2,
T t3,
T t4,
T t5,
T t6)
Expect the next elements received to be equal to the given values.
|
StepVerifier.Step<T> |
expectNextCount(long count)
Expect to received
count elements, starting from the previous
expectation or onSubscribe. |
StepVerifier.Step<T> |
expectNextMatches(Predicate<? super T> predicate)
Expect an element and evaluate with the given predicate.
|
StepVerifier.Step<T> |
expectNextSequence(Iterable<? extends T> iterable)
Expect the next elements to match the given
Iterable until its
iterator depletes. |
StepVerifier.Step<T> |
expectNoAccessibleContext()
Expect that NO
Context was propagated after the Subscription
phase, which usually indicates that the sequence under test doesn't contain
Reactor operators (i.e. |
StepVerifier.Step<T> |
expectNoEvent(Duration duration)
Expect that no event has been observed by the verifier for the length of
the provided
Duration . |
StepVerifier.Step<T> |
expectRecordedMatches(Predicate<? super Collection<T>> predicate)
Expect a recording session started via
recordWith(java.util.function.Supplier<? extends java.util.Collection<T>>) , end it and verify
it by ensuring the provided predicate matches. |
StepVerifier.Step<T> |
recordWith(Supplier<? extends Collection<T>> supplier)
Start a recording session storing
Subscriber.onNext(Object) values in
the supplied Collection . |
StepVerifier.Step<T> |
then(Runnable task)
Run an arbitrary task scheduled after previous expectations or tasks.
|
default StepVerifier.Step<T> |
thenAwait()
Mark a Pause in the expectation evaluation.
|
StepVerifier.Step<T> |
thenAwait(Duration timeshift)
Pause the expectation evaluation for a given
Duration . |
StepVerifier.Step<T> |
thenConsumeWhile(Predicate<T> predicate)
Consume further onNext signals as long as they match a predicate.
|
StepVerifier.Step<T> |
thenConsumeWhile(Predicate<T> predicate,
Consumer<T> consumer)
|
StepVerifier.Step<T> |
thenRequest(long n)
Request the given amount of elements from the upstream
Publisher . |
consumeErrorWith, expectComplete, expectError, expectError, expectErrorMatches, expectErrorMessage, expectErrorSatisfies, expectTimeout, thenCancel, verifyComplete, verifyError, verifyError, verifyErrorMatches, verifyErrorMessage, verifyErrorSatisfies, verifyTimeout
StepVerifier.Step<T> as(String description)
Note that calling this several times in a row will only take the first description into account.
description
- the description for the previous verification stepStepVerifier.Step<T> consumeNextWith(Consumer<? super T> consumer)
AssertionError
s thrown by the consumer will be rethrown during verification.consumer
- the consumer for the valuedefault StepVerifier.Step<T> assertNext(Consumer<? super T> assertionConsumer)
consumeNextWith(Consumer)
for better discoverability of
that use case.
Any AssertionError
s thrown by the consumer will be rethrown during
verification.
assertionConsumer
- the consumer for the value, performing assertionsStepVerifier.Step<T> consumeRecordedWith(Consumer<? super Collection<T>> consumer)
recordWith(java.util.function.Supplier<? extends java.util.Collection<T>>)
, end it and verify
it by applying the given consumer.
Any AssertionError
s thrown by the consumer will be rethrown during
verification.consumer
- the consumer used to apply assertions on the recorded sessionStepVerifier.Step<T> expectNext(T t)
t
- the value to expectSubscriber.onNext(Object)
StepVerifier.Step<T> expectNext(T t1, T t2)
t1
- the first value to expectt2
- the second value to expectSubscriber.onNext(Object)
StepVerifier.Step<T> expectNext(T t1, T t2, T t3)
t1
- the first value to expectt2
- the second value to expectt3
- the third value to expectSubscriber.onNext(Object)
StepVerifier.Step<T> expectNext(T t1, T t2, T t3, T t4)
t1
- the first value to expectt2
- the second value to expectt3
- the third value to expectt4
- the fourth value to expectSubscriber.onNext(Object)
StepVerifier.Step<T> expectNext(T t1, T t2, T t3, T t4, T t5)
t1
- the first value to expectt2
- the second value to expectt3
- the third value to expectt4
- the fourth value to expectt5
- the fifth value to expectSubscriber.onNext(Object)
StepVerifier.Step<T> expectNext(T t1, T t2, T t3, T t4, T t5, T t6)
t1
- the first value to expectt2
- the second value to expectt3
- the third value to expectt4
- the fourth value to expectt5
- the fifth value to expectt6
- the sixth value to expectSubscriber.onNext(Object)
StepVerifier.Step<T> expectNext(T... ts)
ts
- the values to expectSubscriber.onNext(Object)
StepVerifier.Step<T> expectNextCount(long count)
count
elements, starting from the previous
expectation or onSubscribe.count
- the number of emitted items to expect.Subscriber.onNext(Object)
StepVerifier.Step<T> expectNextSequence(Iterable<? extends T> iterable)
Iterable
until its
iterator depletes.iterable
- the iterable containing the next expected valuesSubscriber.onNext(Object)
StepVerifier.Step<T> expectNextMatches(Predicate<? super T> predicate)
predicate
- the predicate to test on the next received valueSubscriber.onNext(Object)
StepVerifier.Step<T> consumeSubscriptionWith(Consumer<? super Subscription> consumer)
Subscription
and consume with the given consumer. Any AssertionError
s thrown by the consumer will be rethrown during verification.consumer
- the consumer for the Subscription
Subscriber.onSubscribe(Subscription)
StepVerifier.ContextExpectations<T> expectAccessibleContext()
Subscription
step, a Context
has been
propagated. You can continue with assertions on said Context
, and you
will need to use StepVerifier.ContextExpectations.then()
to switch back to verifying
the sequence itself.StepVerifier.ContextExpectations
for further assertion of the propagated Context
StepVerifier.Step<T> expectNoAccessibleContext()
Context
was propagated after the Subscription
phase, which usually indicates that the sequence under test doesn't contain
Reactor operators (i.e. external Publisher, just a scalar source...).StepVerifier.Step<T> expectNoEvent(Duration duration)
Duration
. If virtual time is used, this duration is
verified using the virtual clock.
Note that you should only use this method as the first expectation if you
actually don't expect a subscription to happen. Use
StepVerifier.FirstStep.expectSubscription()
combined with expectNoEvent(Duration)
to work around that.
Also avoid using this method at the end of the set of expectations:
prefer StepVerifier.LastStep.expectTimeout(Duration)
rather than expectNoEvent(...).thenCancel()
.
duration
- the duration for which to observe no event has been receivedSubscriber
StepVerifier.Step<T> expectRecordedMatches(Predicate<? super Collection<T>> predicate)
recordWith(java.util.function.Supplier<? extends java.util.Collection<T>>)
, end it and verify
it by ensuring the provided predicate matches.predicate
- the predicate to test on the recorded sessionSubscriber.onNext(Object)
StepVerifier.Step<T> recordWith(Supplier<? extends Collection<T>> supplier)
Subscriber.onNext(Object)
values in
the supplied Collection
. Further steps
expectRecordedMatches(Predicate)
and
consumeRecordedWith(Consumer)
can consume and assert the session.
If an existing recording session hasn't not been declaratively consumed, this step will override the current session.
supplier
- the supplier for the Collection
to use for recording.StepVerifier.Step<T> then(Runnable task)
task
- the task to rundefault StepVerifier.Step<T> thenAwait()
VirtualTimeScheduler
has been configured,
VirtualTimeScheduler.advanceTime()
will be used and the
pause will not block testing or Publisher
thread.StepVerifier.Step<T> thenAwait(Duration timeshift)
Duration
.
If a VirtualTimeScheduler
has been configured,
VirtualTimeScheduler.advanceTimeBy(Duration)
will be used and the
pause will not block testing or Publisher
thread.timeshift
- a pause Duration
StepVerifier.Step<T> thenConsumeWhile(Predicate<T> predicate)
predicate
- the condition to continue consuming onNextStepVerifier.Step<T> thenConsumeWhile(Predicate<T> predicate, Consumer<T> consumer)
Consumer
as long as
they match a Predicate
. You can use the consumer to apply assertions
on each value.predicate
- the condition to continue consuming onNextconsumer
- the consumer to use to consume the data, when the predicate
matchesStepVerifier.Step<T> thenRequest(long n)
Publisher
. This
is in addition to the initial number of elements requested by an
initial passed demand like with StepVerifier.create(Publisher, long)
.n
- the number of elements to requestSubscription.request(long)