From 57f0c2b7dfd343e974a5b973252712b8f5c463c5 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Sat, 31 Aug 2019 11:40:44 +0200 Subject: [PATCH] Remove bodyWithType extension from WebTestClient Since there is no more clash with the new bodyValue method name. See gh-23523 --- .../server/WebTestClientExtensions.kt | 21 ++++--------------- .../server/WebTestClientExtensionsTests.kt | 12 +++++------ 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt index 8634b6f319..b518fb1690 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt @@ -30,13 +30,12 @@ import org.springframework.test.web.reactive.server.WebTestClient.* * @author Sebastien Deleuze * @since 5.0 */ -@Deprecated("Use 'bodyWithType' instead.", replaceWith = ReplaceWith("bodyWithType(publisher)")) @Suppress("EXTENSION_SHADOWED_BY_MEMBER") inline fun > RequestBodySpec.body(publisher: S): RequestHeadersSpec<*> = body(publisher, object : ParameterizedTypeReference() {}) /** - * Extension for [RequestBodySpec.body] providing a `bodyWithType(Any)` variant + * Extension for [RequestBodySpec.body] providing a `body(Any)` variant * leveraging Kotlin reified type parameters. This extension is not subject to type * erasure and retains actual generic type arguments. * @param producer the producer to write to the request. This must be a @@ -46,23 +45,11 @@ inline fun > RequestBodySpec.body(publisher: S * @author Sebastien Deleuze * @since 5.2 */ -inline fun RequestBodySpec.bodyWithType(producer: Any): RequestHeadersSpec<*> +inline fun RequestBodySpec.body(producer: Any): RequestHeadersSpec<*> = body(producer, object : ParameterizedTypeReference() {}) /** - * Extension for [RequestBodySpec.body] providing a `bodyWithType(Publisher)` variant - * leveraging Kotlin reified type parameters. This extension is not subject to type - * erasure and retains actual generic type arguments. - * @param publisher the [Publisher] to write to the request - * @param the type of the elements contained in the publisher - * @author Sebastien Deleuze - * @since 5.2 - */ -inline fun RequestBodySpec.bodyWithType(publisher: Publisher): RequestHeadersSpec<*> = - body(publisher, object : ParameterizedTypeReference() {}) - -/** - * Extension for [RequestBodySpec.body] providing a `bodyWithType(Flow)` variant + * Extension for [RequestBodySpec.body] providing a `body(Flow)` variant * leveraging Kotlin reified type parameters. This extension is not subject to type * erasure and retains actual generic type arguments. * @param flow the [Flow] to write to the request @@ -71,7 +58,7 @@ inline fun RequestBodySpec.bodyWithType(publisher: Publisher RequestBodySpec.bodyWithType(flow: Flow): RequestHeadersSpec<*> = +inline fun RequestBodySpec.body(flow: Flow): RequestHeadersSpec<*> = body(flow, object : ParameterizedTypeReference() {}) /** diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt index 01718f647c..af25ab8278 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt @@ -40,24 +40,24 @@ class WebTestClientExtensionsTests { @Test - fun `RequestBodySpec#bodyWithType with Publisher and reified type parameters`() { + fun `RequestBodySpec#body with Publisher and reified type parameters`() { val body = mockk>() - requestBodySpec.bodyWithType(body) + requestBodySpec.body(body) verify { requestBodySpec.body(body, object : ParameterizedTypeReference() {}) } } @Test @ExperimentalCoroutinesApi - fun `RequestBodySpec#bodyWithType with Flow and reified type parameters`() { + fun `RequestBodySpec#body with Flow and reified type parameters`() { val body = mockk>() - requestBodySpec.bodyWithType(body) + requestBodySpec.body(body) verify { requestBodySpec.body(body, object : ParameterizedTypeReference() {}) } } @Test - fun `RequestBodySpec#bodyWithType with CompletableFuture and reified type parameters`() { + fun `RequestBodySpec#body with CompletableFuture and reified type parameters`() { val body = mockk>() - requestBodySpec.bodyWithType(body) + requestBodySpec.body(body) verify { requestBodySpec.body(body, object : ParameterizedTypeReference() {}) } }