Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StatusAssertion value methods fail when used with custom status code #26658

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public WebTestClient.ResponseSpec is5xxServerError() {
* @since 5.1
*/
public WebTestClient.ResponseSpec value(Matcher<? super Integer> matcher) {
int value = this.exchangeResult.getStatus().value();
int value = this.exchangeResult.getRawStatusCode();
this.exchangeResult.assertWithDiagnostics(() -> MatcherAssert.assertThat("Response status", value, matcher));
return this.responseSpec;
}
Expand All @@ -216,7 +216,7 @@ public WebTestClient.ResponseSpec value(Matcher<? super Integer> matcher) {
* @since 5.1
*/
public WebTestClient.ResponseSpec value(Consumer<Integer> consumer) {
int value = this.exchangeResult.getStatus().value();
int value = this.exchangeResult.getRawStatusCode();
this.exchangeResult.assertWithDiagnostics(() -> consumer.accept(value));
return this.responseSpec;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ void matches() {
assertions.value(equalTo(200)));
}

@Test
void matchesWithCustomStatus() {
statusAssertions(600).value(equalTo(600));
}

private StatusAssertions statusAssertions(HttpStatus status) {
return statusAssertions(status.value());
Expand Down