File tree 2 files changed +6
-6
lines changed
main/kotlin/org/springframework/web/client
test/kotlin/org/springframework/web/client
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,10 @@ inline fun <reified T : Any> RestClient.ResponseSpec.body(): T? =
43
43
body(object : ParameterizedTypeReference <T >() {})
44
44
45
45
/* *
46
- * Extension for [RestClient.ResponseSpec.body] providing a `bodyNotNull <Foo>()` variant
46
+ * Extension for [RestClient.ResponseSpec.body] providing a `requiredBody <Foo>()` variant
47
47
* To leverage Kotlin null safety, this extension throws a [NoSuchElementException] if the response body is null.
48
48
*/
49
- inline fun <reified T : Any > RestClient.ResponseSpec.bodyNotNull (): T =
49
+ inline fun <reified T : Any > RestClient.ResponseSpec.requiredBody (): T =
50
50
body(object : ParameterizedTypeReference <T >() {}) ? : throw NoSuchElementException (" Response body is null when a non-null type was expected." )
51
51
52
52
/* *
Original file line number Diff line number Diff line change @@ -48,15 +48,15 @@ class RestClientExtensionsTests {
48
48
}
49
49
50
50
@Test
51
- fun `ResponseSpec#bodyNotNull with reified type parameters` () {
52
- responseSpec.bodyNotNull <List <Foo >>()
51
+ fun `ResponseSpec#requiredBody with reified type parameters` () {
52
+ responseSpec.requiredBody <List <Foo >>()
53
53
verify { responseSpec.body(object : ParameterizedTypeReference <List <Foo >>() {}) }
54
54
}
55
55
56
56
@Test
57
- fun `ResponseSpec#bodyNotNull with null response throws NoSuchElementException` () {
57
+ fun `ResponseSpec#requiredBody with null response throws NoSuchElementException` () {
58
58
every { responseSpec.body(any<ParameterizedTypeReference <Foo >>()) } returns null
59
- assertThrows<NoSuchElementException > { responseSpec.bodyNotNull <Foo >() }
59
+ assertThrows<NoSuchElementException > { responseSpec.requiredBody <Foo >() }
60
60
}
61
61
62
62
@Test
You can’t perform that action at this time.
0 commit comments