Skip to content

Commit 6747cc1

Browse files
committed
Make WebTestClientExtensions.expectBody generics compliant
Closes gh-24142
1 parent bc7d010 commit 6747cc1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -68,7 +68,7 @@ inline fun <reified T : Any> RequestBodySpec.body(flow: Flow<T>): RequestHeaders
6868
*/
6969
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
7070
inline fun <reified B : Any> ResponseSpec.expectBody(): KotlinBodySpec<B> =
71-
expectBody(B::class.java).returnResult().let {
71+
expectBody(object : ParameterizedTypeReference<B>() {}).returnResult().let {
7272
object : KotlinBodySpec<B> {
7373

7474
override fun isEqualTo(expected: B): KotlinBodySpec<B> = it

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ class WebTestClientExtensionsTests {
6262
@Test
6363
fun `ResponseSpec#expectBody with reified type parameters`() {
6464
responseSpec.expectBody<Foo>()
65-
verify { responseSpec.expectBody(Foo::class.java) }
65+
verify { responseSpec.expectBody(object : ParameterizedTypeReference<Foo>() {}) }
6666
}
6767

6868
@Test

0 commit comments

Comments
 (0)