Skip to content

Commit

Permalink
Slightly improve the test
Browse files Browse the repository at this point in the history
  • Loading branch information
andriy-dmytruk committed Apr 18, 2024
1 parent db7cc08 commit 6d261ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public boolean equals(Object o) {

@Override
public Optional<Cursor> getCursor(int i) {
return Optional.of(cursors.get(i));
return i >= cursors.size() ? Optional.empty() : Optional.of(cursors.get(i));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ abstract class AbstractCursoredPageSpec extends Specification {
page.content[1].name == name2
page.totalSize == 780
page.totalPages == 78
page.getCursor(0).isPresent()
page.getCursor(9).isPresent()
page.hasNext()

when: "The next page is selected"
Expand Down Expand Up @@ -145,6 +147,8 @@ abstract class AbstractCursoredPageSpec extends Specification {
page.pageNumber == 0
page.content[0].name == elem1
page.content.size() == 8
page.getCursor(7).isPresent()
page.getCursor(8).isEmpty()
!page.hasPrevious()
page.hasNext()

Expand Down Expand Up @@ -202,6 +206,8 @@ abstract class AbstractCursoredPageSpec extends Specification {
page.pageNumber == 0
page.content[0].name == elem1
page.content[1].name == elem2
page.getCursor(1).isPresent()
page.getCursor(2).isEmpty()
page.content.size() == 2
!page.hasPrevious()

Expand Down

0 comments on commit 6d261ea

Please sign in to comment.