Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kikers25
Created February 22, 2015 19:17
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/5f8245d1e58f4fe48d0d to your computer and use it in GitHub Desktop.
Save kikers25/5f8245d1e58f4fe48d0d to your computer and use it in GitHub Desktop.
UserService for spies
public class UserService {
private UserDAO userDAO;
private EmailService emailService;
public UserService(UserDAO userDAO, EmailService emailService) {
this.userDAO = userDAO;
this.emailService = emailService;
}
public User findOrCreateWith(Email email) {
User user = userDAO.findUserBy(email);
if (user.isEmpty()) {
user = userDAO.createWith(email);
emailService.sendEmailTo(user);
}
return user;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment