Browse Source

DATACMNS-867 - Cleanups in Pageable API.

Dropped Pageable.NONE in favor of ….unpaged() for consistency with Sort.unsorted(). Extracted the implementation for the value backing it into an Unpaged enum instance. Introduced defaulted isPaged() / isUnpaged() to avoid having to compare instances.

JavaDoc in Sort and a couple of API polishes.
pull/194/head
Oliver Gierke 9 years ago
parent
commit
8372e34adf
  1. 8
      src/main/java/org/springframework/data/domain/Chunk.java
  2. 4
      src/main/java/org/springframework/data/domain/PageImpl.java
  3. 81
      src/main/java/org/springframework/data/domain/Pageable.java
  4. 65
      src/main/java/org/springframework/data/domain/Sort.java
  5. 107
      src/main/java/org/springframework/data/domain/Unpaged.java
  6. 4
      src/main/java/org/springframework/data/repository/query/ParametersParameterAccessor.java
  7. 4
      src/main/java/org/springframework/data/repository/support/PageableExecutionUtils.java
  8. 6
      src/test/java/org/springframework/data/domain/PageImplUnitTests.java
  9. 4
      src/test/java/org/springframework/data/repository/query/SimpleParameterAccessorUnitTests.java
  10. 7
      src/test/java/org/springframework/data/repository/support/CrudRepositoryInvokerUnitTests.java
  11. 4
      src/test/java/org/springframework/data/repository/support/PageableExecutionUtilsUnitTests.java
  12. 5
      src/test/java/org/springframework/data/repository/support/PaginginAndSortingRepositoryInvokerUnitTests.java
  13. 15
      src/test/java/org/springframework/data/repository/support/ReflectionRepositoryInvokerUnitTests.java

8
src/main/java/org/springframework/data/domain/Chunk.java

