Polishing
This commit is contained in:
parent
97b3aa4b13
commit
c1b1940dd2
|
@ -71,8 +71,7 @@ public class StatusAssertions {
|
|||
* Assert the response status code is {@code HttpStatus.CREATED} (201).
|
||||
*/
|
||||
public WebTestClient.ResponseSpec isCreated() {
|
||||
HttpStatus expected = HttpStatus.CREATED;
|
||||
return assertStatusAndReturn(expected);
|
||||
return assertStatusAndReturn(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,8 +194,7 @@ public class StatusAssertions {
|
|||
* Assert the response status code is in the 5xx range.
|
||||
*/
|
||||
public WebTestClient.ResponseSpec is5xxServerError() {
|
||||
HttpStatus.Series expected = HttpStatus.Series.SERVER_ERROR;
|
||||
return assertSeriesAndReturn(expected);
|
||||
return assertSeriesAndReturn(HttpStatus.Series.SERVER_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,8 +203,8 @@ public class StatusAssertions {
|
|||
* @since 5.1
|
||||
*/
|
||||
public WebTestClient.ResponseSpec value(Matcher<? super Integer> matcher) {
|
||||
int value = this.exchangeResult.getRawStatusCode();
|
||||
this.exchangeResult.assertWithDiagnostics(() -> MatcherAssert.assertThat("Response status", value, matcher));
|
||||
int actual = this.exchangeResult.getRawStatusCode();
|
||||
this.exchangeResult.assertWithDiagnostics(() -> MatcherAssert.assertThat("Response status", actual, matcher));
|
||||
return this.responseSpec;
|
||||
}
|
||||
|
||||
|
@ -216,8 +214,8 @@ public class StatusAssertions {
|
|||
* @since 5.1
|
||||
*/
|
||||
public WebTestClient.ResponseSpec value(Consumer<Integer> consumer) {
|
||||
int value = this.exchangeResult.getRawStatusCode();
|
||||
this.exchangeResult.assertWithDiagnostics(() -> consumer.accept(value));
|
||||
int actual = this.exchangeResult.getRawStatusCode();
|
||||
this.exchangeResult.assertWithDiagnostics(() -> consumer.accept(actual));
|
||||
return this.responseSpec;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -56,7 +56,7 @@ class StatusAssertionTests {
|
|||
assertions.isEqualTo(408));
|
||||
}
|
||||
|
||||
@Test // gh-23630
|
||||
@Test // gh-23630
|
||||
void isEqualToWithCustomStatus() {
|
||||
statusAssertions(600).isEqualTo(600);
|
||||
}
|
||||
|
@ -74,20 +74,19 @@ class StatusAssertionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void statusSerius1xx() {
|
||||
void statusSeries1xx() {
|
||||
StatusAssertions assertions = statusAssertions(HttpStatus.CONTINUE);
|
||||
|
||||
// Success
|
||||
assertions.is1xxInformational();
|
||||
|
||||
// Wrong series
|
||||
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
|
||||
assertions.is2xxSuccessful());
|
||||
}
|
||||
|
||||
@Test
|
||||
void statusSerius2xx() {
|
||||
void statusSeries2xx() {
|
||||
StatusAssertions assertions = statusAssertions(HttpStatus.OK);
|
||||
|
||||
// Success
|
||||
|
@ -99,7 +98,7 @@ class StatusAssertionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void statusSerius3xx() {
|
||||
void statusSeries3xx() {
|
||||
StatusAssertions assertions = statusAssertions(HttpStatus.PERMANENT_REDIRECT);
|
||||
|
||||
// Success
|
||||
|
@ -111,7 +110,7 @@ class StatusAssertionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void statusSerius4xx() {
|
||||
void statusSeries4xx() {
|
||||
StatusAssertions assertions = statusAssertions(HttpStatus.BAD_REQUEST);
|
||||
|
||||
// Success
|
||||
|
@ -123,7 +122,7 @@ class StatusAssertionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void statusSerius5xx() {
|
||||
void statusSeries5xx() {
|
||||
StatusAssertions assertions = statusAssertions(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
|
||||
// Success
|
||||
|
@ -135,7 +134,7 @@ class StatusAssertionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void matches() {
|
||||
void matchesStatusValue() {
|
||||
StatusAssertions assertions = statusAssertions(HttpStatus.CONFLICT);
|
||||
|
||||
// Success
|
||||
|
@ -147,11 +146,12 @@ class StatusAssertionTests {
|
|||
assertions.value(equalTo(200)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesWithCustomStatus() {
|
||||
@Test // gh-26658
|
||||
void matchesCustomStatusValue() {
|
||||
statusAssertions(600).value(equalTo(600));
|
||||
}
|
||||
|
||||
|
||||
private StatusAssertions statusAssertions(HttpStatus status) {
|
||||
return statusAssertions(status.value());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue