コード例 #1
0
  @Test
  public void shouldSaveUser() {
    // given a configured user
    User user = new User();
    user.setUsername("username");

    // when
    userDao.save(user);

    // then the user should be persisted
    assertThat(userDao.getById(user.getId()), is(user));
  }
コード例 #2
0
  @Test
  public void shouldDeleteUser() {
    // given an existing user
    User user = new User();
    user.setUsername("username");
    userDao.save(user);

    // when
    userDao.delete(user);

    // then the user should be persisted
    assertThat(userDao.getById(user.getId()), nullValue());
  }
コード例 #3
0
  @Test
  public void shouldGetByUsername() {
    // given an existing user
    User user = new User();
    user.setUsername("username");
    userDao.save(user);

    // when
    User retrievedUser = userDao.getByUserName("username");

    // then
    assertThat(retrievedUser, is(user));
  }