Skip to content

Commit 8d20bad

Browse files
committed
Polishing.
Reduce test element visibility, remove unused constant. See #2472
1 parent 23f4774 commit 8d20bad

File tree

2 files changed

+44
-45
lines changed

2 files changed

+44
-45
lines changed

Diff for: src/main/java/org/springframework/data/mapping/PropertyPath.java

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public class PropertyPath implements Streamable<PropertyPath> {
4747
private static final String PARSE_DEPTH_EXCEEDED = "Trying to parse a path with depth greater than 1000! This has been disabled for security reasons to prevent parsing overflows.";
4848

4949
private static final String DELIMITERS = "_\\.";
50-
private static final String ALL_UPPERCASE = "[A-Z0-9._$]+";
5150
private static final Pattern SPLITTER = Pattern.compile("(?:[%s]?([%s]*?[^%s]+))".replaceAll("%s", DELIMITERS));
5251
private static final Pattern SPLITTER_FOR_QUOTED = Pattern.compile("(?:[%s]?([%s]*?[^%s]+))".replaceAll("%s", "\\."));
5352
private static final Pattern NESTED_PROPERTY_PATTERN = Pattern.compile("\\p{Lu}[\\p{Ll}\\p{Nd}]*$");

Diff for: src/test/java/org/springframework/data/mapping/PropertyPathUnitTests.java

+44-44
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
* @author Mark Paluch
3737
*/
3838
@SuppressWarnings("unused")
39-
public class PropertyPathUnitTests {
39+
class PropertyPathUnitTests {
4040

4141
@Test
42-
public void parsesSimplePropertyCorrectly() throws Exception {
42+
void parsesSimplePropertyCorrectly() {
4343

4444
PropertyPath reference = PropertyPath.from("userName", Foo.class);
4545

@@ -49,7 +49,7 @@ public void parsesSimplePropertyCorrectly() throws Exception {
4949
}
5050

5151
@Test
52-
public void parsesPathPropertyCorrectly() throws Exception {
52+
void parsesPathPropertyCorrectly() {
5353

5454
PropertyPath reference = PropertyPath.from("userName", Bar.class);
5555
assertThat(reference.hasNext()).isTrue();
@@ -58,15 +58,15 @@ public void parsesPathPropertyCorrectly() throws Exception {
5858
}
5959

6060
@Test
61-
public void prefersLongerMatches() throws Exception {
61+
void prefersLongerMatches() {
6262

6363
PropertyPath reference = PropertyPath.from("userName", Sample.class);
6464
assertThat(reference.hasNext()).isFalse();
6565
assertThat(reference.toDotPath()).isEqualTo("userName");
6666
}
6767

6868
@Test
69-
public void testname() throws Exception {
69+
void testname() {
7070

7171
PropertyPath reference = PropertyPath.from("userName", Sample2.class);
7272
assertThat(reference.getSegment()).isEqualTo("user");
@@ -75,7 +75,7 @@ public void testname() throws Exception {
7575
}
7676

7777
@Test
78-
public void prefersExplicitPaths() throws Exception {
78+
void prefersExplicitPaths() {
7979

8080
PropertyPath reference = PropertyPath.from("user_name", Sample.class);
8181
assertThat(reference.getSegment()).isEqualTo("user");
@@ -84,7 +84,7 @@ public void prefersExplicitPaths() throws Exception {
8484
}
8585

8686
@Test
87-
public void handlesGenericsCorrectly() throws Exception {
87+
void handlesGenericsCorrectly() {
8888

8989
PropertyPath reference = PropertyPath.from("usersName", Bar.class);
9090
assertThat(reference.getSegment()).isEqualTo("users");
@@ -94,7 +94,7 @@ public void handlesGenericsCorrectly() throws Exception {
9494
}
9595

9696
@Test
97-
public void handlesMapCorrectly() throws Exception {
97+
void handlesMapCorrectly() {
9898

9999
PropertyPath reference = PropertyPath.from("userMapName", Bar.class);
100100
assertThat(reference.getSegment()).isEqualTo("userMap");
@@ -104,7 +104,7 @@ public void handlesMapCorrectly() throws Exception {
104104
}
105105

106106
@Test
107-
public void handlesArrayCorrectly() throws Exception {
107+
void handlesArrayCorrectly() {
108108

109109
PropertyPath reference = PropertyPath.from("userArrayName", Bar.class);
110110
assertThat(reference.getSegment()).isEqualTo("userArray");
@@ -114,7 +114,7 @@ public void handlesArrayCorrectly() throws Exception {
114114
}
115115

116116
@Test
117-
public void handlesInvalidCollectionCompountTypeProperl() {
117+
void handlesInvalidCollectionCompountTypeProperl() {
118118

119119
try {
120120
PropertyPath.from("usersMame", Bar.class);
@@ -126,7 +126,7 @@ public void handlesInvalidCollectionCompountTypeProperl() {
126126
}
127127

128128
@Test
129-
public void handlesInvalidMapValueTypeProperly() {
129+
void handlesInvalidMapValueTypeProperly() {
130130

131131
assertThatExceptionOfType(PropertyReferenceException.class)//
132132
.isThrownBy(() -> PropertyPath.from("userMapMame", Bar.class))//
@@ -135,7 +135,7 @@ public void handlesInvalidMapValueTypeProperly() {
135135
}
136136

137137
@Test
138-
public void findsNested() {
138+
void findsNested() {
139139

140140
PropertyPath from = PropertyPath.from("barUserName", Sample.class);
141141

@@ -144,7 +144,7 @@ public void findsNested() {
144144
}
145145

146146
@Test // DATACMNS-45
147-
public void handlesEmptyUnderscoresCorrectly() {
147+
void handlesEmptyUnderscoresCorrectly() {
148148

149149
PropertyPath propertyPath = PropertyPath.from("_foo", Sample2.class);
150150
assertThat(propertyPath.getSegment()).isEqualTo("_foo");
@@ -155,7 +155,7 @@ public void handlesEmptyUnderscoresCorrectly() {
155155
}
156156

157157
@Test
158-
public void supportsDotNotationAsWell() {
158+
void supportsDotNotationAsWell() {
159159

160160
PropertyPath propertyPath = PropertyPath.from("bar.userMap.name", Sample.class);
161161

@@ -165,7 +165,7 @@ public void supportsDotNotationAsWell() {
165165
}
166166

167167
@Test
168-
public void returnsCorrectIteratorForSingleElement() {
168+
void returnsCorrectIteratorForSingleElement() {
169169

170170
PropertyPath propertyPath = PropertyPath.from("userName", Foo.class);
171171

@@ -176,7 +176,7 @@ public void returnsCorrectIteratorForSingleElement() {
176176
}
177177

178178
@Test
179-
public void returnsCorrectIteratorForMultipleElement() {
179+
void returnsCorrectIteratorForMultipleElement() {
180180

181181
PropertyPath propertyPath = PropertyPath.from("user.name", Bar.class);
182182

@@ -189,59 +189,59 @@ public void returnsCorrectIteratorForMultipleElement() {
189189
}
190190

191191
@Test // DATACMNS-139
192-
public void rejectsInvalidPropertyWithLeadingUnderscore() {
192+
void rejectsInvalidPropertyWithLeadingUnderscore() {
193193

194194
assertThatExceptionOfType(PropertyReferenceException.class)//
195195
.isThrownBy(() -> PropertyPath.from("_id", Foo.class))//
196196
.withMessageContaining("property _id");
197197
}
198198

199199
@Test // DATACMNS-139
200-
public void rejectsNestedInvalidPropertyWithLeadingUnderscore() {
200+
void rejectsNestedInvalidPropertyWithLeadingUnderscore() {
201201

202202
assertThatExceptionOfType(PropertyReferenceException.class)//
203203
.isThrownBy(() -> PropertyPath.from("_foo_id", Sample2.class))//
204204
.withMessageContaining("property id");
205205
}
206206

207207
@Test // DATACMNS-139
208-
public void rejectsNestedInvalidPropertyExplictlySplitWithLeadingUnderscore() {
208+
void rejectsNestedInvalidPropertyExplictlySplitWithLeadingUnderscore() {
209209

210210
assertThatExceptionOfType(PropertyReferenceException.class)//
211211
.isThrownBy(() -> PropertyPath.from("_foo__id", Sample2.class))//
212212
.withMessageContaining("property _id");
213213
}
214214

215215
@Test // DATACMNS 158
216-
public void rejectsInvalidPathsContainingDigits() {
216+
void rejectsInvalidPathsContainingDigits() {
217217
assertThatExceptionOfType(PropertyReferenceException.class)
218218
.isThrownBy(() -> from("PropertyThatWillFail4Sure", Foo.class));
219219
}
220220

221221
@Test // GH-2472
222-
public void acceptsValidPathWithDigits() {
222+
void acceptsValidPathWithDigits() {
223223
assertThat(from("bar1", Sample.class)).isNotNull();
224224
assertThat(from("bar1foo", Sample.class)).isNotNull();
225225
}
226226

227227
@Test // GH-2472
228-
public void acceptsValidNestedPathWithDigits() {
228+
void acceptsValidNestedPathWithDigits() {
229229
assertThat(from("sample.bar1", SampleHolder.class)).isNotNull();
230230
assertThat(from("sample.bar1foo", SampleHolder.class)).isNotNull();
231231
assertThat(from("sampleBar1", SampleHolder.class)).isNotNull();
232232
assertThat(from("sampleBar1foo", SampleHolder.class)).isNotNull();
233233
}
234234

235235
@Test
236-
public void rejectsInvalidProperty() {
236+
void rejectsInvalidProperty() {
237237

238238
assertThatExceptionOfType(PropertyReferenceException.class)//
239239
.isThrownBy(() -> from("_foo_id", Sample2.class))//
240240
.matches(e -> e.getBaseProperty().getSegment().equals("_foo"));
241241
}
242242

243243
@Test
244-
public void samePathsEqual() {
244+
void samePathsEqual() {
245245

246246
PropertyPath left = PropertyPath.from("user.name", Bar.class);
247247
PropertyPath right = PropertyPath.from("user.name", Bar.class);
@@ -257,7 +257,7 @@ public void samePathsEqual() {
257257
}
258258

259259
@Test
260-
public void hashCodeTests() {
260+
void hashCodeTests() {
261261

262262
PropertyPath left = PropertyPath.from("user.name", Bar.class);
263263
PropertyPath right = PropertyPath.from("user.name", Bar.class);
@@ -269,7 +269,7 @@ public void hashCodeTests() {
269269
}
270270

271271
@Test // DATACMNS-257
272-
public void findsAllUppercaseProperty() {
272+
void findsAllUppercaseProperty() {
273273

274274
PropertyPath path = PropertyPath.from("UUID", Foo.class);
275275

@@ -278,7 +278,7 @@ public void findsAllUppercaseProperty() {
278278
}
279279

280280
@Test // DATACMNS-257
281-
public void findsNestedAllUppercaseProperty() {
281+
void findsNestedAllUppercaseProperty() {
282282

283283
PropertyPath path = PropertyPath.from("_fooUUID", Sample2.class);
284284

@@ -289,7 +289,7 @@ public void findsNestedAllUppercaseProperty() {
289289
}
290290

291291
@Test // DATACMNS-381
292-
public void exposesPreviouslyReferencedPathInExceptionMessage() {
292+
void exposesPreviouslyReferencedPathInExceptionMessage() {
293293

294294
assertThatExceptionOfType(PropertyReferenceException.class).isThrownBy(() -> from("userNameBar", Bar.class)) //
295295
.withMessageContaining("bar") // missing variable
@@ -298,34 +298,34 @@ public void exposesPreviouslyReferencedPathInExceptionMessage() {
298298
}
299299

300300
@Test // DATACMNS-387
301-
public void rejectsNullSource() {
301+
void rejectsNullSource() {
302302
assertThatIllegalArgumentException().isThrownBy(() -> from(null, Foo.class));
303303
}
304304

305305
@Test // DATACMNS-387
306-
public void rejectsEmptySource() {
306+
void rejectsEmptySource() {
307307
assertThatIllegalArgumentException().isThrownBy(() -> from("", Foo.class));
308308
}
309309

310310
@Test // DATACMNS-387
311-
public void rejectsNullClass() {
311+
void rejectsNullClass() {
312312
assertThatIllegalArgumentException().isThrownBy(() -> from("foo", (Class<?>) null));
313313
}
314314

315315
@Test // DATACMNS-387
316-
public void rejectsNullTypeInformation() {
316+
void rejectsNullTypeInformation() {
317317
assertThatIllegalArgumentException().isThrownBy(() -> from("foo", (TypeInformation<?>) null));
318318
}
319319

320320
@Test // DATACMNS-546
321-
public void returnsCompletePathIfResolutionFailedCompletely() {
321+
void returnsCompletePathIfResolutionFailedCompletely() {
322322

323323
assertThatExceptionOfType(PropertyReferenceException.class) //
324324
.isThrownBy(() -> from("somethingDifferent", Foo.class)).withMessageContaining("somethingDifferent");
325325
}
326326

327327
@Test // DATACMNS-546
328-
public void includesResolvedPathInExceptionMessage() {
328+
void includesResolvedPathInExceptionMessage() {
329329

330330
assertThatExceptionOfType(PropertyReferenceException.class) //
331331
.isThrownBy(() -> from("userFooName", Bar.class)) //
@@ -335,14 +335,14 @@ public void includesResolvedPathInExceptionMessage() {
335335
}
336336

337337
@Test // DATACMNS-703
338-
public void includesPropertyHintsOnTypos() {
338+
void includesPropertyHintsOnTypos() {
339339

340340
assertThatExceptionOfType(PropertyReferenceException.class) //
341341
.isThrownBy(() -> from("userAme", Foo.class)).withMessageContaining("userName");
342342
}
343343

344344
@Test // DATACMNS-867
345-
public void preservesUnderscoresForQuotedNames() {
345+
void preservesUnderscoresForQuotedNames() {
346346

347347
PropertyPath path = from(Pattern.quote("var_name_with_underscore"), Foo.class);
348348

@@ -352,22 +352,22 @@ public void preservesUnderscoresForQuotedNames() {
352352
}
353353

354354
@Test // DATACMNS-1120
355-
public void cachesPropertyPathsByPathAndType() {
355+
void cachesPropertyPathsByPathAndType() {
356356
assertThat(from("userName", Foo.class)).isSameAs(from("userName", Foo.class));
357357
}
358358

359359
@Test // DATACMNS-1198
360-
public void exposesLeafPropertyType() {
360+
void exposesLeafPropertyType() {
361361
assertThat(from("user.name", Bar.class).getLeafType()).isEqualTo(String.class);
362362
}
363363

364364
@Test // DATACMNS-1199
365-
public void createsNestedPropertyPath() {
365+
void createsNestedPropertyPath() {
366366
assertThat(from("user", Bar.class).nested("name")).isEqualTo(from("user.name", Bar.class));
367367
}
368368

369369
@Test // DATACMNS-1199
370-
public void rejectsNonExistentNestedPath() {
370+
void rejectsNonExistentNestedPath() {
371371

372372
assertThatExceptionOfType(PropertyReferenceException.class) //
373373
.isThrownBy(() -> from("user", Bar.class).nested("nonexistant")) //
@@ -376,7 +376,7 @@ public void rejectsNonExistentNestedPath() {
376376
}
377377

378378
@Test // DATACMNS-1285
379-
public void rejectsTooLongPath() {
379+
void rejectsTooLongPath() {
380380

381381
String source = "foo.bar";
382382

@@ -393,17 +393,17 @@ public void rejectsTooLongPath() {
393393
}
394394

395395
@Test // DATACMNS-1304
396-
public void resolvesPropertyPathWithSingleUppercaseLetterPropertyEnding() {
396+
void resolvesPropertyPathWithSingleUppercaseLetterPropertyEnding() {
397397
assertThat(from("categoryB", Product.class).toDotPath()).isEqualTo("categoryB");
398398
}
399399

400400
@Test // DATACMNS-1304
401-
public void resolvesPropertyPathWithUppercaseLettersPropertyEnding() {
401+
void resolvesPropertyPathWithUppercaseLettersPropertyEnding() {
402402
assertThat(from("categoryABId", Product.class).toDotPath()).isEqualTo("categoryAB.id");
403403
}
404404

405405
@Test // DATACMNS-1304
406-
public void detectsNestedSingleCharacterProperty() {
406+
void detectsNestedSingleCharacterProperty() {
407407
assertThat(from("category_B", Product.class).toDotPath()).isEqualTo("category.b");
408408
}
409409

0 commit comments

Comments
 (0)