Rename body(Object) to bodyValue
The recently added body(Object) variant can be confused easily with body(Publisher, Class) forgetting to provide the element type and only running into the IllegalArgumentException at runtime. See gh-23212
This commit is contained in:
@@ -63,7 +63,7 @@ class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
|
||||
Mono<ClientResponse> result = webClient
|
||||
.post()
|
||||
.uri("http://localhost:" + this.port + "/multipartData")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.exchange();
|
||||
|
||||
StepVerifier
|
||||
@@ -79,7 +79,7 @@ class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
|
||||
Mono<ClientResponse> result = webClient
|
||||
.post()
|
||||
.uri("http://localhost:" + this.port + "/parts")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.exchange();
|
||||
|
||||
StepVerifier
|
||||
@@ -95,7 +95,7 @@ class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
|
||||
Mono<String> result = webClient
|
||||
.post()
|
||||
.uri("http://localhost:" + this.port + "/transferTo")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.retrieve()
|
||||
.bodyToMono(String.class);
|
||||
|
||||
@@ -176,7 +176,7 @@ class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
|
||||
Path tempFile = Files.createTempFile("MultipartIntegrationTests", null);
|
||||
return part.transferTo(tempFile)
|
||||
.then(ServerResponse.ok()
|
||||
.body(tempFile.toString()));
|
||||
.bodyValue(tempFile.toString()));
|
||||
}
|
||||
catch (Exception e) {
|
||||
return Mono.error(e);
|
||||
|
||||
@@ -186,7 +186,7 @@ public class DefaultWebClientTests {
|
||||
WebClient client = this.builder.build();
|
||||
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
client.post().uri("https://example.com").body(mono));
|
||||
client.post().uri("https://example.com").bodyValue(mono));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -514,7 +514,7 @@ class WebClientIntegrationTests {
|
||||
.uri("/pojo/capitalize")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body(new Pojo("foofoo", "barbar"))
|
||||
.bodyValue(new Pojo("foofoo", "barbar"))
|
||||
.retrieve()
|
||||
.bodyToMono(Pojo.class);
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ public class DefaultServerResponseBuilderTests {
|
||||
public void copyCookies() {
|
||||
Mono<ServerResponse> serverResponse = ServerResponse.ok()
|
||||
.cookie(ResponseCookie.from("foo", "bar").build())
|
||||
.body("body");
|
||||
.bodyValue("body");
|
||||
|
||||
assertThat(serverResponse.block().cookies().isEmpty()).isFalse();
|
||||
|
||||
@@ -361,7 +361,7 @@ public class DefaultServerResponseBuilderTests {
|
||||
Mono<Void> mono = Mono.empty();
|
||||
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ServerResponse.ok().body(mono));
|
||||
ServerResponse.ok().bodyValue(mono));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -369,7 +369,7 @@ public class DefaultServerResponseBuilderTests {
|
||||
String etag = "\"foo\"";
|
||||
ServerResponse responseMono = ServerResponse.ok()
|
||||
.eTag(etag)
|
||||
.body("bar")
|
||||
.bodyValue("bar")
|
||||
.block();
|
||||
|
||||
MockServerHttpRequest request = MockServerHttpRequest.get("https://example.com")
|
||||
@@ -393,7 +393,7 @@ public class DefaultServerResponseBuilderTests {
|
||||
|
||||
ServerResponse responseMono = ServerResponse.ok()
|
||||
.lastModified(oneMinuteBeforeNow)
|
||||
.body("bar")
|
||||
.bodyValue("bar")
|
||||
.block();
|
||||
|
||||
MockServerHttpRequest request = MockServerHttpRequest.get("https://example.com")
|
||||
|
||||
@@ -32,8 +32,8 @@ class InvalidHttpMethodIntegrationTests extends AbstractRouterFunctionIntegratio
|
||||
@Override
|
||||
protected RouterFunction<?> routerFunction() {
|
||||
return RouterFunctions.route(RequestPredicates.GET("/"),
|
||||
request -> ServerResponse.ok().body("FOO"))
|
||||
.andRoute(RequestPredicates.all(), request -> ServerResponse.ok().body("BAR"));
|
||||
request -> ServerResponse.ok().bodyValue("FOO"))
|
||||
.andRoute(RequestPredicates.all(), request -> ServerResponse.ok().bodyValue("BAR"));
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
|
||||
@@ -137,7 +137,7 @@ class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrationTests
|
||||
|
||||
public Mono<ServerResponse> pattern(ServerRequest request) {
|
||||
String pattern = matchingPattern(request).getPatternString();
|
||||
return ServerResponse.ok().body(pattern);
|
||||
return ServerResponse.ok().bodyValue(pattern);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -85,7 +85,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
Mono<ClientResponse> result = webClient
|
||||
.post()
|
||||
.uri("/requestPart")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.exchange();
|
||||
|
||||
StepVerifier
|
||||
@@ -101,7 +101,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
Mono<String> result = webClient
|
||||
.post()
|
||||
.uri("/requestBodyMap")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.retrieve()
|
||||
.bodyToMono(String.class);
|
||||
|
||||
@@ -117,7 +117,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
Mono<String> result = webClient
|
||||
.post()
|
||||
.uri("/requestBodyFlux")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.retrieve()
|
||||
.bodyToMono(String.class);
|
||||
|
||||
@@ -133,7 +133,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
Mono<String> result = webClient
|
||||
.post()
|
||||
.uri("/filePartFlux")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.retrieve()
|
||||
.bodyToMono(String.class);
|
||||
|
||||
@@ -149,7 +149,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
Mono<String> result = webClient
|
||||
.post()
|
||||
.uri("/filePartMono")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.retrieve()
|
||||
.bodyToMono(String.class);
|
||||
|
||||
@@ -165,7 +165,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
Flux<String> result = webClient
|
||||
.post()
|
||||
.uri("/transferTo")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.retrieve()
|
||||
.bodyToFlux(String.class);
|
||||
|
||||
@@ -183,7 +183,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
Mono<String> result = webClient
|
||||
.post()
|
||||
.uri("/modelAttribute")
|
||||
.body(generateBody())
|
||||
.bodyValue(generateBody())
|
||||
.retrieve()
|
||||
.bodyToMono(String.class);
|
||||
|
||||
|
||||
@@ -67,12 +67,12 @@ class ServerResponseExtensionsTests {
|
||||
fun `BodyBuilder#bodyAndAwait with object parameter`() {
|
||||
val response = mockk<ServerResponse>()
|
||||
val body = "foo"
|
||||
every { bodyBuilder.body(ofType<String>()) } returns Mono.just(response)
|
||||
every { bodyBuilder.bodyValue(ofType<String>()) } returns Mono.just(response)
|
||||
runBlocking {
|
||||
bodyBuilder.bodyAndAwait(body)
|
||||
}
|
||||
verify {
|
||||
bodyBuilder.body(ofType<String>())
|
||||
bodyBuilder.bodyValue(ofType<String>())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user