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:
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user