DATACMNS-399 - Support query prefix to designate repository query methods.

Extended PREFIX regex in PartTree to support the "query" prefix.

Original author: @jiming
Original pull request: #56.
This commit is contained in:
Thomas Darimont
2013-11-13 17:55:49 +01:00
committed by Oliver Gierke
parent ba89dc9bb4
commit eddb3323de
3 changed files with 16 additions and 3 deletions

View File

@@ -44,7 +44,7 @@ import org.springframework.data.repository.query.parser.PartTree.OrPart;
*/
public class PartTreeUnitTests {
private String[] PREFIXES = { "find", "read", "get" };
private String[] PREFIXES = { "find", "read", "get", "query" };
@Test(expected = IllegalArgumentException.class)
public void rejectsNullSource() throws Exception {
@@ -417,6 +417,19 @@ public class PartTreeUnitTests {
assertThat(tree.isCountProjection(), is(true));
}
/**
* @see DATACMNS-399
*/
@Test
public void queryPrefixShouldBeSupportedInRepositoryQueryMethods() {
PartTree tree = new PartTree("queryByFirstnameAndLastname", User.class);
Iterable<Part> parts = tree.getParts();
assertThat(parts, hasItem(part("firstname")));
assertThat(parts, hasItem(part("lastname")));
}
/**
* @see DATACMNS-303
*/