Browse Source

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
pull/23493/head
Rossen Stoyanchev 7 years ago
parent
commit
008687d5ae
  1. 6
      spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java
  2. 4
      spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java
  3. 2
      spring-test/src/test/java/org/springframework/test/web/reactive/server/ApplicationContextSpecTests.java
  4. 2
      spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ErrorTests.java
  5. 2
      spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/JsonContentTests.java
  6. 2
      spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java
  7. 2
      spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/XmlContentTests.java
  8. 2
      spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java
  9. 2
      spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java
  10. 6
      spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt
  11. 12
      spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java
  12. 4
      spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
  13. 8
      spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java
  14. 4
      spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java
  15. 4
      spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java
  16. 2
      spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt
  17. 8
      spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java
  18. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java
  19. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
  20. 8
      spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java
  21. 4
      spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java
  22. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java
  23. 14
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java
  24. 4
      spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt

6
spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java

@ -261,8 +261,8 @@ class DefaultWebTestClient implements WebTestClient { @@ -261,8 +261,8 @@ class DefaultWebTestClient implements WebTestClient {
}
@Override
public RequestHeadersSpec<?> body(Object body) {
this.bodySpec.body(body);
public RequestHeadersSpec<?> bodyValue(Object body) {
this.bodySpec.bodyValue(body);
return this;
}
@ -299,7 +299,7 @@ class DefaultWebTestClient implements WebTestClient { @@ -299,7 +299,7 @@ class DefaultWebTestClient implements WebTestClient {
@Override
@Deprecated
public RequestHeadersSpec<?> syncBody(Object body) {
return body(body);
return bodyValue(body);
}
@Override

4
spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java

@ -642,7 +642,7 @@ public interface WebTestClient { @@ -642,7 +642,7 @@ public interface WebTestClient {
* @return spec for decoding the response
* @since 5.2
*/
RequestHeadersSpec<?> body(Object body);
RequestHeadersSpec<?> bodyValue(Object body);
/**
* Set the body of the request to the given producer.
@ -713,7 +713,7 @@ public interface WebTestClient { @@ -713,7 +713,7 @@ public interface WebTestClient {
* @throws IllegalArgumentException if {@code body} is a {@link Publisher} or an
* instance of a type supported by {@link ReactiveAdapterRegistry#getSharedInstance()},
* for which {@link #body(Publisher, Class)} or {@link #body(Object, Class)} should be used.
* @deprecated as of Spring Framework 5.2 in favor of {@link #body(Object)}
* @deprecated as of Spring Framework 5.2 in favor of {@link #bodyValue(Object)}
*/
@Deprecated
RequestHeadersSpec<?> syncBody(Object body);

2
spring-test/src/test/java/org/springframework/test/web/reactive/server/ApplicationContextSpecTests.java

@ -61,7 +61,7 @@ public class ApplicationContextSpecTests { @@ -61,7 +61,7 @@ public class ApplicationContextSpecTests {
.GET("/sessionClassName", request ->
request.session().flatMap(session -> {
String className = session.getClass().getSimpleName();
return ServerResponse.ok().body(className);
return ServerResponse.ok().bodyValue(className);
}))
.build();
}

2
spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ErrorTests.java

@ -63,7 +63,7 @@ public class ErrorTests { @@ -63,7 +63,7 @@ public class ErrorTests {
EntityExchangeResult<Void> result = this.client.post()
.uri("/post")
.contentType(MediaType.APPLICATION_JSON)
.body(new Person("Dan"))
.bodyValue(new Person("Dan"))
.exchange()
.expectStatus().isBadRequest()
.expectBody().isEmpty();

2
spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/JsonContentTests.java

@ -82,7 +82,7 @@ public class JsonContentTests { @@ -82,7 +82,7 @@ public class JsonContentTests {
public void postJsonContent() {
this.client.post().uri("/persons")
.contentType(MediaType.APPLICATION_JSON)
.body("{\"name\":\"John\"}")
.bodyValue("{\"name\":\"John\"}")
.exchange()
.expectStatus().isCreated()
.expectBody().isEmpty();

2
spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java

@ -145,7 +145,7 @@ public class ResponseEntityTests { @@ -145,7 +145,7 @@ public class ResponseEntityTests {
@Test
public void postEntity() {
this.client.post()
.body(new Person("John"))
.bodyValue(new Person("John"))
.exchange()
.expectStatus().isCreated()
.expectHeader().valueEquals("location", "/persons/John")

2
spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/XmlContentTests.java

@ -116,7 +116,7 @@ public class XmlContentTests { @@ -116,7 +116,7 @@ public class XmlContentTests {
this.client.post().uri("/persons")
.contentType(MediaType.APPLICATION_XML)
.body(content)
.bodyValue(content)
.exchange()
.expectStatus().isCreated()
.expectHeader().valueEquals(HttpHeaders.LOCATION, "/persons/John")

2
spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java

@ -45,7 +45,7 @@ public class HttpServerTests { @@ -45,7 +45,7 @@ public class HttpServerTests {
@BeforeEach
public void start() throws Exception {
HttpHandler httpHandler = RouterFunctions.toHttpHandler(
route(GET("/test"), request -> ServerResponse.ok().body("It works!")));
route(GET("/test"), request -> ServerResponse.ok().bodyValue("It works!")));
this.server = new ReactorHttpServer();
this.server.setHandler(httpHandler);

2
spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java

@ -41,7 +41,7 @@ public class RouterFunctionTests { @@ -41,7 +41,7 @@ public class RouterFunctionTests {
public void setUp() throws Exception {
RouterFunction<?> route = route(GET("/test"), request ->
ServerResponse.ok().body("It works!"));
ServerResponse.ok().bodyValue("It works!"));
this.testClient = WebTestClient.bindToRouterFunction(route).build();
}

6
spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt

@ -70,7 +70,7 @@ class WebTestClientExtensionsTests { @@ -70,7 +70,7 @@ class WebTestClientExtensionsTests {
@Test
fun `KotlinBodySpec#isEqualTo`() {
WebTestClient
.bindToRouterFunction( router { GET("/") { ok().body("foo") } } )
.bindToRouterFunction( router { GET("/") { ok().bodyValue("foo") } } )
.build()
.get().uri("/").exchange().expectBody<String>().isEqualTo("foo")
}
@ -78,7 +78,7 @@ class WebTestClientExtensionsTests { @@ -78,7 +78,7 @@ class WebTestClientExtensionsTests {
@Test
fun `KotlinBodySpec#consumeWith`() {
WebTestClient
.bindToRouterFunction( router { GET("/") { ok().body("foo") } } )
.bindToRouterFunction( router { GET("/") { ok().bodyValue("foo") } } )
.build()
.get().uri("/").exchange().expectBody<String>().consumeWith { assertEquals("foo", it.responseBody) }
}
@ -86,7 +86,7 @@ class WebTestClientExtensionsTests { @@ -86,7 +86,7 @@ class WebTestClientExtensionsTests {
@Test
fun `KotlinBodySpec#returnResult`() {
WebTestClient
.bindToRouterFunction( router { GET("/") { ok().body("foo") } } )
.bindToRouterFunction( router { GET("/") { ok().bodyValue("foo") } } )
.build()
.get().uri("/").exchange().expectBody<String>().returnResult().apply { assertEquals("foo", responseBody) }
}

12
spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java

@ -78,7 +78,7 @@ public abstract class BodyInserters { @@ -78,7 +78,7 @@ public abstract class BodyInserters {
/**
* Inserter to write the given object.
* <p>Alternatively, consider using the {@code body(Object)} shortcuts on
* <p>Alternatively, consider using the {@code bodyValue(Object)} shortcuts on
* {@link org.springframework.web.reactive.function.client.WebClient WebClient} and
* {@link org.springframework.web.reactive.function.server.ServerResponse ServerResponse}.
* @param body the body to write to the response
@ -227,7 +227,7 @@ public abstract class BodyInserters { @@ -227,7 +227,7 @@ public abstract class BodyInserters {
* Return a {@link FormInserter} to write the given {@code MultiValueMap}
* as URL-encoded form data. The returned inserter allows for additional
* entries to be added via {@link FormInserter#with(String, Object)}.
* <p>Note that you can also use the {@code body(Object)} method in the
* <p>Note that you can also use the {@code bodyValue(Object)} method in the
* request builders of both the {@code WebClient} and {@code WebTestClient}.
* In that case the setting of the request content type is also not required,
* just be sure the map contains String values only or otherwise it would be
@ -259,7 +259,7 @@ public abstract class BodyInserters { @@ -259,7 +259,7 @@ public abstract class BodyInserters {
* Object or an {@link HttpEntity}.
* <p>Note that you can also build the multipart data externally with
* {@link MultipartBodyBuilder}, and pass the resulting map directly to the
* {@code body(Object)} shortcut method in {@code WebClient}.
* {@code bodyValue(Object)} shortcut method in {@code WebClient}.
* @param multipartData the form data to write to the output message
* @return the inserter that allows adding more parts
* @see MultipartBodyBuilder
@ -275,7 +275,7 @@ public abstract class BodyInserters { @@ -275,7 +275,7 @@ public abstract class BodyInserters {
* {@link HttpEntity}.
* <p>Note that you can also build the multipart data externally with
* {@link MultipartBodyBuilder}, and pass the resulting map directly to the
* {@code body(Object)} shortcut method in {@code WebClient}.
* {@code bodyValue(Object)} shortcut method in {@code WebClient}.
* @param name the part name
* @param value the part value, an Object or {@code HttpEntity}
* @return the inserter that allows adding more parts
@ -291,7 +291,7 @@ public abstract class BodyInserters { @@ -291,7 +291,7 @@ public abstract class BodyInserters {
* as multipart data.
* <p>Note that you can also build the multipart data externally with
* {@link MultipartBodyBuilder}, and pass the resulting map directly to the
* {@code body(Object)} shortcut method in {@code WebClient}.
* {@code bodyValue(Object)} shortcut method in {@code WebClient}.
* @param name the part name
* @param publisher the publisher that forms the part value
* @param elementClass the class contained in the {@code publisher}
@ -309,7 +309,7 @@ public abstract class BodyInserters { @@ -309,7 +309,7 @@ public abstract class BodyInserters {
* allows specifying generic type information.
* <p>Note that you can also build the multipart data externally with
* {@link MultipartBodyBuilder}, and pass the resulting map directly to the
* {@code body(Object)} shortcut method in {@code WebClient}.
* {@code bodyValue(Object)} shortcut method in {@code WebClient}.
* @param name the part name
* @param publisher the publisher that forms the part value
* @param typeReference the type contained in the {@code publisher}

4
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java

@ -288,7 +288,7 @@ class DefaultWebClient implements WebClient { @@ -288,7 +288,7 @@ class DefaultWebClient implements WebClient {
}
@Override
public RequestHeadersSpec<?> body(Object body) {
public RequestHeadersSpec<?> bodyValue(Object body) {
this.inserter = BodyInserters.fromObject(body);
return this;
}
@ -327,7 +327,7 @@ class DefaultWebClient implements WebClient { @@ -327,7 +327,7 @@ class DefaultWebClient implements WebClient {
@Override
@Deprecated
public RequestHeadersSpec<?> syncBody(Object body) {
return body(body);
return bodyValue(body);
}
@Override

8
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java

@ -59,7 +59,7 @@ import org.springframework.web.util.UriBuilderFactory; @@ -59,7 +59,7 @@ import org.springframework.web.util.UriBuilderFactory;
* </ul>
* <p>For examples with a request body see:
* <ul>
* <li>{@link RequestBodySpec#body(Object) body(Object)}
* <li>{@link RequestBodySpec#bodyValue(Object) bodyValue(Object)}
* <li>{@link RequestBodySpec#body(Publisher, Class) body(Publisher,Class)}
* <li>{@link RequestBodySpec#body(Object, Class) body(Object,Class)}
* <li>{@link RequestBodySpec#body(BodyInserter) body(BodyInserter)}
@ -528,7 +528,7 @@ public interface WebClient { @@ -528,7 +528,7 @@ public interface WebClient {
* Mono&lt;Void&gt; result = client.post()
* .uri("/persons/{id}", id)
* .contentType(MediaType.APPLICATION_JSON)
* .body(person)
* .bodyValue(person)
* .retrieve()
* .bodyToMono(Void.class);
* </pre>
@ -547,7 +547,7 @@ public interface WebClient { @@ -547,7 +547,7 @@ public interface WebClient {
* for which {@link #body(Publisher, Class)} or {@link #body(Object, Class)} should be used.
* @since 5.2
*/
RequestHeadersSpec<?> body(Object body);
RequestHeadersSpec<?> bodyValue(Object body);
/**
* A shortcut for {@link #body(BodyInserter)} with a
@ -657,7 +657,7 @@ public interface WebClient { @@ -657,7 +657,7 @@ public interface WebClient {
* @throws IllegalArgumentException if {@code body} is a {@link Publisher} or an
* instance of a type supported by {@link ReactiveAdapterRegistry#getSharedInstance()},
* for which {@link #body(Publisher, Class)} or {@link #body(Object, Class)} should be used.
* @deprecated as of Spring Framework 5.2 in favor of {@link #body(Object)}
* @deprecated as of Spring Framework 5.2 in favor of {@link #bodyValue(Object)}
*/
@Deprecated
RequestHeadersSpec<?> syncBody(Object body);

4
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java

@ -223,7 +223,7 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder { @@ -223,7 +223,7 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
}
@Override
public Mono<ServerResponse> body(Object body) {
public Mono<ServerResponse> bodyValue(Object body) {
return new DefaultEntityResponseBuilder<>(body,
BodyInserters.fromObject(body))
.status(this.statusCode)
@ -286,7 +286,7 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder { @@ -286,7 +286,7 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
@Override
@Deprecated
public Mono<ServerResponse> syncBody(Object body) {
return body(body);
return bodyValue(body);
}
@Override

4
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java

@ -408,7 +408,7 @@ public interface ServerResponse { @@ -408,7 +408,7 @@ public interface ServerResponse {
* for which {@link #body(Publisher, Class)} or {@link #body(Object, Class)} should be used.
* @since 5.2
*/
Mono<ServerResponse> body(Object body);
Mono<ServerResponse> bodyValue(Object body);
/**
* Set the body of the response to the given asynchronous {@code Publisher} and return it.
@ -479,7 +479,7 @@ public interface ServerResponse { @@ -479,7 +479,7 @@ public interface ServerResponse {
* @throws IllegalArgumentException if {@code body} is a {@link Publisher} or an
* instance of a type supported by {@link ReactiveAdapterRegistry#getSharedInstance()},
* for which {@link #body(Publisher, Class)} or {@link #body(Object, Class)} should be used.
* @deprecated as of Spring Framework 5.2 in favor of {@link #body(Object)}
* @deprecated as of Spring Framework 5.2 in favor of {@link #bodyValue(Object)}
*/
@Deprecated
Mono<ServerResponse> syncBody(Object body);

2
spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt

@ -75,7 +75,7 @@ inline fun <reified T : Any> ServerResponse.BodyBuilder.bodyWithType(publisher: @@ -75,7 +75,7 @@ inline fun <reified T : Any> ServerResponse.BodyBuilder.bodyWithType(publisher:
* instance of a type supported by [org.springframework.core.ReactiveAdapterRegistry.getSharedInstance],
*/
suspend fun ServerResponse.BodyBuilder.bodyAndAwait(body: Any): ServerResponse =
body(body).awaitSingle()
bodyValue(body).awaitSingle()
/**
* Coroutines variant of [ServerResponse.BodyBuilder.body] with [Any] and

8
spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java

@ -63,7 +63,7 @@ class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests { @@ -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 { @@ -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 { @@ -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 { @@ -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);

2
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java

@ -186,7 +186,7 @@ public class DefaultWebClientTests { @@ -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

2
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java

@ -514,7 +514,7 @@ class WebClientIntegrationTests { @@ -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);

8
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java

@ -309,7 +309,7 @@ public class DefaultServerResponseBuilderTests { @@ -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 { @@ -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 { @@ -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 { @@ -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")

4
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java

@ -32,8 +32,8 @@ class InvalidHttpMethodIntegrationTests extends AbstractRouterFunctionIntegratio @@ -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

2
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java

@ -137,7 +137,7 @@ class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrationTests @@ -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")

14
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java

@ -85,7 +85,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -183,7 +183,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
Mono<String> result = webClient
.post()
.uri("/modelAttribute")
.body(generateBody())
.bodyValue(generateBody())
.retrieve()
.bodyToMono(String.class);

4
spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt

@ -67,12 +67,12 @@ class ServerResponseExtensionsTests { @@ -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>())
}
}

Loading…
Cancel
Save