Added integration test for dynamic sorting.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user