@Test
public void shouldReturnPageableResultsWithGivenSortingOrder(){
//given
String documentId = random(5);
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setMessage("abc");
sampleEntity.setVersion(System.currentTimeMillis());
repository.save(sampleEntity);
String documentId2 = randomNumeric(5);
SampleEntity sampleEntity2 = new SampleEntity();
sampleEntity2.setId(documentId2);
sampleEntity2.setMessage("abd");
sampleEntity.setVersion(System.currentTimeMillis());
repository.save(sampleEntity2);
String documentId3 = randomNumeric(5);
SampleEntity sampleEntity3 = new SampleEntity();
sampleEntity3.setId(documentId3);
sampleEntity3.setMessage("abe");
sampleEntity.setVersion(System.currentTimeMillis());
repository.save(sampleEntity3);
//when
Page<SampleEntity> pageResult = repository.findByMessageContaining("a", new PageRequest(0, 23, new Sort(new Sort.Order(Sort.Direction.DESC,"message"))));
//then
assertThat(pageResult.getContent().isEmpty(),is(false));
assertThat(pageResult.getContent().get(0).getMessage(),is(sampleEntity3.getMessage()));
}