@ -58,7 +58,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable { @@ -58,7 +58,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
* @see org.springframework.data.domain.Slice#getNumber()
*/
public int getNumber() {
return pageable == Pageable.NONE ? 0 : pageable.getPageNumber();
return pageable.isPaged() ? pageable.getPageNumber() : 0;
}
/*
@ -66,7 +66,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable { @@ -66,7 +66,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
* @see org.springframework.data.domain.Slice#getSize()
*/
public int getSize() {
return pageable == Pageable.NONE ? 0 : pageable.getPageSize();
return pageable.isPaged() ? pageable.getPageSize() : 0;
}
/*
@ -106,7 +106,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable { @@ -106,7 +106,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
* @see org.springframework.data.domain.Slice#nextPageable()
*/
public Pageable nextPageable() {
return hasNext() ? pageable.next() : Pageable.NONE;
return hasNext() ? pageable.next() : Pageable.unpaged();
}
/*
@ -114,7 +114,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable { @@ -114,7 +114,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
* @see org.springframework.data.domain.Slice#previousPageable()
*/
public Pageable previousPageable() {
return hasPrevious() ? pageable.previousOrFirst() : Pageable.NONE;
return hasPrevious() ? pageable.previousOrFirst() : Pageable.unpaged();
}
/*

4
src/main/java/org/springframework/data/domain/PageImpl.java

@ -47,7 +47,7 @@ public class PageImpl<T> extends Chunk<T> implements Page<T> { @@ -47,7 +47,7 @@ public class PageImpl<T> extends Chunk<T> implements Page<T> {
this.pageable = pageable;
Optional<Pageable> foo = Pageable.NONE == pageable ? Optional.empty() : Optional.of(pageable);
Optional<Pageable> foo = pageable.isPaged() ? Optional.of(pageable) : Optional.empty();
this.total = foo.filter(it -> !content.isEmpty())//
.filter(it -> it.getOffset() + it.getPageSize() > total)//
@ -62,7 +62,7 @@ public class PageImpl<T> extends Chunk<T> implements Page<T> { @@ -62,7 +62,7 @@ public class PageImpl<T> extends Chunk<T> implements Page<T> {
* @param content must not be {@literal null}.
*/
public PageImpl(List<T> content) {
this(content, Pageable.NONE, null == content ? 0 : content.size());
this(content, Pageable.unpaged(), null == content ? 0 : content.size());
}
/*

81
src/main/java/org/springframework/data/domain/Pageable.java

@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
*/
package org.springframework.data.domain;
import org.springframework.util.Assert;
/**
* Abstract interface for pagination information.
*
@ -22,6 +24,33 @@ package org.springframework.data.domain; @@ -22,6 +24,33 @@ package org.springframework.data.domain;
*/
public interface Pageable {
/**
* Returns a {@link Pageable} instance representing no pagination setup.
*
* @return
*/
static Pageable unpaged() {
return Unpaged.INSTANCE;
}
/**
* Returns whether the current {@link Pageable} contains pagination information.
*
* @return
*/
default boolean isPaged() {
return true;
}
/**
* Returns whether the current {@link Pageable} does not contain pagination information.
*
* @return
*/
default boolean isUnpaged() {
return !isPaged();
}
/**
* Returns the page to be returned.
*
@ -50,7 +79,16 @@ public interface Pageable { @@ -50,7 +79,16 @@ public interface Pageable {
*/
Sort getSort();
/**
* Returns the current {@link Sort} or the given one if the current one is unsorted.
*
* @param sort must not be {@literal null}.
* @return
*/
default Sort getSortOr(Sort sort) {
Assert.notNull(sort, "Fallback Sort must not be null!");
return getSort().isSorted() ? getSort() : sort;
}
@ -82,47 +120,4 @@ public interface Pageable { @@ -82,47 +120,4 @@ public interface Pageable {
* @return
*/
boolean hasPrevious();
public static Pageable NONE = new Pageable() {
@Override
public Pageable previousOrFirst() {
return this;
}
@Override
public Pageable next() {
return this;
}
@Override
public boolean hasPrevious() {
return false;
}
@Override
public Sort getSort() {
return Sort.unsorted();
}
@Override
public int getPageSize() {
throw new UnsupportedOperationException();
}
@Override
public int getPageNumber() {
throw new UnsupportedOperationException();
}
@Override
public long getOffset() {
throw new UnsupportedOperationException();
}
@Override
public Pageable first() {
return this;
}
};
}

65
src/main/java/org/springframework/data/domain/Sort.java

@ -83,7 +83,7 @@ public class Sort implements Iterable<org.springframework.data.domain.Sort.Order @@ -83,7 +83,7 @@ public class Sort implements Iterable<org.springframework.data.domain.Sort.Order
/**
* Creates a new {@link Sort} instance.
*
* @param direction defaults to {@linke Sort#DEFAULT_DIRECTION} (for {@literal null} cases, too)
* @param direction defaults to {@link Sort#DEFAULT_DIRECTION} (for {@literal null} cases, too)
* @param properties must not be {@literal null}, empty or contain {@literal null} or empty strings.
*/
public Sort(Direction direction, String... properties) {
@ -109,38 +109,80 @@ public class Sort implements Iterable<org.springframework.data.domain.Sort.Order @@ -109,38 +109,80 @@ public class Sort implements Iterable<org.springframework.data.domain.Sort.Order
}
}
/**
* Creates a new {@link Sort} for the given properties.
*
* @param properties must not be {@literal null}.
* @return
*/
public static Sort by(String... properties) {
Assert.notNull(properties, "Properties must not be null!");
return properties.length == 0 ? Sort.unsorted() : new Sort(properties);
}
/**
* Creates a new {@link Sort} for the given {@link Order}s.
*
* @param orders must not be {@literal null}.
* @return
*/
public static Sort by(List<Order> orders) {
Assert.notNull(orders, "Orders must not be null!");
return orders.isEmpty() ? Sort.unsorted() : new Sort(orders);
}
/**
* Creates a new {@link Sort} for the given {@link Order}s.
*
* @param orders must not be {@literal null}.
* @return
*/
public static Sort by(Order... orders) {
Assert.notNull(orders, "Orders must not be null!");
return new Sort(orders);
}
/**
* Returns a {@link Sort} instances representing no sorting setup at all.
*
* @return
*/
public static Sort unsorted() {
return UNSORTED;
}
/**
* Returns a new {@link Sort} with the current setup but descending order direction.
*
* @return
*/
public Sort descending() {
return withDirection(Direction.DESC);
}
/**
* Returns a new {@link Sort} with the current setup but ascendin order direction.
*
* @return
*/
public Sort ascending() {
return withDirection(Direction.ASC);
}
private Sort withDirection(Direction direction) {
return new Sort(orders.stream().map(it -> new Order(direction, it.getProperty())).collect(Collectors.toList()));
}
public boolean isSorted() {
return !orders.isEmpty();
}
public boolean isUnorted() {
return !isSorted();
}
/**
* Returns a new {@link Sort} consisting of the {@link Order}s of the current {@link Sort} combined with the given
* ones.
@ -160,7 +202,7 @@ public class Sort implements Iterable<org.springframework.data.domain.Sort.Order @@ -160,7 +202,7 @@ public class Sort implements Iterable<org.springframework.data.domain.Sort.Order
these.add(order);
}
return new Sort(these);
return Sort.by(these);
}
/**
@ -229,6 +271,17 @@ public class Sort implements Iterable<org.springframework.data.domain.Sort.Order @@ -229,6 +271,17 @@ public class Sort implements Iterable<org.springframework.data.domain.Sort.Order
return orders.isEmpty() ? "UNSORTED" : StringUtils.collectionToCommaDelimitedString(orders);
}
/**
* Creates a new {@link Sort} with the current setup but the given order direction.
*
* @param direction
* @return
*/
private Sort withDirection(Direction direction) {
return Sort.by(orders.stream().map(it -> new Order(direction, it.getProperty())).collect(Collectors.toList()));
}
/**
* Enumeration for sort directions.
*

107
src/main/java/org/springframework/data/domain/Unpaged.java

@ -0,0 +1,107 @@ @@ -0,0 +1,107 @@
/*
* Copyright 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.domain;
/**
* {@link Pageable} implementation to represent the absence of pagination information.
*
* @author Oliver Gierke
*/
enum Unpaged implements Pageable {
INSTANCE;
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#isPaged()
*/
@Override
public boolean isPaged() {
return false;
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#previousOrFirst()
*/
@Override
public Pageable previousOrFirst() {
return this;
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#next()
*/
@Override
public Pageable next() {
return this;
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#hasPrevious()
*/
@Override
public boolean hasPrevious() {
return false;
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#getSort()
*/
@Override
public Sort getSort() {
return Sort.unsorted();
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#getPageSize()
*/
@Override
public int getPageSize() {
throw new UnsupportedOperationException();
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#getPageNumber()
*/
@Override
public int getPageNumber() {
throw new UnsupportedOperationException();
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#getOffset()
*/
@Override
public long getOffset() {
throw new UnsupportedOperationException();
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#first()
*/
@Override
public Pageable first() {
return this;
}
}

4
src/main/java/org/springframework/data/repository/query/ParametersParameterAccessor.java

@ -71,12 +71,12 @@ public class ParametersParameterAccessor implements ParameterAccessor { @@ -71,12 +71,12 @@ public class ParametersParameterAccessor implements ParameterAccessor {
public Pageable getPageable() {
if (!parameters.hasPageableParameter()) {
return Pageable.NONE;
return Pageable.unpaged();
}
Pageable pageable = (Pageable) values.get(parameters.getPageableIndex());
return pageable == null ? Pageable.NONE : pageable;
return pageable == null ? Pageable.unpaged() : pageable;
}
/*

4
src/main/java/org/springframework/data/repository/support/PageableExecutionUtils.java

@ -53,9 +53,9 @@ public class PageableExecutionUtils { @@ -53,9 +53,9 @@ public class PageableExecutionUtils {
Assert.notNull(pageable, "Pageable must not be null!");
Assert.notNull(totalSupplier, "TotalSupplier must not be null!");
if (pageable == Pageable.NONE || pageable.getOffset() == 0) {
if (pageable.isUnpaged() || pageable.getOffset() == 0) {
if (pageable == Pageable.NONE || pageable.getPageSize() > content.size()) {
if (pageable.isUnpaged() || pageable.getPageSize() > content.size()) {
return new PageImpl<>(content, pageable, content.size());
}

6
src/test/java/org/springframework/data/domain/PageImplUnitTests.java

@ -72,7 +72,7 @@ public class PageImplUnitTests { @@ -72,7 +72,7 @@ public class PageImplUnitTests {
assertThat(page.isFirst()).isTrue();
assertThat(page.hasPrevious()).isFalse();
assertThat(page.previousPageable()).isEqualTo(Pageable.NONE);
assertThat(page.previousPageable().isPaged()).isFalse();
assertThat(page.isLast()).isFalse();
assertThat(page.hasNext()).isTrue();
@ -90,7 +90,7 @@ public class PageImplUnitTests { @@ -90,7 +90,7 @@ public class PageImplUnitTests {
assertThat(page.isLast()).isTrue();
assertThat(page.hasNext()).isFalse();
assertThat(page.nextPageable()).isEqualTo(Pageable.NONE);
assertThat(page.nextPageable().isPaged()).isFalse();
}
@Test
@ -158,7 +158,7 @@ public class PageImplUnitTests { @@ -158,7 +158,7 @@ public class PageImplUnitTests {
@Test // DATACMNS-713
public void doesNotAdapttotalIfPageIsEmpty() {
assertThat(new PageImpl<>(Collections.<String>emptyList(), PageRequest.of(1, 10), 0).getTotalElements())
assertThat(new PageImpl<>(Collections.<String> emptyList(), PageRequest.of(1, 10), 0).getTotalElements())
.isEqualTo(0L);
}
}

4
src/test/java/org/springframework/data/repository/query/SimpleParameterAccessorUnitTests.java

@ -71,7 +71,7 @@ public class SimpleParameterAccessorUnitTests { @@ -71,7 +71,7 @@ public class SimpleParameterAccessorUnitTests {
ParameterAccessor accessor = new ParametersParameterAccessor(parameters, new Object[] { "test" });
assertThat(accessor.getPageable()).isEqualTo(Pageable.NONE);
assertThat(accessor.getPageable().isPaged()).isFalse();
assertThat(accessor.getSort().isSorted()).isFalse();
}
@ -82,7 +82,7 @@ public class SimpleParameterAccessorUnitTests { @@ -82,7 +82,7 @@ public class SimpleParameterAccessorUnitTests {
ParameterAccessor accessor = new ParametersParameterAccessor(sortParameters, new Object[] { "test", sort });
assertThat(accessor.getSort()).isEqualTo(sort);
assertThat(accessor.getPageable()).isEqualTo(Pageable.NONE);
assertThat(accessor.getPageable().isPaged()).isFalse();
}
@Test

7
src/test/java/org/springframework/data/repository/support/CrudRepositoryInvokerUnitTests.java

@ -39,6 +39,7 @@ import org.springframework.data.repository.PagingAndSortingRepository; @@ -39,6 +39,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.support.RepositoryInvocationTestUtils.VerifyingMethodInterceptor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.format.support.DefaultFormattingConversionService;
@ -95,7 +96,7 @@ public class CrudRepositoryInvokerUnitTests { @@ -95,7 +96,7 @@ public class CrudRepositoryInvokerUnitTests {
Method method = CrudRepository.class.getMethod("findAll");
getInvokerFor(orderRepository, expectInvocationOf(method)).invokeFindAll(Pageable.NONE);
getInvokerFor(orderRepository, expectInvocationOf(method)).invokeFindAll(Pageable.unpaged());
getInvokerFor(orderRepository, expectInvocationOf(method)).invokeFindAll(Sort.unsorted());
}
@ -108,7 +109,7 @@ public class CrudRepositoryInvokerUnitTests { @@ -108,7 +109,7 @@ public class CrudRepositoryInvokerUnitTests {
getInvokerFor(repository, expectInvocationOf(findAllWithSort)).invokeFindAll(Sort.unsorted());
getInvokerFor(repository, expectInvocationOf(findAllWithSort)).invokeFindAll(PageRequest.of(0, 10));
getInvokerFor(repository, expectInvocationOf(findAllWithSort)).invokeFindAll(Pageable.NONE);
getInvokerFor(repository, expectInvocationOf(findAllWithSort)).invokeFindAll(Pageable.unpaged());
}
@Test // DATACMNS-589
@ -118,7 +119,7 @@ public class CrudRepositoryInvokerUnitTests { @@ -118,7 +119,7 @@ public class CrudRepositoryInvokerUnitTests {
Method findAllWithPageable = CrudWithFindAllWithPageable.class.getMethod("findAll", Pageable.class);
getInvokerFor(repository, expectInvocationOf(findAllWithPageable)).invokeFindAll(Pageable.NONE);
getInvokerFor(repository, expectInvocationOf(findAllWithPageable)).invokeFindAll(Pageable.unpaged());
getInvokerFor(repository, expectInvocationOf(findAllWithPageable)).invokeFindAll(PageRequest.of(0, 10));
}

4
src/test/java/org/springframework/data/repository/support/PageableExecutionUtilsUnitTests.java

@ -55,7 +55,7 @@ public class PageableExecutionUtilsUnitTests { @@ -55,7 +55,7 @@ public class PageableExecutionUtilsUnitTests {
@Test // DATAMCNS-884
public void noPageableRequestDoesNotRequireTotal() {
Page<Integer> page = PageableExecutionUtils.getPage(Arrays.asList(1, 2, 3), Pageable.NONE, totalSupplierMock);
Page<Integer> page = PageableExecutionUtils.getPage(Arrays.asList(1, 2, 3), Pageable.unpaged(), totalSupplierMock);
assertThat(page).contains(1, 2, 3);
assertThat(page.getTotalElements()).isEqualTo(3L);
@ -107,7 +107,7 @@ public class PageableExecutionUtilsUnitTests { @@ -107,7 +107,7 @@ public class PageableExecutionUtilsUnitTests {
public void subsequentPageRequestWithoutResultRequiresRequireTotal() {
doReturn(7L).when(totalSupplierMock).getAsLong();
Page<Integer> page = PageableExecutionUtils.getPage(Collections.<Integer>emptyList(), PageRequest.of(5, 10),
Page<Integer> page = PageableExecutionUtils.getPage(Collections.<Integer> emptyList(), PageRequest.of(5, 10),
totalSupplierMock);
assertThat(page.getTotalElements()).isEqualTo(7L);

5
src/test/java/org/springframework/data/repository/support/PaginginAndSortingRepositoryInvokerUnitTests.java

@ -29,6 +29,7 @@ import org.springframework.data.domain.Sort; @@ -29,6 +29,7 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
import org.springframework.data.repository.support.RepositoryInvocationTestUtils.VerifyingMethodInterceptor;
import org.springframework.format.support.DefaultFormattingConversionService;
/**
@ -45,7 +46,7 @@ public class PaginginAndSortingRepositoryInvokerUnitTests { @@ -45,7 +46,7 @@ public class PaginginAndSortingRepositoryInvokerUnitTests {
Method method = PagingAndSortingRepository.class.getMethod("findAll", Pageable.class);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(PageRequest.of(0, 10));
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.NONE);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.unpaged());
}
@Test // DATACMNS-589
@ -65,7 +66,7 @@ public class PaginginAndSortingRepositoryInvokerUnitTests { @@ -65,7 +66,7 @@ public class PaginginAndSortingRepositoryInvokerUnitTests {
Method method = RepositoryWithRedeclaredFindAllWithPageable.class.getMethod("findAll", Pageable.class);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(PageRequest.of(0, 10));
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.NONE);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.unpaged());
}
@Test // DATACMNS-589

15
src/test/java/org/springframework/data/repository/support/ReflectionRepositoryInvokerUnitTests.java

@ -45,6 +45,7 @@ import org.springframework.data.repository.core.support.DefaultRepositoryMetadat @@ -45,6 +45,7 @@ import org.springframework.data.repository.core.support.DefaultRepositoryMetadat
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.Person;
import org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository;
import org.springframework.data.repository.support.RepositoryInvocationTestUtils.VerifyingMethodInterceptor;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@ -103,7 +104,7 @@ public class ReflectionRepositoryInvokerUnitTests { @@ -103,7 +104,7 @@ public class ReflectionRepositoryInvokerUnitTests {
Method method = ManualCrudRepository.class.getMethod("findAll");
ManualCrudRepository repository = mock(ManualCrudRepository.class);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.NONE);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.unpaged());
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(PageRequest.of(0, 10));
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Sort.unsorted());
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Sort.by("foo"));
@ -115,7 +116,7 @@ public class ReflectionRepositoryInvokerUnitTests { @@ -115,7 +116,7 @@ public class ReflectionRepositoryInvokerUnitTests {
Method method = RepoWithFindAllWithSort.class.getMethod("findAll", Sort.class);
RepoWithFindAllWithSort repository = mock(RepoWithFindAllWithSort.class);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.NONE);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.unpaged());
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(PageRequest.of(0, 10));
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Sort.unsorted());
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Sort.by("foo"));
@ -127,7 +128,7 @@ public class ReflectionRepositoryInvokerUnitTests { @@ -127,7 +128,7 @@ public class ReflectionRepositoryInvokerUnitTests {
Method method = RepoWithFindAllWithPageable.class.getMethod("findAll", Pageable.class);
RepoWithFindAllWithPageable repository = mock(RepoWithFindAllWithPageable.class);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.NONE);
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(Pageable.unpaged());
getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(PageRequest.of(0, 10));
}
@ -140,7 +141,7 @@ public class ReflectionRepositoryInvokerUnitTests { @@ -140,7 +141,7 @@ public class ReflectionRepositoryInvokerUnitTests {
Method method = PersonRepository.class.getMethod("findByFirstName", String.class, Pageable.class);
PersonRepository repository = mock(PersonRepository.class);
getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.NONE,
getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.unpaged(),
Sort.unsorted());
}
@ -153,7 +154,7 @@ public class ReflectionRepositoryInvokerUnitTests { @@ -153,7 +154,7 @@ public class ReflectionRepositoryInvokerUnitTests {
Method method = PersonRepository.class.getMethod("findByCreatedUsingISO8601Date", Date.class, Pageable.class);
PersonRepository repository = mock(PersonRepository.class);
getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.NONE,
getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.unpaged(),
Sort.unsorted());
}
@ -213,7 +214,7 @@ public class ReflectionRepositoryInvokerUnitTests { @@ -213,7 +214,7 @@ public class ReflectionRepositoryInvokerUnitTests {
Method method = PersonRepository.class.getMethod("findByIdIn", Collection.class);
PersonRepository repository = mock(PersonRepository.class);
getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.NONE,
getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.unpaged(),
Sort.unsorted());
}
}
@ -229,7 +230,7 @@ public class ReflectionRepositoryInvokerUnitTests { @@ -229,7 +230,7 @@ public class ReflectionRepositoryInvokerUnitTests {
Method method = SimpleRepository.class.getMethod("findByClass", int.class);
try {
invoker.invokeQueryMethod(method, parameters, Pageable.NONE, Sort.unsorted());
invoker.invokeQueryMethod(method, parameters, Pageable.unpaged(), Sort.unsorted());
} catch (QueryMethodParameterConversionException o_O) {
assertThat(o_O.getParameter()).isEqualTo(new MethodParameters(method).getParameters().get(0));

Loading…
Cancel
Save