From 61373d85674b02eb87094687a1bfac4b4f9ac147 Mon Sep 17 00:00:00 2001 From: Thomas Darimont Date: Tue, 17 Sep 2013 09:46:05 +0200 Subject: [PATCH] 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. --- .../query/parser/PartTreeUnitTests.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java b/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java index 5cfc8a5d99..9d96e469a8 100644 --- a/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java +++ b/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java @@ -40,6 +40,7 @@ * * @author Oliver Gierke * @author Phillip Webb + * @author Thomas Darimont */ public class PartTreeUnitTests { @@ -357,6 +358,22 @@ public void resolvesPropertyPathFromGettersOnInterfaces() { assertThat(new PartTree("findByCategoryId", Product.class), is(notNullValue())); } + /** + * @see DATACMNS-368 + */ + @Test + public void detectPropertyWithOrKeywordPart() { + assertThat(new PartTree("findByOrder", Product.class), is(notNullValue())); + } + + /** + * @see DATACMNS-368 + */ + @Test + public void detectPropertyWithAndKeywordPart() { + assertThat(new PartTree("findByAnders", Product.class), is(notNullValue())); + } + private static void assertType(Iterable sources, Type type, String property) { assertType(sources, type, property, 1, true); } @@ -434,10 +451,18 @@ class Organization { class DomainObjectWithSpecialChars { String øre; String år; + + public Order getOrder() { + return null; + } } interface Product { + Order getOrder(); // contains Or keyword + + Anders getAnders(); // constains And keyword + Category getCategory(); } @@ -445,4 +470,14 @@ interface Category { Long getId(); } + + interface Order { + + Long getId(); + } + + interface Anders { + + Long getId(); + } }