@Test
  public void testFindAllSortingByName() {
    Sort sort = new Sort(new Sort.Order(Sort.Direction.ASC, "name"));
    PageRequest pageRequest = new PageRequest(0, 100, sort);
    Page<Author> authors = authorRepository.findAll(pageRequest);
    assertThat(authors).isNotNull();
    assertThat(authors.getContent().size()).isEqualTo(4);
    assertThat(authors.getContent().get(0).getName()).isEqualTo(fozzie.getName());

    sort = new Sort(new Sort.Order(Sort.Direction.DESC, "name"));
    pageRequest = new PageRequest(0, 100, sort);
    authors = authorRepository.findAll(pageRequest);
    assertThat(authors).isNotNull();
    assertThat(authors.getContent().size()).isEqualTo(4);
    assertThat(authors.getContent().get(0).getName()).isEqualTo(swedishChef.getName());
  }
 @Test
 public void testFindByBirthDateBetweenDates() {
   List<Author> authors = authorRepository.findAll();
   assertThat(authors).isNotNull();
   assertThat(authors.size()).isEqualTo(4);
   assertThat(authors.get(0).getName()).isEqualTo(kermit.getName());
 }
 /** Demo of named queries using paging but not sorting */
 @Test
 @Ignore
 public void testFindByBirthDateBetweenDatesWithNullPageable() {
   Sort sort = new Sort(new Sort.Order(Sort.Direction.ASC, "name"));
   PageRequest pageRequest = new PageRequest(0, 100, sort);
   Page<Author> authors =
       authorRepository.findByBirthDateBetweenDates(
           new LocalDate().minusYears(25), new LocalDate(), pageRequest);
   assertThat(authors).isNotNull();
   assertThat(authors.getContent()).isNotNull();
   assertThat(authors.getContent().size()).isEqualTo(4);
   assertThat(authors.getContent().get(0).getName()).isEqualTo(fozzie.getName());
 }
  @Before
  public void before() {
    kermit = new Author();
    kermit.setName("Kermit the Frog");
    kermit.setBirthDate(new LocalDate().minusYears(20));
    kermit = authorRepository.save(kermit);

    scooter = new Author();
    scooter.setName("Scooter");
    scooter.setBirthDate(new LocalDate().minusYears(15));
    scooter = authorRepository.save(scooter);

    fozzie = new Author();
    fozzie.setName("Fozzie the Bear");
    fozzie.setBirthDate(new LocalDate().minusYears(5));
    fozzie = authorRepository.saveAndFlush(fozzie);

    swedishChef = new Author();
    swedishChef.setName("Swedish Chef");
    swedishChef.setBirthDate(new LocalDate().minusYears(10));
    swedishChef = authorRepository.save(swedishChef);

    authorRepository.flush();
  }