Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-323

PageImpl.getTotalPages() possibly returns incorrect result when PageImpl is instantiated with simple constructor

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5 Final
    • Fix Version/s: 1.6 M1, 1.5.2
    • Component/s: Core
    • Labels:
      None

      Description

      I wonder, why PageImpl.getTotalPages() returns 0, when instantiated with simple constructor, with non zero element collection as argument.

      PageImplTest.java
      import org.junit.*;
      import org.springframework.data.domain.*;
      
      import java.util.*;
      
      import static org.hamcrest.CoreMatchers.*;
      import static org.junit.Assert.*;
      
      public class PageImplTest {
      
          @Test
          public void getTotalPagesReturnSameResultForAllConstructors() {
              List<String> content = Arrays.asList("a", "b");
      
              Page<String> pageWithSimpleConstructor = new PageImpl<>(content);
      
              Pageable pageable = new PageRequest(0, content.size());
      
              Page<String> pageWithComplexConstructor = new PageImpl<>(content, pageable, content.size());
      
              assertThat(pageWithComplexConstructor.getTotalPages(), is(1));
              assertThat(pageWithSimpleConstructor.getTotalPages(), is(1));
      
          }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              sniff Mikhail Mikhaylenko
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: