Polish Kotlin source code style
This commit is contained in:
@@ -23,7 +23,6 @@ import org.springframework.http.RequestEntity
|
||||
import org.springframework.http.ResponseEntity
|
||||
import java.net.URI
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [RestOperations.getForObject] avoiding specifying the type
|
||||
* parameter thanks to Kotlin reified type parameters.
|
||||
@@ -117,7 +116,8 @@ inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any)
|
||||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, vararg uriVariables: Any): ResponseEntity<T> =
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any,
|
||||
vararg uriVariables: Any): ResponseEntity<T> =
|
||||
postForEntity(url, request, T::class.java, *uriVariables)
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,8 @@ inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: A
|
||||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, uriVariables: Map<String, *>): ResponseEntity<T> =
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any,
|
||||
uriVariables: Map<String, *>): ResponseEntity<T> =
|
||||
postForEntity(url, request, T::class.java, uriVariables)
|
||||
|
||||
/**
|
||||
@@ -153,7 +154,8 @@ inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any)
|
||||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, vararg uriVariables: Any): ResponseEntity<T> =
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod,
|
||||
requestEntity: HttpEntity<*>, vararg uriVariables: Any): ResponseEntity<T> =
|
||||
exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {}, *uriVariables)
|
||||
|
||||
/**
|
||||
@@ -165,7 +167,8 @@ inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMet
|
||||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, uriVariables: Map<String, *>): ResponseEntity<T> =
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod,
|
||||
requestEntity: HttpEntity<*>, uriVariables: Map<String, *>): ResponseEntity<T> =
|
||||
exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {}, uriVariables)
|
||||
|
||||
/**
|
||||
@@ -177,7 +180,8 @@ inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMet
|
||||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<*>): ResponseEntity<T> =
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod,
|
||||
requestEntity: HttpEntity<*>): ResponseEntity<T> =
|
||||
exchange(url, method, requestEntity, object : ParameterizedTypeReference<T>() {})
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.http.RequestEntity
|
||||
import java.net.URI
|
||||
|
||||
/**
|
||||
* Mock object based tests for [RestOperations] Kotlin extensions
|
||||
* Mock object based tests for [RestOperations] Kotlin extensions.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@@ -135,7 +135,8 @@ class RestOperationsExtensionsTests {
|
||||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
template.exchange<List<Foo>>(url, method, entity, var1, var2)
|
||||
verify(template, times(1)).exchange(url, method, entity, object : ParameterizedTypeReference<List<Foo>>() {}, var1, var2)
|
||||
verify(template, times(1)).exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}, var1, var2)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,7 +146,8 @@ class RestOperationsExtensionsTests {
|
||||
val entity = mock<HttpEntity<Foo>>()
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
template.exchange<List<Foo>>(url, method, entity, vars)
|
||||
verify(template, times(1)).exchange(url, method, entity, object : ParameterizedTypeReference<List<Foo>>() {}, vars)
|
||||
verify(template, times(1)).exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}, vars)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -154,14 +156,16 @@ class RestOperationsExtensionsTests {
|
||||
val method = HttpMethod.GET
|
||||
val entity = mock<HttpEntity<Foo>>()
|
||||
template.exchange<List<Foo>>(url, method, entity)
|
||||
verify(template, times(1)).exchange(url, method, entity, object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify(template, times(1)).exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `exchange with reified type parameters, String, HttpEntity`() {
|
||||
val entity = mock<RequestEntity<Foo>>()
|
||||
template.exchange<List<Foo>>(entity)
|
||||
verify(template, times(1)).exchange(entity, object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify(template, times(1)).exchange(entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.method.annotation
|
||||
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Before
|
||||
|
||||
Reference in New Issue
Block a user