-
-
Save kikers25/0a6bbe1c679e3c1574f7 to your computer and use it in GitHub Desktop.
UserServiceStubs
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; | |
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; | |
} | |
} |
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 interface UserDAO { | |
User findUserBy(Email email); | |
} |
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 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