class 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;
    }

}

class UserServiceImplTest  {

    @Autowired
    private UserService userService;

    @Test(dataProvider = "dataUser", expectedExceptions = UserNotFoundException.class)
    public void testAuthenticate(User user) {

        userService.save(user);

        userService.authenticate("kevinzzzzzzzzzzz999999****@weghst.com", "88888888");
    }

}