Skip to content

Commit 2556bf7

Browse files
Thomas Darimontodrotbohm
authored andcommitted
DATACMNS-368 - Add test for PartTree properties that contain keyword sequences.
Added appropriate test to PartTreeUnitTests to check whether the regular expression in PartTree doesn't accidentally finds keywords in property expressions.
1 parent 7978cd2 commit 2556bf7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
*
4141
* @author Oliver Gierke
4242
* @author Phillip Webb
43+
* @author Thomas Darimont
4344
*/
4445
public class PartTreeUnitTests {
4546

@@ -357,6 +358,22 @@ public void resolvesPropertyPathFromGettersOnInterfaces() {
357358
assertThat(new PartTree("findByCategoryId", Product.class), is(notNullValue()));
358359
}
359360

361+
/**
362+
* @see DATACMNS-368
363+
*/
364+
@Test
365+
public void detectPropertyWithOrKeywordPart() {
366+
assertThat(new PartTree("findByOrder", Product.class), is(notNullValue()));
367+
}
368+
369+
/**
370+
* @see DATACMNS-368
371+
*/
372+
@Test
373+
public void detectPropertyWithAndKeywordPart() {
374+
assertThat(new PartTree("findByAnders", Product.class), is(notNullValue()));
375+
}
376+
360377
private static void assertType(Iterable<String> sources, Type type, String property) {
361378
assertType(sources, type, property, 1, true);
362379
}
@@ -434,15 +451,33 @@ class Organization {
434451
class DomainObjectWithSpecialChars {
435452
String øre;
436453
String år;
454+
455+
public Order getOrder() {
456+
return null;
457+
}
437458
}
438459

439460
interface Product {
440461

462+
Order getOrder(); // contains Or keyword
463+
464+
Anders getAnders(); // constains And keyword
465+
441466
Category getCategory();
442467
}
443468

444469
interface Category {
445470

446471
Long getId();
447472
}
473+
474+
interface Order {
475+
476+
Long getId();
477+
}
478+
479+
interface Anders {
480+
481+
Long getId();
482+
}
448483
}

0 commit comments

Comments
 (0)