Add PageRequest builder.

We now support PageRequest creation through PageRequest.ofSize(10).withPage(1).withSort(Direction.DESC, "foo"). Simplified Pageable instances can be created through Pageable.ofSize(10).withPage(1).

Closes #322.
This commit is contained in:
Anastasiia Smirnova
2018-11-02 18:25:19 +02:00
committed by Mark Paluch
parent d4b8e38622
commit 2db26d2765
2 changed files with 32 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.data.domain;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.domain.PageRequest.pageRequest;
import static org.springframework.data.domain.UnitTestUtils.*;
import org.junit.jupiter.api.Test;
@@ -45,7 +46,7 @@ class PageRequestUnitTests extends AbstractPageRequestUnitTests {
void equalsRegardsSortCorrectly() {
Sort sort = Sort.by(Direction.DESC, "foo");
AbstractPageRequest request = PageRequest.of(0, 10, sort);
AbstractPageRequest request = pageRequest().page(0).size(10).sort(sort).build();
// Equals itself
assertEqualsAndHashcode(request, request);