Instantly share code, notes, and snippets.

What would you like to do?
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);
return user;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment