Commit d93c7931 authored by Andy Wilkinson's avatar Andy Wilkinson

Align with body method changes in RequestBodySpec

Closes gh-17460
parent 3e6c15c4
...@@ -163,7 +163,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable ...@@ -163,7 +163,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
Map<String, Object> body = new HashMap<>(); Map<String, Object> body = new HashMap<>();
body.put("foo", "one"); body.put("foo", "one");
body.put("bar", "two"); body.put("bar", "two");
client.post().uri("/test").syncBody(body).exchange().expectStatus().isNoContent().expectBody().isEmpty(); client.post().uri("/test").body(body).exchange().expectStatus().isNoContent().expectBody().isEmpty();
}); });
} }
...@@ -194,7 +194,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable ...@@ -194,7 +194,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
load(TestEndpointConfiguration.class, (context, client) -> { load(TestEndpointConfiguration.class, (context, client) -> {
Map<String, Object> body = new HashMap<>(); Map<String, Object> body = new HashMap<>();
body.put("foo", "one"); body.put("foo", "one");
client.post().uri("/test").syncBody(body).exchange().expectStatus().isNoContent().expectBody().isEmpty(); client.post().uri("/test").body(body).exchange().expectStatus().isNoContent().expectBody().isEmpty();
verify(context.getBean(EndpointDelegate.class)).write("one", null); verify(context.getBean(EndpointDelegate.class)).write("one", null);
}); });
} }
......
...@@ -80,7 +80,7 @@ class ControllerEndpointHandlerMappingIntegrationTests { ...@@ -80,7 +80,7 @@ class ControllerEndpointHandlerMappingIntegrationTests {
@Test @Test
void post() { void post() {
this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.post().uri("/actuator/example/two") this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.post().uri("/actuator/example/two")
.syncBody(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader() .body(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader()
.valueEquals(HttpHeaders.LOCATION, "/example/test"))); .valueEquals(HttpHeaders.LOCATION, "/example/test")));
} }
......
...@@ -79,7 +79,7 @@ class ControllerEndpointHandlerMappingIntegrationTests { ...@@ -79,7 +79,7 @@ class ControllerEndpointHandlerMappingIntegrationTests {
@Test @Test
void post() { void post() {
this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.post().uri("/actuator/example/two") this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.post().uri("/actuator/example/two")
.syncBody(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader() .body(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader()
.valueEquals(HttpHeaders.LOCATION, "/example/test"))); .valueEquals(HttpHeaders.LOCATION, "/example/test")));
} }
......
...@@ -95,7 +95,7 @@ class LoggersEndpointWebIntegrationTests { ...@@ -95,7 +95,7 @@ class LoggersEndpointWebIntegrationTests {
@WebEndpointTest @WebEndpointTest
void setLoggerUsingApplicationJsonShouldSetLogLevel() { void setLoggerUsingApplicationJsonShouldSetLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
.syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus().isNoContent(); .body(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
} }
...@@ -103,15 +103,14 @@ class LoggersEndpointWebIntegrationTests { ...@@ -103,15 +103,14 @@ class LoggersEndpointWebIntegrationTests {
void setLoggerUsingActuatorV2JsonShouldSetLogLevel() { void setLoggerUsingActuatorV2JsonShouldSetLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT") this.client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)) .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus().isNoContent(); .body(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
} }
@WebEndpointTest @WebEndpointTest
void setLoggerWithWrongLogLevelResultInBadRequestResponse() { void setLoggerWithWrongLogLevelResultInBadRequestResponse() {
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
.syncBody(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus() .body(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus().isBadRequest();
.isBadRequest();
verifyZeroInteractions(this.loggingSystem); verifyZeroInteractions(this.loggingSystem);
} }
...@@ -119,14 +118,14 @@ class LoggersEndpointWebIntegrationTests { ...@@ -119,14 +118,14 @@ class LoggersEndpointWebIntegrationTests {
void setLoggerWithNullLogLevel() { void setLoggerWithNullLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT") this.client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)) .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent(); .body(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null); verify(this.loggingSystem).setLogLevel("ROOT", null);
} }
@WebEndpointTest @WebEndpointTest
void setLoggerWithNoLogLevel() { void setLoggerWithNoLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT") this.client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)).syncBody(Collections.emptyMap()) .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)).body(Collections.emptyMap())
.exchange().expectStatus().isNoContent(); .exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null); verify(this.loggingSystem).setLogLevel("ROOT", null);
} }
......
...@@ -222,7 +222,7 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept ...@@ -222,7 +222,7 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept
builder.append("<div style='white-space:pre-wrap;'>").append(htmlEscape(trace)).append("</div>"); builder.append("<div style='white-space:pre-wrap;'>").append(htmlEscape(trace)).append("</div>");
} }
builder.append("</body></html>"); builder.append("</body></html>");
return responseBody.syncBody(builder.toString()); return responseBody.body(builder.toString());
} }
private String htmlEscape(Object input) { private String htmlEscape(Object input) {
......
...@@ -111,7 +111,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { ...@@ -111,7 +111,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests {
void bindingResultError() { void bindingResultError() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
WebTestClient client = getWebClient(context); WebTestClient client = getWebClient(context);
client.post().uri("/bind").contentType(MediaType.APPLICATION_JSON).syncBody("{}").exchange().expectStatus() client.post().uri("/bind").contentType(MediaType.APPLICATION_JSON).body("{}").exchange().expectStatus()
.isBadRequest().expectBody().jsonPath("status").isEqualTo("400").jsonPath("error") .isBadRequest().expectBody().jsonPath("status").isEqualTo("400").jsonPath("error")
.isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase()).jsonPath("path").isEqualTo(("/bind")) .isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase()).jsonPath("path").isEqualTo(("/bind"))
.jsonPath("exception").doesNotExist().jsonPath("errors").isArray().jsonPath("message").isNotEmpty() .jsonPath("exception").doesNotExist().jsonPath("errors").isArray().jsonPath("message").isNotEmpty()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment