36
36
* @author Mark Paluch
37
37
*/
38
38
@ SuppressWarnings ("unused" )
39
- public class PropertyPathUnitTests {
39
+ class PropertyPathUnitTests {
40
40
41
41
@ Test
42
- public void parsesSimplePropertyCorrectly () throws Exception {
42
+ void parsesSimplePropertyCorrectly () {
43
43
44
44
PropertyPath reference = PropertyPath .from ("userName" , Foo .class );
45
45
@@ -49,7 +49,7 @@ public void parsesSimplePropertyCorrectly() throws Exception {
49
49
}
50
50
51
51
@ Test
52
- public void parsesPathPropertyCorrectly () throws Exception {
52
+ void parsesPathPropertyCorrectly () {
53
53
54
54
PropertyPath reference = PropertyPath .from ("userName" , Bar .class );
55
55
assertThat (reference .hasNext ()).isTrue ();
@@ -58,15 +58,15 @@ public void parsesPathPropertyCorrectly() throws Exception {
58
58
}
59
59
60
60
@ Test
61
- public void prefersLongerMatches () throws Exception {
61
+ void prefersLongerMatches () {
62
62
63
63
PropertyPath reference = PropertyPath .from ("userName" , Sample .class );
64
64
assertThat (reference .hasNext ()).isFalse ();
65
65
assertThat (reference .toDotPath ()).isEqualTo ("userName" );
66
66
}
67
67
68
68
@ Test
69
- public void testname () throws Exception {
69
+ void testname () {
70
70
71
71
PropertyPath reference = PropertyPath .from ("userName" , Sample2 .class );
72
72
assertThat (reference .getSegment ()).isEqualTo ("user" );
@@ -75,7 +75,7 @@ public void testname() throws Exception {
75
75
}
76
76
77
77
@ Test
78
- public void prefersExplicitPaths () throws Exception {
78
+ void prefersExplicitPaths () {
79
79
80
80
PropertyPath reference = PropertyPath .from ("user_name" , Sample .class );
81
81
assertThat (reference .getSegment ()).isEqualTo ("user" );
@@ -84,7 +84,7 @@ public void prefersExplicitPaths() throws Exception {
84
84
}
85
85
86
86
@ Test
87
- public void handlesGenericsCorrectly () throws Exception {
87
+ void handlesGenericsCorrectly () {
88
88
89
89
PropertyPath reference = PropertyPath .from ("usersName" , Bar .class );
90
90
assertThat (reference .getSegment ()).isEqualTo ("users" );
@@ -94,7 +94,7 @@ public void handlesGenericsCorrectly() throws Exception {
94
94
}
95
95
96
96
@ Test
97
- public void handlesMapCorrectly () throws Exception {
97
+ void handlesMapCorrectly () {
98
98
99
99
PropertyPath reference = PropertyPath .from ("userMapName" , Bar .class );
100
100
assertThat (reference .getSegment ()).isEqualTo ("userMap" );
@@ -104,7 +104,7 @@ public void handlesMapCorrectly() throws Exception {
104
104
}
105
105
106
106
@ Test
107
- public void handlesArrayCorrectly () throws Exception {
107
+ void handlesArrayCorrectly () {
108
108
109
109
PropertyPath reference = PropertyPath .from ("userArrayName" , Bar .class );
110
110
assertThat (reference .getSegment ()).isEqualTo ("userArray" );
@@ -114,7 +114,7 @@ public void handlesArrayCorrectly() throws Exception {
114
114
}
115
115
116
116
@ Test
117
- public void handlesInvalidCollectionCompountTypeProperl () {
117
+ void handlesInvalidCollectionCompountTypeProperl () {
118
118
119
119
try {
120
120
PropertyPath .from ("usersMame" , Bar .class );
@@ -126,7 +126,7 @@ public void handlesInvalidCollectionCompountTypeProperl() {
126
126
}
127
127
128
128
@ Test
129
- public void handlesInvalidMapValueTypeProperly () {
129
+ void handlesInvalidMapValueTypeProperly () {
130
130
131
131
assertThatExceptionOfType (PropertyReferenceException .class )//
132
132
.isThrownBy (() -> PropertyPath .from ("userMapMame" , Bar .class ))//
@@ -135,7 +135,7 @@ public void handlesInvalidMapValueTypeProperly() {
135
135
}
136
136
137
137
@ Test
138
- public void findsNested () {
138
+ void findsNested () {
139
139
140
140
PropertyPath from = PropertyPath .from ("barUserName" , Sample .class );
141
141
@@ -144,7 +144,7 @@ public void findsNested() {
144
144
}
145
145
146
146
@ Test // DATACMNS-45
147
- public void handlesEmptyUnderscoresCorrectly () {
147
+ void handlesEmptyUnderscoresCorrectly () {
148
148
149
149
PropertyPath propertyPath = PropertyPath .from ("_foo" , Sample2 .class );
150
150
assertThat (propertyPath .getSegment ()).isEqualTo ("_foo" );
@@ -155,7 +155,7 @@ public void handlesEmptyUnderscoresCorrectly() {
155
155
}
156
156
157
157
@ Test
158
- public void supportsDotNotationAsWell () {
158
+ void supportsDotNotationAsWell () {
159
159
160
160
PropertyPath propertyPath = PropertyPath .from ("bar.userMap.name" , Sample .class );
161
161
@@ -165,7 +165,7 @@ public void supportsDotNotationAsWell() {
165
165
}
166
166
167
167
@ Test
168
- public void returnsCorrectIteratorForSingleElement () {
168
+ void returnsCorrectIteratorForSingleElement () {
169
169
170
170
PropertyPath propertyPath = PropertyPath .from ("userName" , Foo .class );
171
171
@@ -176,7 +176,7 @@ public void returnsCorrectIteratorForSingleElement() {
176
176
}
177
177
178
178
@ Test
179
- public void returnsCorrectIteratorForMultipleElement () {
179
+ void returnsCorrectIteratorForMultipleElement () {
180
180
181
181
PropertyPath propertyPath = PropertyPath .from ("user.name" , Bar .class );
182
182
@@ -189,59 +189,59 @@ public void returnsCorrectIteratorForMultipleElement() {
189
189
}
190
190
191
191
@ Test // DATACMNS-139
192
- public void rejectsInvalidPropertyWithLeadingUnderscore () {
192
+ void rejectsInvalidPropertyWithLeadingUnderscore () {
193
193
194
194
assertThatExceptionOfType (PropertyReferenceException .class )//
195
195
.isThrownBy (() -> PropertyPath .from ("_id" , Foo .class ))//
196
196
.withMessageContaining ("property _id" );
197
197
}
198
198
199
199
@ Test // DATACMNS-139
200
- public void rejectsNestedInvalidPropertyWithLeadingUnderscore () {
200
+ void rejectsNestedInvalidPropertyWithLeadingUnderscore () {
201
201
202
202
assertThatExceptionOfType (PropertyReferenceException .class )//
203
203
.isThrownBy (() -> PropertyPath .from ("_foo_id" , Sample2 .class ))//
204
204
.withMessageContaining ("property id" );
205
205
}
206
206
207
207
@ Test // DATACMNS-139
208
- public void rejectsNestedInvalidPropertyExplictlySplitWithLeadingUnderscore () {
208
+ void rejectsNestedInvalidPropertyExplictlySplitWithLeadingUnderscore () {
209
209
210
210
assertThatExceptionOfType (PropertyReferenceException .class )//
211
211
.isThrownBy (() -> PropertyPath .from ("_foo__id" , Sample2 .class ))//
212
212
.withMessageContaining ("property _id" );
213
213
}
214
214
215
215
@ Test // DATACMNS 158
216
- public void rejectsInvalidPathsContainingDigits () {
216
+ void rejectsInvalidPathsContainingDigits () {
217
217
assertThatExceptionOfType (PropertyReferenceException .class )
218
218
.isThrownBy (() -> from ("PropertyThatWillFail4Sure" , Foo .class ));
219
219
}
220
220
221
221
@ Test // GH-2472
222
- public void acceptsValidPathWithDigits () {
222
+ void acceptsValidPathWithDigits () {
223
223
assertThat (from ("bar1" , Sample .class )).isNotNull ();
224
224
assertThat (from ("bar1foo" , Sample .class )).isNotNull ();
225
225
}
226
226
227
227
@ Test // GH-2472
228
- public void acceptsValidNestedPathWithDigits () {
228
+ void acceptsValidNestedPathWithDigits () {
229
229
assertThat (from ("sample.bar1" , SampleHolder .class )).isNotNull ();
230
230
assertThat (from ("sample.bar1foo" , SampleHolder .class )).isNotNull ();
231
231
assertThat (from ("sampleBar1" , SampleHolder .class )).isNotNull ();
232
232
assertThat (from ("sampleBar1foo" , SampleHolder .class )).isNotNull ();
233
233
}
234
234
235
235
@ Test
236
- public void rejectsInvalidProperty () {
236
+ void rejectsInvalidProperty () {
237
237
238
238
assertThatExceptionOfType (PropertyReferenceException .class )//
239
239
.isThrownBy (() -> from ("_foo_id" , Sample2 .class ))//
240
240
.matches (e -> e .getBaseProperty ().getSegment ().equals ("_foo" ));
241
241
}
242
242
243
243
@ Test
244
- public void samePathsEqual () {
244
+ void samePathsEqual () {
245
245
246
246
PropertyPath left = PropertyPath .from ("user.name" , Bar .class );
247
247
PropertyPath right = PropertyPath .from ("user.name" , Bar .class );
@@ -257,7 +257,7 @@ public void samePathsEqual() {
257
257
}
258
258
259
259
@ Test
260
- public void hashCodeTests () {
260
+ void hashCodeTests () {
261
261
262
262
PropertyPath left = PropertyPath .from ("user.name" , Bar .class );
263
263
PropertyPath right = PropertyPath .from ("user.name" , Bar .class );
@@ -269,7 +269,7 @@ public void hashCodeTests() {
269
269
}
270
270
271
271
@ Test // DATACMNS-257
272
- public void findsAllUppercaseProperty () {
272
+ void findsAllUppercaseProperty () {
273
273
274
274
PropertyPath path = PropertyPath .from ("UUID" , Foo .class );
275
275
@@ -278,7 +278,7 @@ public void findsAllUppercaseProperty() {
278
278
}
279
279
280
280
@ Test // DATACMNS-257
281
- public void findsNestedAllUppercaseProperty () {
281
+ void findsNestedAllUppercaseProperty () {
282
282
283
283
PropertyPath path = PropertyPath .from ("_fooUUID" , Sample2 .class );
284
284
@@ -289,7 +289,7 @@ public void findsNestedAllUppercaseProperty() {
289
289
}
290
290
291
291
@ Test // DATACMNS-381
292
- public void exposesPreviouslyReferencedPathInExceptionMessage () {
292
+ void exposesPreviouslyReferencedPathInExceptionMessage () {
293
293
294
294
assertThatExceptionOfType (PropertyReferenceException .class ).isThrownBy (() -> from ("userNameBar" , Bar .class )) //
295
295
.withMessageContaining ("bar" ) // missing variable
@@ -298,34 +298,34 @@ public void exposesPreviouslyReferencedPathInExceptionMessage() {
298
298
}
299
299
300
300
@ Test // DATACMNS-387
301
- public void rejectsNullSource () {
301
+ void rejectsNullSource () {
302
302
assertThatIllegalArgumentException ().isThrownBy (() -> from (null , Foo .class ));
303
303
}
304
304
305
305
@ Test // DATACMNS-387
306
- public void rejectsEmptySource () {
306
+ void rejectsEmptySource () {
307
307
assertThatIllegalArgumentException ().isThrownBy (() -> from ("" , Foo .class ));
308
308
}
309
309
310
310
@ Test // DATACMNS-387
311
- public void rejectsNullClass () {
311
+ void rejectsNullClass () {
312
312
assertThatIllegalArgumentException ().isThrownBy (() -> from ("foo" , (Class <?>) null ));
313
313
}
314
314
315
315
@ Test // DATACMNS-387
316
- public void rejectsNullTypeInformation () {
316
+ void rejectsNullTypeInformation () {
317
317
assertThatIllegalArgumentException ().isThrownBy (() -> from ("foo" , (TypeInformation <?>) null ));
318
318
}
319
319
320
320
@ Test // DATACMNS-546
321
- public void returnsCompletePathIfResolutionFailedCompletely () {
321
+ void returnsCompletePathIfResolutionFailedCompletely () {
322
322
323
323
assertThatExceptionOfType (PropertyReferenceException .class ) //
324
324
.isThrownBy (() -> from ("somethingDifferent" , Foo .class )).withMessageContaining ("somethingDifferent" );
325
325
}
326
326
327
327
@ Test // DATACMNS-546
328
- public void includesResolvedPathInExceptionMessage () {
328
+ void includesResolvedPathInExceptionMessage () {
329
329
330
330
assertThatExceptionOfType (PropertyReferenceException .class ) //
331
331
.isThrownBy (() -> from ("userFooName" , Bar .class )) //
@@ -335,14 +335,14 @@ public void includesResolvedPathInExceptionMessage() {
335
335
}
336
336
337
337
@ Test // DATACMNS-703
338
- public void includesPropertyHintsOnTypos () {
338
+ void includesPropertyHintsOnTypos () {
339
339
340
340
assertThatExceptionOfType (PropertyReferenceException .class ) //
341
341
.isThrownBy (() -> from ("userAme" , Foo .class )).withMessageContaining ("userName" );
342
342
}
343
343
344
344
@ Test // DATACMNS-867
345
- public void preservesUnderscoresForQuotedNames () {
345
+ void preservesUnderscoresForQuotedNames () {
346
346
347
347
PropertyPath path = from (Pattern .quote ("var_name_with_underscore" ), Foo .class );
348
348
@@ -352,22 +352,22 @@ public void preservesUnderscoresForQuotedNames() {
352
352
}
353
353
354
354
@ Test // DATACMNS-1120
355
- public void cachesPropertyPathsByPathAndType () {
355
+ void cachesPropertyPathsByPathAndType () {
356
356
assertThat (from ("userName" , Foo .class )).isSameAs (from ("userName" , Foo .class ));
357
357
}
358
358
359
359
@ Test // DATACMNS-1198
360
- public void exposesLeafPropertyType () {
360
+ void exposesLeafPropertyType () {
361
361
assertThat (from ("user.name" , Bar .class ).getLeafType ()).isEqualTo (String .class );
362
362
}
363
363
364
364
@ Test // DATACMNS-1199
365
- public void createsNestedPropertyPath () {
365
+ void createsNestedPropertyPath () {
366
366
assertThat (from ("user" , Bar .class ).nested ("name" )).isEqualTo (from ("user.name" , Bar .class ));
367
367
}
368
368
369
369
@ Test // DATACMNS-1199
370
- public void rejectsNonExistentNestedPath () {
370
+ void rejectsNonExistentNestedPath () {
371
371
372
372
assertThatExceptionOfType (PropertyReferenceException .class ) //
373
373
.isThrownBy (() -> from ("user" , Bar .class ).nested ("nonexistant" )) //
@@ -376,7 +376,7 @@ public void rejectsNonExistentNestedPath() {
376
376
}
377
377
378
378
@ Test // DATACMNS-1285
379
- public void rejectsTooLongPath () {
379
+ void rejectsTooLongPath () {
380
380
381
381
String source = "foo.bar" ;
382
382
@@ -393,17 +393,17 @@ public void rejectsTooLongPath() {
393
393
}
394
394
395
395
@ Test // DATACMNS-1304
396
- public void resolvesPropertyPathWithSingleUppercaseLetterPropertyEnding () {
396
+ void resolvesPropertyPathWithSingleUppercaseLetterPropertyEnding () {
397
397
assertThat (from ("categoryB" , Product .class ).toDotPath ()).isEqualTo ("categoryB" );
398
398
}
399
399
400
400
@ Test // DATACMNS-1304
401
- public void resolvesPropertyPathWithUppercaseLettersPropertyEnding () {
401
+ void resolvesPropertyPathWithUppercaseLettersPropertyEnding () {
402
402
assertThat (from ("categoryABId" , Product .class ).toDotPath ()).isEqualTo ("categoryAB.id" );
403
403
}
404
404
405
405
@ Test // DATACMNS-1304
406
- public void detectsNestedSingleCharacterProperty () {
406
+ void detectsNestedSingleCharacterProperty () {
407
407
assertThat (from ("category_B" , Product .class ).toDotPath ()).isEqualTo ("category.b" );
408
408
}
409
409
0 commit comments