### Question:
UserServiceImpl implements UserService { @Transactional @Override public User update(String username, User updatedUser, String updatedRawPassword) { Assert.notNull(updatedUser, "user must not be null"); preUpdate(username, updatedUser); String encodedPassword = passwordEncoder.encode(updatedRawPassword); updatedUser.setPassword(encodedPassword); return doUpdate(username, updatedUser); }  @Override User findOne(String username); @Override User findOneByUsernameOrEmail(String usernameOrEmail); @Override Page<User> findPage(Pageable pageable); @Transactional @Override User create(User user, String rawPassword); @Transactional @Override User update(String username, User updatedUser,
                       String updatedRawPassword); @Transactional @Override User updateWithoutPassword(String username, User updatedUser); @Transactional @Override void delete(String username);  }### Answer:
@Ignore("TODO fix") @Test @Rollback(false) @Transactional public void testUpdate() { System.out.println("test update"); User user = new User("testuser", null, "testuser@example.com", true, false, "Test", "User", new HashSet<Role>()).lock().disable(); user.getRoles().clear(); user.getRoles().add(new Role(1)); System.out.println("lock"); user.setEmail("testuser2@example.com"); userService.update("testuser", user, "password"); }
@Test(expected = BusinessException.class) @Transactional public void testUpdate_email_is_already_used() { System.out.println("hoge"); User user = new User("testuser", null, "testuser@example.com", true, false, "Test", "User", null); user.setEmail("admin@example.com"); userService.update("testuser", user, "password"); }
@Test(expected = BusinessException.class) @Transactional public void testUpdate_not_existuser() { User user = new User("not_exist_user", null, "not_exist_user@example.com", true, false, "Test", "User", null); user.setEmail("not_exist_user@example.com"); userService.update("not_exist_user", user, "password"); }
@Test(expected = BusinessException.class) @Transactional public void testUpdate_illegal_role() { System.out.println("test update illegal role"); User user = new User("testuser", null, "testuser@example.com", true, false, "Test", "User", new HashSet<Role>()); user.getRoles().add(new Role(100)); userService.update("testuser", user, "password"); }