Make WebTestClientExtensions.expectBody generics compliant

Closes gh-24142
This commit is contained in:
Sébastien Deleuze 2020-01-13 10:05:17 +01:00
parent bc7d010485
commit 6747cc1353
2 changed files with 4 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
inline fun <reified B : Any> ResponseSpec.expectBody(): KotlinBodySpec<B> =
expectBody(B::class.java).returnResult().let {
expectBody(object : ParameterizedTypeReference<B>() {}).returnResult().let {
object : KotlinBodySpec<B> {
override fun isEqualTo(expected: B): KotlinBodySpec<B> = it

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -62,7 +62,7 @@ class WebTestClientExtensionsTests {
@Test
fun `ResponseSpec#expectBody with reified type parameters`() {
responseSpec.expectBody<Foo>()
verify { responseSpec.expectBody(Foo::class.java) }
verify { responseSpec.expectBody(object : ParameterizedTypeReference<Foo>() {}) }
}
@Test