Fix RestOperations extensions parameters nullability

Issue: SPR-16328
This commit is contained in:
sdeleuze
2017-12-27 17:49:41 +01:00
parent deac8e556e
commit d2616b7996
2 changed files with 51 additions and 17 deletions

View File

@@ -112,13 +112,20 @@ class RestOperationsExtensionsTests {
}
@Test
fun `patchForObject with reified type parameters`() {
fun `patchForObject with reified type parameters and String`() {
val url = "https://spring.io"
val body: Any = "body"
template.patchForObject<Foo>(url, body)
verify(template, times(1)).patchForObject(url, body, Foo::class.java)
}
@Test
fun `patchForObject with reified type parameters`() {
val url = "https://spring.io"
template.patchForObject<Foo>(url)
verify(template, times(1)).patchForObject(url, null, Foo::class.java)
}
@Test
fun `postForObject with reified type parameters, String and varargs`() {
val url = "https://spring.io"
@@ -139,13 +146,20 @@ class RestOperationsExtensionsTests {
}
@Test
fun `postForObject with reified type parameters`() {
fun `postForObject with reified type parameters and String`() {
val url = "https://spring.io"
val body: Any = "body"
template.postForObject<Foo>(url, body)
verify(template, times(1)).postForObject(url, body, Foo::class.java)
}
@Test
fun `postForObject with reified type parameters`() {
val url = "https://spring.io"
template.postForObject<Foo>(url)
verify(template, times(1)).postForObject(url, null, Foo::class.java)
}
@Test
fun `postForEntity with reified type parameters, String and varargs`() {
val url = "https://spring.io"
@@ -166,13 +180,20 @@ class RestOperationsExtensionsTests {
}
@Test
fun `postForEntity with reified type parameters`() {
fun `postForEntity with reified type parameters and String`() {
val url = "https://spring.io"
val body: Any = "body"
template.postForEntity<Foo>(url, body)
verify(template, times(1)).postForEntity(url, body, Foo::class.java)
}
@Test
fun `postForEntity with reified type parameters`() {
val url = "https://spring.io"
template.postForEntity<Foo>(url)
verify(template, times(1)).postForEntity(url, null, Foo::class.java)
}
@Test
fun `exchange with reified type parameters, String, HttpMethod, HttpEntity and varargs`() {
val url = "https://spring.io"
@@ -197,7 +218,7 @@ class RestOperationsExtensionsTests {
}
@Test
fun `exchange with reified type parameters, String, HttpMethod, HttpEntity`() {
fun `exchange with reified type parameters, String, HttpMethod and HttpEntity`() {
val url = "https://spring.io"
val method = HttpMethod.GET
val entity = mock<HttpEntity<Foo>>()
@@ -207,7 +228,16 @@ class RestOperationsExtensionsTests {
}
@Test
fun `exchange with reified type parameters, String, HttpEntity`() {
fun `exchange with reified type parameters, String and HttpMethod`() {
val url = "https://spring.io"
val method = HttpMethod.GET
template.exchange<List<Foo>>(url, method)
verify(template, times(1)).exchange(url, method, null,
object : ParameterizedTypeReference<List<Foo>>() {})
}
@Test
fun `exchange with reified type parameters, String and HttpEntity`() {
val entity = mock<RequestEntity<Foo>>()
template.exchange<List<Foo>>(entity)
verify(template, times(1)).exchange(entity,