Esempio n. 1
0
  @Test
  public void returnsSamePageIfNoSpecGiven() throws Exception {

    Pageable pageable = new PageRequest(0, 1);

    flushTestUsers();
    assertEquals(userDao.readAll(pageable), userDao.readAll(null, pageable));
  }
Esempio n. 2
0
  @Test
  public void executesCombinedSpecificationsCorrectly() {

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

    flushTestUsers();

    List<User> reference = Arrays.asList(firstUser, secondUser);
    assertTrue(userDao.readAll().containsAll(reference));
  }
Esempio n. 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;
  }
Esempio n. 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));
  }
Esempio n. 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));
  }
Esempio n. 7
0
  @Test
  public void returnsAllAsPageIfNoPageableIsGiven() throws Exception {

    flushTestUsers();
    assertEquals(new PageImpl<User>(userDao.readAll()), userDao.readAll((Pageable) null));
  }
Esempio n. 8
0
  @Test
  public void returnsSameListIfNoSortIsGiven() throws Exception {

    flushTestUsers();
    assertSameElements(userDao.readAll((Sort) null), userDao.readAll());
  }
Esempio n. 9
0
  @Test
  public void returnsSameListIfNoSpecGiven() throws Exception {

    flushTestUsers();
    assertSameElements(userDao.readAll(), userDao.readAll((Specification<User>) null));
  }
Esempio n. 10
0
  @Test
  public void executesSpecificationCorrectly() {

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