mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-05-03 03:43:54 +01:00
Fix broken endpoint integration tests
Ensure that JSON response is returned when extracting data from the error details. See gh-12513
This commit is contained in:
+4
-2
@@ -168,7 +168,8 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
|||||||
public void readOperationWithMappingFailureProducesBadRequestResponse() {
|
public void readOperationWithMappingFailureProducesBadRequestResponse() {
|
||||||
load(QueryEndpointConfiguration.class, (client) -> {
|
load(QueryEndpointConfiguration.class, (client) -> {
|
||||||
WebTestClient.BodyContentSpec body = client.get().uri("/query?two=two")
|
WebTestClient.BodyContentSpec body = client.get().uri("/query?two=two")
|
||||||
.exchange().expectStatus().isBadRequest().expectBody();
|
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus()
|
||||||
|
.isBadRequest().expectBody();
|
||||||
validateErrorBody(body, HttpStatus.BAD_REQUEST, "/endpoints/query",
|
validateErrorBody(body, HttpStatus.BAD_REQUEST, "/endpoints/query",
|
||||||
"Missing parameters: one");
|
"Missing parameters: one");
|
||||||
});
|
});
|
||||||
@@ -290,7 +291,8 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
|||||||
public void readOperationWithMissingRequiredParametersReturnsBadRequestResponse() {
|
public void readOperationWithMissingRequiredParametersReturnsBadRequestResponse() {
|
||||||
load(RequiredParameterEndpointConfiguration.class, (client) -> {
|
load(RequiredParameterEndpointConfiguration.class, (client) -> {
|
||||||
WebTestClient.BodyContentSpec body = client.get().uri("/requiredparameters")
|
WebTestClient.BodyContentSpec body = client.get().uri("/requiredparameters")
|
||||||
.exchange().expectStatus().isBadRequest().expectBody();
|
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus()
|
||||||
|
.isBadRequest().expectBody();
|
||||||
validateErrorBody(body, HttpStatus.BAD_REQUEST,
|
validateErrorBody(body, HttpStatus.BAD_REQUEST,
|
||||||
"/endpoints/requiredparameters", "Missing parameters: foo");
|
"/endpoints/requiredparameters", "Missing parameters: foo");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user