DATACMNS-1645 - Add search prefix for part tree queries.

We're adding search as prefix for derived repository query methods to improve readability when a Spring Data module is integrated with a search engine. Now it's possible to create a `search…By…` query like `searchByFirstname`.
This commit is contained in:
Mark Paluch
2020-01-13 15:34:24 +01:00
parent 4adef63610
commit b69141ac17
2 changed files with 12 additions and 2 deletions

View File

@@ -50,7 +50,8 @@ import org.springframework.data.repository.query.parser.PartTree.OrPart;
*/
public class PartTreeUnitTests {
private String[] PREFIXES = { "find", "read", "get", "query", "stream", "count", "delete", "remove", "exists" };
private String[] PREFIXES = { "find", "read", "get", "query", "search", "stream", "count", "delete", "remove",
"exists" };
@Test
public void rejectsNullSource() {
@@ -400,6 +401,15 @@ public class PartTreeUnitTests {
assertThat(parts).containsExactly(part("firstname"), part("lastname"));
}
@Test // DATACMNS-1645
public void searchPrefixShouldBeSupportedInRepositoryQueryMethods() {
PartTree tree = new PartTree("searchByFirstnameAndLastname", User.class);
Iterable<Part> parts = tree.getParts();
assertThat(parts).containsExactly(part("firstname"), part("lastname"));
}
@Test // DATACMNS-303
public void identifiesExtendedCountByCorrectly() {