@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)); }
@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()); }
@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)); }