Instantly share code, notes, and snippets.

Embed
What would you like to do?
UserServiceStubs
public class UserService {
private UserDAO userDAO;
public UserService(UserDAO userDAO) {
this.userDAO = userDAO;
}
public User signIn(Email email, Password password) throws AuthenticationException {
User user;
user = userDAO.findUserBy(email);
// validation user
if (!password.is(user.getPassword())) {
throw new AuthenticationException("user has no permission");
}
// do something
return user;
}
}
public interface UserDAO {
User findUserBy(Email email);
}
public class Password {
private String value;
public Password(String value) {
this.value = value;
}
public boolean is(String password) {
return value.equals(password);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment