pixel
pixel

Reputation: 26441

Reactor test Step Verifier - check that every next event matches predicate

I would like to verify that every onNext emission matches the given predicate.

I tried expectNextMatches:

StepVerifier.create(...)
    .expectNextMatches { it.status != "SUCCESS" }
    .expectComplete()
    .verify()

However, it matches only one emission, not every single one.

Upvotes: 2

Views: 1710

Answers (1)

lkatiforis
lkatiforis

Reputation: 6255

There's an operator for that:

StepVerifier.create(...)
    .thenConsumeWhile(it -> it.status != "SUCCESS")
    .expectComplete()
    .verify();

If there is any element in the sequence that doesn't match, the StepVerifier will error.

Upvotes: 6

Related Questions