@@ -19,13 +19,13 @@ public void TestReadingFields() {
19
19
List <String > results = Reflecting .getPathsOf (Test1Class .class , MyType .class , ContainsMyType .class );
20
20
assertThat (results ).containsAll (List .of ("myType" , "usedClass.myType" ));
21
21
}
22
-
22
+
23
23
@ Test
24
24
public void TestReadingFieldsContainsFieldsInArrays () {
25
25
List <String > results = Reflecting .getPathsOf (Test1Class .class , MyType .class , ContainsMyType .class );
26
26
assertThat (results ).containsAll (List .of ("myTypeArray" , "usedClassArray.myType" ));
27
27
}
28
-
28
+
29
29
@ Test
30
30
public void TestReadingFieldsContainsFieldsInGenericLists () {
31
31
List <String > results = Reflecting .getPathsOf (Test1Class .class , MyType .class , ContainsMyType .class );
@@ -52,7 +52,7 @@ public void TestWritingOfFieldInArray() throws IllegalArgumentException, Illegal
52
52
assertThat (tc .getMyTypeArray ()[1 ].getName ()).isNull ();
53
53
assertThat (tc .getMyTypeArray ()[3 ].getName ()).isEqualTo ("gluppy" );
54
54
}
55
-
55
+
56
56
@ Test
57
57
public void TestWritingOfFieldInList () throws IllegalArgumentException , IllegalAccessException {
58
58
Test1Class tc = new Test1Class ();
@@ -64,7 +64,7 @@ public void TestWritingOfFieldInList() throws IllegalArgumentException, IllegalA
64
64
assertThat (tc .getMyTypeList ().get (1 ).getName ()).isNull ();
65
65
assertThat (tc .getMyTypeList ().get (3 ).getName ()).isEqualTo ("gluppy" );
66
66
}
67
-
67
+
68
68
@ Test
69
69
public void TestWritingOfFieldInUsedClassInArray () throws IllegalArgumentException , IllegalAccessException {
70
70
Test1Class tc = new Test1Class ();
@@ -76,7 +76,7 @@ public void TestWritingOfFieldInUsedClassInArray() throws IllegalArgumentExcepti
76
76
assertThat (tc .getUsedClassArray ()[1 ].getMyType ().getName ()).isNull ();
77
77
assertThat (tc .getUsedClassArray ()[2 ].getMyType ().getName ()).isEqualTo ("gluppy" );
78
78
}
79
-
79
+
80
80
@ Test
81
81
public void TestWritingOfFieldInUsedClassInList () throws IllegalArgumentException , IllegalAccessException {
82
82
Test1Class tc = new Test1Class ();
@@ -88,7 +88,40 @@ public void TestWritingOfFieldInUsedClassInList() throws IllegalArgumentExceptio
88
88
assertThat (tc .getUsedClassList ().get (1 ).getMyType ().getName ()).isNull ();
89
89
assertThat (tc .getUsedClassList ().get (2 ).getMyType ().getName ()).isEqualTo ("gluppy" );
90
90
}
91
-
91
+
92
+ @ Test
93
+ public void TestIndexOfListEmptyReturnsFirstEntry () throws IllegalArgumentException , IllegalAccessException {
94
+ Test1Class tc = new Test1Class ();
95
+ MyType mt = Reflecting .getFieldByPath ("usedClassList.myType" , tc , ContainsMyType .class );
96
+ mt .setName ("blubb" );
97
+ assertThat (tc .getUsedClassList ().get (0 ).getMyType ().getName ()).isEqualTo ("blubb" );
98
+ }
99
+
100
+ @ Test
101
+ public void TestIndexOfListOverflowJustStartsFromBeginning ()
102
+ throws IllegalArgumentException , IllegalAccessException {
103
+ Test1Class tc = new Test1Class ();
104
+ MyType mt = Reflecting .getFieldByPath ("usedClassList:3.myType" , tc , ContainsMyType .class );
105
+ mt .setName ("blubb" );
106
+ assertThat (tc .getUsedClassList ().get (0 ).getMyType ().getName ()).isEqualTo ("blubb" );
107
+ }
108
+
109
+ @ Test
110
+ public void TestIndexOfListUnderflowJustStartsFromTheEnd () throws IllegalArgumentException , IllegalAccessException {
111
+ Test1Class tc = new Test1Class ();
112
+ MyType mt = Reflecting .getFieldByPath ("usedClassList:-1.myType" , tc , ContainsMyType .class );
113
+ mt .setName ("blubb" );
114
+ assertThat (tc .getUsedClassList ().get (2 ).getMyType ().getName ()).isEqualTo ("blubb" );
115
+ }
116
+
117
+ @ Test
118
+ public void TestIndexOfListNegativeOverflowWrapsAsWell () throws IllegalArgumentException , IllegalAccessException {
119
+ Test1Class tc = new Test1Class ();
120
+ MyType mt = Reflecting .getFieldByPath ("usedClassList:-4.myType" , tc , ContainsMyType .class );
121
+ mt .setName ("blubb" );
122
+ assertThat (tc .getUsedClassList ().get (2 ).getMyType ().getName ()).isEqualTo ("blubb" );
123
+ }
124
+
92
125
@ Test
93
126
public void TestWritingOfFieldInUsedClass () throws IllegalArgumentException , IllegalAccessException {
94
127
Test1Class tc = new Test1Class ();
0 commit comments