-
-
Save kikers25/5f8245d1e58f4fe48d0d to your computer and use it in GitHub Desktop.
UserService for spies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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