Skip to content

Instantly share code, notes, and snippets.

@kikers25
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikers25/0a6bbe1c679e3c1574f7 to your computer and use it in GitHub Desktop.
Save kikers25/0a6bbe1c679e3c1574f7 to your computer and use it in GitHub Desktop.
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