1 package mockit;
2
3 import static org.junit.jupiter.api.Assertions.assertNotNull;
4 import static org.junit.jupiter.api.Assertions.assertNull;
5
6 import javax.inject.Inject;
7
8 import org.junit.jupiter.api.Test;
9
10
11
12
13 final class TestedClassWithFullMixedFieldDITest {
14
15
16
17
18 static class TestedClass {
19
20
21 @Inject
22 Dependency dependency;
23
24
25 StringBuilder text;
26 }
27
28
29
30
31 static class Dependency {
32
33 String value;
34 }
35
36
37
38
39 static class Dependency2 {
40 }
41
42
43
44
45
46
47
48 @Test
49 void verifyThatFieldsFromJRETypesAreNotInitialized(@Tested(fullyInitialized = true) TestedClass tested) {
50 assertNull(tested.text);
51 assertNull(tested.dependency.value);
52 }
53
54
55
56
57 static class TestedClass2 {
58
59
60 @Inject
61 Dependency dependency1;
62
63
64 Dependency2 dependency2;
65 }
66
67
68
69
70
71
72
73 @Test
74 void verifyThatFieldsOfUserTypesAreInitializedEvenOnlySomeAreAnnotated(
75 @Tested(fullyInitialized = true) TestedClass2 tested) {
76 assertNotNull(tested.dependency1);
77 assertNotNull(tested.dependency2);
78 }
79 }