View Javadoc
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   * The Class TestedClassWithFullMixedFieldDITest.
12   */
13  final class TestedClassWithFullMixedFieldDITest {
14  
15      /**
16       * The Class TestedClass.
17       */
18      static class TestedClass {
19  
20          /** The dependency. */
21          @Inject
22          Dependency dependency;
23  
24          /** The text. */
25          StringBuilder text;
26      }
27  
28      /**
29       * The Class Dependency.
30       */
31      static class Dependency {
32          /** The value. */
33          String value;
34      }
35  
36      /**
37       * The Class Dependency2.
38       */
39      static class Dependency2 {
40      }
41  
42      /**
43       * Verify that fields from JRE types are not initialized.
44       *
45       * @param tested
46       *            the tested
47       */
48      @Test
49      void verifyThatFieldsFromJRETypesAreNotInitialized(@Tested(fullyInitialized = true) TestedClass tested) {
50          assertNull(tested.text);
51          assertNull(tested.dependency.value);
52      }
53  
54      /**
55       * The Class TestedClass2.
56       */
57      static class TestedClass2 {
58  
59          /** The dependency 1. */
60          @Inject
61          Dependency dependency1;
62  
63          /** The dependency 2. */
64          Dependency2 dependency2;
65      }
66  
67      /**
68       * Verify that fields of user types are initialized even only some are annotated.
69       *
70       * @param tested
71       *            the tested
72       */
73      @Test
74      void verifyThatFieldsOfUserTypesAreInitializedEvenOnlySomeAreAnnotated(
75              @Tested(fullyInitialized = true) TestedClass2 tested) {
76          assertNotNull(tested.dependency1);
77          assertNotNull(tested.dependency2);
78      }
79  }