SGF-115 - Added support for Like, Contains, StartsWith and EndsWith keywords.

This commit is contained in:
Oliver Gierke
2012-08-06 17:49:37 +02:00
parent fdf9f84180
commit e9e9aafe10
4 changed files with 84 additions and 2 deletions

View File

@@ -44,4 +44,12 @@ public interface PersonRepository extends CrudRepository<Person, Long> {
Collection<Person> findByFirstnameOrLastname(String firstname, String lastname);
Person findByLastname(String lastname);
Collection<Person> findByFirstnameLike(String firstname);
Collection<Person> findByFirstnameStartingWith(String firstname);
Collection<Person> findByLastnameEndingWith(String lastname);
Collection<Person> findByFirstnameContaining(String firstname);
}

View File

@@ -153,6 +153,38 @@ public abstract class AbstractGemfireRepositoryFactoryIntegrationTests {
}
}
/**
* @see SGF-115
*/
@Test
public void executesStartsWithCorrectly() {
assertResultsFound(repository.findByFirstnameStartingWith("Da"), dave);
}
/**
* @see SGF-115
*/
@Test
public void executesEndsWithCorrectly() {
assertResultsFound(repository.findByLastnameEndingWith("ews"), dave, oliverAugust);
}
/**
* @see SGF-115
*/
@Test
public void executesContainsCorrectly() {
assertResultsFound(repository.findByFirstnameContaining("o"), boyd, leroi);
}
/**
* @see SGF-115
*/
@Test
public void executesLikeCorrectly() {
assertResultsFound(repository.findByFirstnameLike("Da%"), dave);
}
private <T> void assertResultsFound(Iterable<T> result, T... expected) {
assertThat(result, is(notNullValue()));