Make WebTestClientExtensions.expectBody generics compliant
Closes gh-24142
This commit is contained in:
parent
bc7d010485
commit
6747cc1353
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue