Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannizotta committed Jul 6, 2023
1 parent dd72b5a commit ebeec96
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1414,4 +1414,20 @@ Duration after(StepVerifier.LastStep step, Duration duration) {
return step.verifyTimeout(duration);
}
}

/** Avoid collecting when verifying only the given element is in the given {@link Flux}. */
static final class VerifyOnlyElementInFlux<T> {
@BeforeTemplate
Duration before(Flux<T> flux, T object) {
return flux.collect(toImmutableList())
.as(StepVerifier::create)
.assertNext(list -> assertThat(list).containsExactly(object))
.verifyComplete();
}

@AfterTemplate
Duration after(Flux<T> flux, T object) {
return flux.as(StepVerifier::create).expectNext(object).verifyComplete();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,12 @@ Duration testStepVerifierLastStepVerifyErrorMessage() {
Duration testStepVerifierLastStepVerifyTimeout() {
return StepVerifier.create(Mono.empty()).expectTimeout(Duration.ZERO).verify();
}

Duration testVerifyOnlyElementInFlux() {
return Flux.just(1)
.collect(toImmutableList())
.as(StepVerifier::create)
.assertNext(list -> assertThat(list).containsExactly(1))
.verifyComplete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,8 @@ Duration testStepVerifierLastStepVerifyErrorMessage() {
Duration testStepVerifierLastStepVerifyTimeout() {
return StepVerifier.create(Mono.empty()).verifyTimeout(Duration.ZERO);
}

Duration testVerifyOnlyElementInFlux() {
return Flux.just(1).as(StepVerifier::create).expectNext(1).verifyComplete();
}
}

0 comments on commit ebeec96

Please sign in to comment.