Metadata metadata = _repo.save(updateChangeDate(newMetadata(), "1990-12-13"));
Metadata metadata2 = _repo.save(updateChangeDate(newMetadata(), "1980-12-13"));
Metadata metadata3 = _repo.save(updateChangeDate(newMetadata(), "1995-12-13"));
final Sort sortByIdAsc = new Sort(Sort.Direction.DESC, Metadata_.id.getName());
PageRequest page1 = new PageRequest(0, 2, sortByIdAsc);
PageRequest page2 = new PageRequest(1, 2, sortByIdAsc);
Page<Pair<Integer, ISODate>> firstPage = _repo.findAllIdsAndChangeDates(page1);
Page<Pair<Integer, ISODate>> secondPage = _repo.findAllIdsAndChangeDates(page2);
assertEquals(2, firstPage.getNumberOfElements());
assertEquals(0, firstPage.getNumber());
assertEquals(2, firstPage.getTotalPages());
assertEquals(3, firstPage.getTotalElements());
assertTrue(firstPage.isFirstPage());
assertFalse(firstPage.isLastPage());
assertTrue(firstPage.hasContent());
assertEquals(1, secondPage.getNumberOfElements());
assertEquals(1, secondPage.getNumber());
assertEquals(2, secondPage.getTotalPages());
assertEquals(3, secondPage.getTotalElements());
assertFalse(secondPage.isFirstPage());
assertTrue(secondPage.isLastPage());
assertTrue(secondPage.hasContent());
assertEquals((Integer) metadata3.getId(), firstPage.getContent().get(0).one());
assertEquals((Integer) metadata2.getId(), firstPage.getContent().get(1).one());
assertEquals((Integer) metadata.getId(), secondPage.getContent().get(0).one());
assertEquals(metadata3.getDataInfo().getChangeDate(), firstPage.getContent().get(0).two());
assertEquals(metadata2.getDataInfo().getChangeDate(), firstPage.getContent().get(1).two());
assertEquals(metadata.getDataInfo().getChangeDate(), secondPage.getContent().get(0).two());
final Sort sortByChangeDate = SortUtils.createSort(Metadata_.dataInfo, MetadataDataInfo_.changeDate);
page1 = new PageRequest(0, 1, sortByChangeDate);
page2 = new PageRequest(0, 3, sortByChangeDate);
firstPage = _repo.findAllIdsAndChangeDates(page1);
secondPage = _repo.findAllIdsAndChangeDates(page2);