File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
main/kotlin/org/springframework/beans/factory
test/kotlin/org/springframework/beans/factory Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,6 @@ inline fun <reified T : Annotation> ListableBeanFactory.getBeansWithAnnotation()
64
64
* @author Sebastien Deleuze
65
65
* @since 5.0
66
66
*/
67
- inline fun <reified T : Annotation > ListableBeanFactory.findAnnotationOnBean (beanName : String ): Annotation ? =
67
+ inline fun <reified T : Annotation > ListableBeanFactory.findAnnotationOnBean (beanName : String ): T ? =
68
68
findAnnotationOnBean(beanName, T ::class .java)
69
69
Original file line number Diff line number Diff line change 16
16
17
17
package org.springframework.beans.factory
18
18
19
+ import io.mockk.every
19
20
import io.mockk.mockk
20
21
import io.mockk.verify
21
22
import org.junit.jupiter.api.Test
23
+ import kotlin.reflect.full.createInstance
22
24
23
25
/* *
24
26
* Mock object based tests for ListableBeanFactory Kotlin extensions
@@ -77,10 +79,12 @@ class ListableBeanFactoryExtensionsTests {
77
79
verify { lbf.getBeansWithAnnotation(Bar ::class .java) }
78
80
}
79
81
82
+ @Suppress(" UNUSED_VARIABLE" )
80
83
@Test
81
84
fun `findAnnotationOnBean with String and reified type parameters` () {
82
85
val name = " bar"
83
- lbf.findAnnotationOnBean<Bar >(name)
86
+ every { lbf.findAnnotationOnBean(name, Bar ::class .java) } returns Bar ::class .createInstance()
87
+ val annotation: Bar ? = lbf.findAnnotationOnBean(name)
84
88
verify { lbf.findAnnotationOnBean(name, Bar ::class .java) }
85
89
}
86
90
You can’t perform that action at this time.
0 commit comments