|
|
|
@ -238,6 +238,22 @@ class InvocableHandlerMethodKotlinTests { |
|
|
|
Assertions.assertThat(value).isEqualTo("foo-20") |
|
|
|
Assertions.assertThat(value).isEqualTo("foo-20") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
fun contextParameter() { |
|
|
|
|
|
|
|
composite.addResolver(StubArgumentResolver(CustomException::class.java, CustomException("foo"))) |
|
|
|
|
|
|
|
val value = getInvocable(ReflectionUtils.findMethod(ContextParameterHandler::class.java, "handle", CustomException::class.java)!!).invokeForRequest(request, null) |
|
|
|
|
|
|
|
Assertions.assertThat(value).isEqualTo("foo") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
fun contextParameterWithParameter() { |
|
|
|
|
|
|
|
composite.addResolver(StubArgumentResolver(CustomException::class.java, CustomException("foo"))) |
|
|
|
|
|
|
|
composite.addResolver(StubArgumentResolver(Int::class.java, 20)) |
|
|
|
|
|
|
|
val value = getInvocable(ReflectionUtils.findMethod(ContextParameterHandler::class.java, "handleWithParameter", CustomException::class.java, Int::class.java)!!) |
|
|
|
|
|
|
|
.invokeForRequest(request, null) |
|
|
|
|
|
|
|
Assertions.assertThat(value).isEqualTo("foo-20") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
fun genericParameter() { |
|
|
|
fun genericParameter() { |
|
|
|
val horse = Animal("horse") |
|
|
|
val horse = Animal("horse") |
|
|
|
@ -359,6 +375,19 @@ class InvocableHandlerMethodKotlinTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class ContextParameterHandler { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context(exception: CustomException) |
|
|
|
|
|
|
|
fun handle(): String { |
|
|
|
|
|
|
|
return "${exception.message}" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context(exception: CustomException) |
|
|
|
|
|
|
|
fun handleWithParameter(limit: Int): String { |
|
|
|
|
|
|
|
return "${exception.message}-$limit" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private abstract class GenericHandler<T : Named> { |
|
|
|
private abstract class GenericHandler<T : Named> { |
|
|
|
|
|
|
|
|
|
|
|
fun handle(named: T) = named.name |
|
|
|
fun handle(named: T) = named.name |
|
|
|
|