Exemplo n.º 1
0
  @Test
  public void existReturnsWhetherAnEntityCanBeLoaded() throws Exception {

    flushTestUsers();
    assertTrue(userDao.exists(id));
    assertFalse(userDao.exists(id * 27));
  }
Exemplo n.º 2
0
  /** Flushes test users to the database. */
  private void flushTestUsers() {

    firstUser = userDao.save(firstUser);
    secondUser = userDao.save(secondUser);
    thirdUser = userDao.save(thirdUser);

    userDao.flush();

    id = firstUser.getId();

    assertThat(id, is(notNullValue()));
    assertThat(secondUser.getId(), is(notNullValue()));
    assertThat(thirdUser.getId(), is(notNullValue()));

    assertThat(userDao.exists(id), is(true));
    assertThat(userDao.exists(secondUser.getId()), is(true));
    assertThat(userDao.exists(thirdUser.getId()), is(true));
  }