Align with body method changes in RequestBodySpec

Closes gh-17460
This commit is contained in:
Andy Wilkinson
2019-07-09 12:13:23 +01:00
parent 3e6c15c451
commit d93c79316d
6 changed files with 11 additions and 12 deletions

View File

@@ -163,7 +163,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
Map<String, Object> body = new HashMap<>();
body.put("foo", "one");
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
load(TestEndpointConfiguration.class, (context, client) -> {
Map<String, Object> body = new HashMap<>();
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);
});
}

View File

@@ -80,7 +80,7 @@ class ControllerEndpointHandlerMappingIntegrationTests {
@Test
void post() {
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")));
}

View File

@@ -79,7 +79,7 @@ class ControllerEndpointHandlerMappingIntegrationTests {
@Test
void post() {
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")));
}

View File

@@ -95,7 +95,7 @@ class LoggersEndpointWebIntegrationTests {
@WebEndpointTest
void setLoggerUsingApplicationJsonShouldSetLogLevel() {
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);
}
@@ -103,15 +103,14 @@ class LoggersEndpointWebIntegrationTests {
void setLoggerUsingActuatorV2JsonShouldSetLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT")
.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);
}
@WebEndpointTest
void setLoggerWithWrongLogLevelResultInBadRequestResponse() {
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
.syncBody(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus()
.isBadRequest();
.body(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus().isBadRequest();
verifyZeroInteractions(this.loggingSystem);
}
@@ -119,14 +118,14 @@ class LoggersEndpointWebIntegrationTests {
void setLoggerWithNullLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT")
.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);
}
@WebEndpointTest
void setLoggerWithNoLogLevel() {
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();
verify(this.loggingSystem).setLogLevel("ROOT", null);
}