コード例 #1
0
  @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());
  }
コード例 #2
0
 @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());
 }