Пример #1
0
  @Test
  public void returnsSamePageIfNoSpecGiven() throws Exception {

    Pageable pageable = new PageRequest(0, 1);

    flushTestUsers();
    assertEquals(userDao.readAll(pageable), userDao.readAll(null, pageable));
  }
Пример #2
0
  @Test
  public void executesCombinedSpecificationsCorrectly() {

    flushTestUsers();
    Specification<User> spec = where(userHasFirstname("Oliver")).or(userHasLastname("Arrasz"));
    assertThat(userDao.readAll(spec).size(), is(2));
  }
Пример #3
0
  /** Tests reading all users. */
  @Test
  public void testReadAll() {

    flushTestUsers();

    List<User> reference = Arrays.asList(firstUser, secondUser);
    assertTrue(userDao.readAll().containsAll(reference));
  }
Пример #4
0
  private Page<User> executeSpecWithSort(Sort sort) {

    flushTestUsers();

    Specification<User> spec = where(userHasFirstname("Oliver")).or(userHasLastname("Matthews"));

    Page<User> result = userDao.readAll(spec, new PageRequest(0, 1, sort));
    assertThat(result.getTotalElements(), is(2L));
    return result;
  }
Пример #5
0
  @Test
  public void executesCombinedSpecificationsWithPageableCorrectly() {

    flushTestUsers();
    Specification<User> spec = where(userHasFirstname("Oliver")).or(userHasLastname("Arrasz"));

    Page<User> users = userDao.readAll(spec, new PageRequest(0, 1));
    assertThat(users.getSize(), is(1));
    assertThat(users.hasPreviousPage(), is(false));
    assertThat(users.getTotalElements(), is(2L));
  }
Пример #6
0
  @Test
  public void returnsAllSortedCorrectly() throws Exception {

    flushTestUsers();
    List<User> result = userDao.readAll(new Sort(Order.ASCENDING, "lastname"));
    assertNotNull(result);
    assertThat(result.size(), is(3));
    assertThat(result.get(0), is(secondUser));
    assertThat(result.get(1), is(firstUser));
    assertThat(result.get(2), is(thirdUser));
  }
Пример #7
0
  @Test
  public void returnsAllAsPageIfNoPageableIsGiven() throws Exception {

    flushTestUsers();
    assertEquals(new PageImpl<User>(userDao.readAll()), userDao.readAll((Pageable) null));
  }
Пример #8
0
  @Test
  public void returnsSameListIfNoSortIsGiven() throws Exception {

    flushTestUsers();
    assertSameElements(userDao.readAll((Sort) null), userDao.readAll());
  }
Пример #9
0
  @Test
  public void returnsSameListIfNoSpecGiven() throws Exception {

    flushTestUsers();
    assertSameElements(userDao.readAll(), userDao.readAll((Specification<User>) null));
  }
Пример #10
0
  @Test
  public void executesSpecificationCorrectly() {

    flushTestUsers();
    assertThat(userDao.readAll(where(userHasFirstname("Oliver"))).size(), is(1));
  }