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.
This commit is contained in:
Thomas Darimont
2013-09-17 09:46:05 +02:00
committed by Oliver Gierke
parent 7978cd24f2
commit 2556bf7a4a

View File

@@ -40,6 +40,7 @@ import org.springframework.data.repository.query.parser.PartTree.OrPart;
*
* @author Oliver Gierke
* @author Phillip Webb
* @author Thomas Darimont
*/
public class PartTreeUnitTests {
@@ -357,6 +358,22 @@ public class PartTreeUnitTests {
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<String> sources, Type type, String property) {
assertType(sources, type, property, 1, true);
}
@@ -434,10 +451,18 @@ public class PartTreeUnitTests {
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 @@ public class PartTreeUnitTests {
Long getId();
}
interface Order {
Long getId();
}
interface Anders {
Long getId();
}
}