Skip to content

Commit

Permalink
Introduce StepVerifierLastStepVerifyErrorMatchesAssertions Refaster…
Browse files Browse the repository at this point in the history
… rule
  • Loading branch information
werli committed Apr 11, 2024
1 parent f4ab9b4 commit 7395f93
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,22 @@ Duration after(StepVerifier.LastStep step, Predicate<Throwable> predicate) {
}
}

/**
* Prefer {@link StepVerifier.LastStep#verifyErrorMatches(Predicate)} over more verbose
* alternatives.
*/
static final class StepVerifierLastStepVerifyErrorMatchesAssertions {
@BeforeTemplate
void before(StepVerifier.LastStep step, Predicate<Throwable> predicate) {
step.expectError().verifyThenAssertThat().hasOperatorErrorMatching(predicate);
}

@AfterTemplate
void after(StepVerifier.LastStep step, Predicate<Throwable> predicate) {
step.verifyErrorMatches(predicate);
}
}

/**
* Prefer {@link StepVerifier.LastStep#verifyErrorSatisfies(Consumer)} over more verbose
* alternatives.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,14 @@ Duration testStepVerifierLastStepVerifyErrorMatches() {
.verify();
}

void testStepVerifierLastStepVerifyErrorMatchesAssertions() {
Mono.empty()
.as(StepVerifier::create)
.expectError()
.verifyThenAssertThat()
.hasOperatorErrorMatching(IllegalArgumentException.class::equals);
}

Duration testStepVerifierLastStepVerifyErrorSatisfies() {
return Mono.empty().as(StepVerifier::create).expectErrorSatisfies(t -> {}).verify();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,12 @@ Duration testStepVerifierLastStepVerifyErrorMatches() {
.verifyErrorMatches(IllegalArgumentException.class::equals);
}

void testStepVerifierLastStepVerifyErrorMatchesAssertions() {
Mono.empty()
.as(StepVerifier::create)
.verifyErrorMatches(IllegalArgumentException.class::equals);
}

Duration testStepVerifierLastStepVerifyErrorSatisfies() {
return Mono.empty().as(StepVerifier::create).verifyErrorSatisfies(t -> {});
}
Expand Down

0 comments on commit 7395f93

Please sign in to comment.