diff --git a/src/main/java/org/springframework/data/elasticsearch/core/FacetedPageImpl.java b/src/main/java/org/springframework/data/elasticsearch/core/FacetedPageImpl.java index e4708a306..f5a37f713 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/FacetedPageImpl.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/FacetedPageImpl.java @@ -48,6 +48,7 @@ import org.springframework.data.elasticsearch.core.facet.result.TermResult; * @author Artur Konczak * @author Jonathan Yan * @author Philipp Kräutli + * @author Remco Zigterman */ @Deprecated public abstract class FacetedPageImpl extends PageImpl implements FacetedPage, AggregatedPage { @@ -60,7 +61,7 @@ public abstract class FacetedPageImpl extends PageImpl implements FacetedP } public FacetedPageImpl(List content, Pageable pageable, long total) { - super(content, Pageable.unpaged(), total); + super(content, pageable, total); } @Override diff --git a/src/test/java/org/springframework/data/elasticsearch/core/aggregation/AggregatedPageImplTest.java b/src/test/java/org/springframework/data/elasticsearch/core/aggregation/AggregatedPageImplTest.java new file mode 100644 index 000000000..9c9d12045 --- /dev/null +++ b/src/test/java/org/springframework/data/elasticsearch/core/aggregation/AggregatedPageImplTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2013-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.elasticsearch.core.aggregation; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.elasticsearch.core.aggregation.impl.AggregatedPageImpl; + +import java.util.Arrays; + +/** + * @author Remco Zigterman + */ +public class AggregatedPageImplTest { + + @Test + public void constructFacetedPageWithPageable() { + Page page = new AggregatedPageImpl<>(Arrays.asList("Test", "Test 2"), PageRequest.of(0, 2), 10); + + assertEquals(10, page.getTotalElements()); + assertEquals(2, page.getNumberOfElements()); + assertEquals(2, page.getSize()); + assertEquals(5, page.getTotalPages()); + } +}