Skip to content

Commit 86580b2

Browse files
committed
Polishing
1 parent 736bf1c commit 86580b2

File tree

16 files changed

+772
-778
lines changed

16 files changed

+772
-778
lines changed

spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import org.junit.Test
44
import org.junit.runner.RunWith
55
import org.mockito.Answers
66
import org.mockito.Mock
7-
import org.mockito.Mockito
8-
import org.mockito.Mockito.verify
7+
import org.mockito.Mockito.*
98
import org.mockito.junit.MockitoJUnitRunner
109

1110
/**
@@ -16,43 +15,43 @@ import org.mockito.junit.MockitoJUnitRunner
1615
@RunWith(MockitoJUnitRunner::class)
1716
class BeanFactoryExtensionsTests {
1817

19-
@Mock(answer = Answers.RETURNS_MOCKS)
20-
lateinit var bf: BeanFactory
21-
22-
@Test
23-
fun `getBean with KClass`() {
24-
bf.getBean(Foo::class)
25-
verify(bf, Mockito.times(1)).getBean(Foo::class.java)
26-
}
27-
28-
@Test
29-
fun `getBean with reified type parameters`() {
30-
bf.getBean<Foo>()
31-
verify(bf, Mockito.times(1)).getBean(Foo::class.java)
32-
}
33-
34-
@Test
35-
fun `getBean with String and reified type parameters`() {
36-
val name = "foo"
37-
bf.getBean<Foo>(name)
38-
verify(bf, Mockito.times(1)).getBean(name, Foo::class.java)
39-
}
40-
41-
@Test
42-
fun `getBean with KClass and varargs`() {
43-
val arg1 = "arg1"
44-
val arg2 = "arg2"
45-
bf.getBean(Foo::class, arg1, arg2)
46-
verify(bf, Mockito.times(1)).getBean(Foo::class.java, arg1, arg2)
47-
}
48-
49-
@Test
50-
fun `getBean with reified type parameters and varargs`() {
51-
val arg1 = "arg1"
52-
val arg2 = "arg2"
53-
bf.getBean<Foo>(arg1, arg2)
54-
verify(bf, Mockito.times(1)).getBean(Foo::class.java, arg1, arg2)
55-
}
56-
57-
class Foo
18+
@Mock(answer = Answers.RETURNS_MOCKS)
19+
lateinit var bf: BeanFactory
20+
21+
@Test
22+
fun `getBean with KClass`() {
23+
bf.getBean(Foo::class)
24+
verify(bf, times(1)).getBean(Foo::class.java)
25+
}
26+
27+
@Test
28+
fun `getBean with reified type parameters`() {
29+
bf.getBean<Foo>()
30+
verify(bf, times(1)).getBean(Foo::class.java)
31+
}
32+
33+
@Test
34+
fun `getBean with String and reified type parameters`() {
35+
val name = "foo"
36+
bf.getBean<Foo>(name)
37+
verify(bf, times(1)).getBean(name, Foo::class.java)
38+
}
39+
40+
@Test
41+
fun `getBean with KClass and varargs`() {
42+
val arg1 = "arg1"
43+
val arg2 = "arg2"
44+
bf.getBean(Foo::class, arg1, arg2)
45+
verify(bf, times(1)).getBean(Foo::class.java, arg1, arg2)
46+
}
47+
48+
@Test
49+
fun `getBean with reified type parameters and varargs`() {
50+
val arg1 = "arg1"
51+
val arg2 = "arg2"
52+
bf.getBean<Foo>(arg1, arg2)
53+
verify(bf, times(1)).getBean(Foo::class.java, arg1, arg2)
54+
}
55+
56+
class Foo
5857
}

spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt

Lines changed: 119 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.junit.Test
44
import org.junit.runner.RunWith
55
import org.mockito.Answers
66
import org.mockito.Mock
7-
import org.mockito.Mockito
7+
import org.mockito.Mockito.*
88
import org.mockito.junit.MockitoJUnitRunner
99

1010
/**
@@ -13,122 +13,122 @@ import org.mockito.junit.MockitoJUnitRunner
1313
* @author Sebastien Deleuze
1414
*/
1515
@RunWith(MockitoJUnitRunner::class)
16-
class ListenableBeanFactoryExtensionsTests {
17-
18-
@Mock(answer = Answers.RETURNS_MOCKS)
19-
lateinit var lbf: ListableBeanFactory
20-
21-
@Test
22-
fun `getBeanNamesForType with KClass`() {
23-
lbf.getBeanNamesForType(Foo::class)
24-
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, true , true)
25-
}
26-
27-
@Test
28-
fun `getBeanNamesForType with KClass and Boolean`() {
29-
lbf.getBeanNamesForType(Foo::class, false)
30-
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, false , true)
31-
}
32-
33-
@Test
34-
fun `getBeanNamesForType with KClass, Boolean and Boolean`() {
35-
lbf.getBeanNamesForType(Foo::class, false, false)
36-
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, false , false)
37-
}
38-
39-
@Test
40-
fun `getBeanNamesForType with reified type parameters`() {
41-
lbf.getBeanNamesForType<Foo>()
42-
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, true , true)
43-
}
44-
45-
@Test
46-
fun `getBeanNamesForType with reified type parameters and Boolean`() {
47-
lbf.getBeanNamesForType<Foo>(false)
48-
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, false , true)
49-
}
50-
51-
@Test
52-
fun `getBeanNamesForType with reified type parameters, Boolean and Boolean`() {
53-
lbf.getBeanNamesForType<Foo>(false, false)
54-
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, false , false)
55-
}
56-
57-
@Test
58-
fun `getBeansOfType with KClass`() {
59-
lbf.getBeansOfType(Foo::class)
60-
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, true , true)
61-
}
62-
63-
@Test
64-
fun `getBeansOfType with KClass and Boolean`() {
65-
lbf.getBeansOfType(Foo::class, false)
66-
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, false , true)
67-
}
68-
69-
@Test
70-
fun `getBeansOfType with KClass, Boolean and Boolean`() {
71-
lbf.getBeansOfType(Foo::class, false, false)
72-
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, false , false)
73-
}
74-
75-
@Test
76-
fun `getBeansOfType with reified type parameters`() {
77-
lbf.getBeansOfType<Foo>()
78-
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, true , true)
79-
}
80-
81-
@Test
82-
fun `getBeansOfType with reified type parameters and Boolean`() {
83-
lbf.getBeansOfType<Foo>(false)
84-
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, false , true)
85-
}
86-
87-
@Test
88-
fun `getBeansOfType with reified type parameters, Boolean and Boolean`() {
89-
lbf.getBeansOfType<Foo>(false, false)
90-
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, false , false)
91-
}
92-
93-
@Test
94-
fun `getBeanNamesForAnnotation with KClass`() {
95-
lbf.getBeanNamesForAnnotation(Bar::class)
96-
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForAnnotation(Bar::class.java)
97-
}
98-
99-
@Test
100-
fun `getBeanNamesForAnnotation with reified type parameters`() {
101-
lbf.getBeanNamesForAnnotation<Bar>()
102-
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForAnnotation(Bar::class.java)
103-
}
104-
105-
@Test
106-
fun `getBeansWithAnnotation with KClass`() {
107-
lbf.getBeansWithAnnotation(Bar::class)
108-
Mockito.verify(lbf, Mockito.times(1)).getBeansWithAnnotation(Bar::class.java)
109-
}
110-
111-
@Test
112-
fun `getBeansWithAnnotation with reified type parameters`() {
113-
lbf.getBeansWithAnnotation<Bar>()
114-
Mockito.verify(lbf, Mockito.times(1)).getBeansWithAnnotation(Bar::class.java)
115-
}
116-
117-
@Test
118-
fun `findAnnotationOnBean with String and KClass`() {
119-
val name = "bar"
120-
lbf.findAnnotationOnBean(name, Bar::class)
121-
Mockito.verify(lbf, Mockito.times(1)).findAnnotationOnBean(name, Bar::class.java)
122-
}
123-
124-
@Test
125-
fun `findAnnotationOnBean with String and reified type parameters`() {
126-
val name = "bar"
127-
lbf.findAnnotationOnBean<Bar>(name)
128-
Mockito.verify(lbf, Mockito.times(1)).findAnnotationOnBean(name, Bar::class.java)
129-
}
130-
131-
class Foo
132-
133-
annotation class Bar
16+
class ListableBeanFactoryExtensionsTests {
17+
18+
@Mock(answer = Answers.RETURNS_MOCKS)
19+
lateinit var lbf: ListableBeanFactory
20+
21+
@Test
22+
fun `getBeanNamesForType with KClass`() {
23+
lbf.getBeanNamesForType(Foo::class)
24+
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, true , true)
25+
}
26+
27+
@Test
28+
fun `getBeanNamesForType with KClass and Boolean`() {
29+
lbf.getBeanNamesForType(Foo::class, false)
30+
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , true)
31+
}
32+
33+
@Test
34+
fun `getBeanNamesForType with KClass, Boolean and Boolean`() {
35+
lbf.getBeanNamesForType(Foo::class, false, false)
36+
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , false)
37+
}
38+
39+
@Test
40+
fun `getBeanNamesForType with reified type parameters`() {
41+
lbf.getBeanNamesForType<Foo>()
42+
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, true , true)
43+
}
44+
45+
@Test
46+
fun `getBeanNamesForType with reified type parameters and Boolean`() {
47+
lbf.getBeanNamesForType<Foo>(false)
48+
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , true)
49+
}
50+
51+
@Test
52+
fun `getBeanNamesForType with reified type parameters, Boolean and Boolean`() {
53+
lbf.getBeanNamesForType<Foo>(false, false)
54+
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , false)
55+
}
56+
57+
@Test
58+
fun `getBeansOfType with KClass`() {
59+
lbf.getBeansOfType(Foo::class)
60+
verify(lbf, times(1)).getBeansOfType(Foo::class.java, true , true)
61+
}
62+
63+
@Test
64+
fun `getBeansOfType with KClass and Boolean`() {
65+
lbf.getBeansOfType(Foo::class, false)
66+
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , true)
67+
}
68+
69+
@Test
70+
fun `getBeansOfType with KClass, Boolean and Boolean`() {
71+
lbf.getBeansOfType(Foo::class, false, false)
72+
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , false)
73+
}
74+
75+
@Test
76+
fun `getBeansOfType with reified type parameters`() {
77+
lbf.getBeansOfType<Foo>()
78+
verify(lbf, times(1)).getBeansOfType(Foo::class.java, true , true)
79+
}
80+
81+
@Test
82+
fun `getBeansOfType with reified type parameters and Boolean`() {
83+
lbf.getBeansOfType<Foo>(false)
84+
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , true)
85+
}
86+
87+
@Test
88+
fun `getBeansOfType with reified type parameters, Boolean and Boolean`() {
89+
lbf.getBeansOfType<Foo>(false, false)
90+
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , false)
91+
}
92+
93+
@Test
94+
fun `getBeanNamesForAnnotation with KClass`() {
95+
lbf.getBeanNamesForAnnotation(Bar::class)
96+
verify(lbf, times(1)).getBeanNamesForAnnotation(Bar::class.java)
97+
}
98+
99+
@Test
100+
fun `getBeanNamesForAnnotation with reified type parameters`() {
101+
lbf.getBeanNamesForAnnotation<Bar>()
102+
verify(lbf, times(1)).getBeanNamesForAnnotation(Bar::class.java)
103+
}
104+
105+
@Test
106+
fun `getBeansWithAnnotation with KClass`() {
107+
lbf.getBeansWithAnnotation(Bar::class)
108+
verify(lbf, times(1)).getBeansWithAnnotation(Bar::class.java)
109+
}
110+
111+
@Test
112+
fun `getBeansWithAnnotation with reified type parameters`() {
113+
lbf.getBeansWithAnnotation<Bar>()
114+
verify(lbf, times(1)).getBeansWithAnnotation(Bar::class.java)
115+
}
116+
117+
@Test
118+
fun `findAnnotationOnBean with String and KClass`() {
119+
val name = "bar"
120+
lbf.findAnnotationOnBean(name, Bar::class)
121+
verify(lbf, times(1)).findAnnotationOnBean(name, Bar::class.java)
122+
}
123+
124+
@Test
125+
fun `findAnnotationOnBean with String and reified type parameters`() {
126+
val name = "bar"
127+
lbf.findAnnotationOnBean<Bar>(name)
128+
verify(lbf, times(1)).findAnnotationOnBean(name, Bar::class.java)
129+
}
130+
131+
class Foo
132+
133+
annotation class Bar
134134
}

spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class KotlinAutowiredTests {
3838
bpp.setBeanFactory(bf)
3939
bf.addBeanPostProcessor(bpp)
4040
var bd = RootBeanDefinition(KotlinBean::class.java)
41-
bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE)
41+
bd.scope = RootBeanDefinition.SCOPE_PROTOTYPE
4242
bf.registerBeanDefinition("annotatedBean", bd)
4343
var tb = TestBean()
4444
bf.registerSingleton("testBean", tb)
@@ -56,7 +56,7 @@ class KotlinAutowiredTests {
5656
bpp.setBeanFactory(bf)
5757
bf.addBeanPostProcessor(bpp)
5858
var bd = RootBeanDefinition(KotlinBean::class.java)
59-
bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE)
59+
bd.scope = RootBeanDefinition.SCOPE_PROTOTYPE
6060
bf.registerBeanDefinition("annotatedBean", bd)
6161

6262
var kb = bf.getBean("annotatedBean", KotlinBean::class.java)

spring-context/src/test/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensionsTests.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import org.springframework.context.support.registerBean
1212
*/
1313
class AnnotationConfigApplicationContextExtensionsTests {
1414

15-
@Test
16-
fun `Instantiate AnnotationConfigApplicationContext`() {
17-
val applicationContext = AnnotationConfigApplicationContext {
18-
registerBean<Foo>()
19-
}
20-
applicationContext.refresh()
21-
assertNotNull(applicationContext)
22-
assertNotNull(applicationContext.getBean<Foo>())
23-
}
15+
@Test
16+
fun `Instantiate AnnotationConfigApplicationContext`() {
17+
val applicationContext = AnnotationConfigApplicationContext {
18+
registerBean<Foo>()
19+
}
20+
applicationContext.refresh()
21+
assertNotNull(applicationContext)
22+
assertNotNull(applicationContext.getBean<Foo>())
23+
}
2424

25-
class Foo
25+
class Foo
2626
}

0 commit comments

Comments
 (0)