Added integration test for dynamic sorting.

This commit is contained in:
Oliver Gierke
2011-03-01 20:44:02 +01:00
parent 05d681e0ef
commit 8e29899eff
2 changed files with 20 additions and 0 deletions

View File

@@ -785,6 +785,22 @@ public class UserRepositoryTests {
}
@Test
public void findsSortedByLastname() throws Exception {
flushTestUsers();
List<User> result =
repository.findByEmailAddressLike("%@%", new Sort(
Direction.ASC, "lastname"));
assertThat(result.size(), is(3));
assertThat(result.get(0), is(secondUser));
assertThat(result.get(1), is(firstUser));
assertThat(result.get(2), is(thirdUser));
}
private Page<User> executeSpecWithSort(Sort sort) {
flushTestUsers();

View File

@@ -22,6 +22,7 @@ import javax.persistence.QueryHint;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.sample.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
@@ -203,4 +204,7 @@ public interface UserRepository extends JpaRepository<User, Integer>,
List<User> findByLastnameNull();
List<User> findByEmailAddressLike(String email, Sort sort);
}