File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
main/kotlin/com/baeldung/theValueAnnotation
test/kotlin/com/baeldung/theValueAnnotation Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Value
4
4
import org.springframework.stereotype.Component
5
5
6
6
@Component
7
- class MyMagicBean (
7
+ class ValueBean (
8
8
// without default values
9
9
@Value(" \$ {my-app.magic-number}" )
10
10
val magicNumber : Int ,
Original file line number Diff line number Diff line change @@ -10,11 +10,11 @@ import kotlin.test.assertTrue
10
10
11
11
@SpringBootTest
12
12
@TestConstructor(autowireMode = AutowireMode .ALL )
13
- class TheValueAnnotationUnitTest (val myMagicBean : MyMagicBean ) {
13
+ class TheValueAnnotationUnitTest (val valueBean : ValueBean ) {
14
14
15
15
@Test
16
16
fun `when using value annotations, then expected values should be injected` () {
17
- with (myMagicBean ) {
17
+ with (valueBean ) {
18
18
assertEquals(42 , magicNumber)
19
19
assertEquals(" It's a magic string" , magicString)
20
20
assertTrue(magicFlag)
@@ -23,15 +23,15 @@ class TheValueAnnotationUnitTest(val myMagicBean: MyMagicBean) {
23
23
24
24
@Test
25
25
fun `when using value annotations with default values, then expected values should be injected` () {
26
- with (myMagicBean ) {
26
+ with (valueBean ) {
27
27
assertEquals(1024 , magicNumberWithDefault)
28
28
assertEquals(" It's another magic string" , magicStringWithDefault)
29
29
}
30
30
}
31
31
32
32
@Test
33
33
fun `when using value annotations with null as default values, then expected values should be injected` () {
34
- with (myMagicBean ) {
34
+ with (valueBean ) {
35
35
assertEquals(" null" , stringDefaultLiteralNull)
36
36
assertNull(stringDefaultNull)
37
37
}
You can’t perform that action at this time.
0 commit comments