UserServiceImpl implements UserService { @Transactional(readOnly = true) @Override public User authenticate(String email, String password) throws UserNotFoundException, PasswordNotMatchedException { User user = findByEmail(email); if (user == null) { throw new UserNotFoundException("未找到邮箱为 [" + email + "] 的用户"); } String encPassword = DigestUtils.md5Hex(password); if (!encPassword.equalsIgnoreCase(user.getPassword())) { throw new PasswordNotMatchedException("用户 [" + email + "] 输入的密码错误"); } return user; }  @Override void save(User user); @Override void save(User user, int[] appIds); @Override void update(User user); @Override void updatePassword(int id, String oldPassword, String newPassword); @Override void update(User user, int[] appIds); @Override void deleteById(int id); @Transactional(readOnly = true) @Override User findById(int id); @Transactional(readOnly = true) @Override User findByEmail(String email); @Transactional(readOnly = true) @Override int[] findUserAppIds(int id); @Override List<User> findOrdinaryUsers(); @Transactional(readOnly = true) @Override List<User> findAll(); @Transactional(readOnly = true) @Override User authenticate(String email, String password);  }
@Test(dataProvider = "dataUser", expectedExceptions = UserNotFoundException.class) public void testAuthenticate(User user) { userService.save(user); userService.authenticate("kevinzzzzzzzzzzz999999****@weghst.com", "88888888"); }