Create a gist now

Instantly share code, notes, and snippets.

@kikers25 / Secret
Last active Aug 29, 2015

What would you like to do?
public class TestUserService {
private static final Email EMAIL = new Email("");
private final class StubUserDAO implements UserDAO {
public User findUserBy(Email email) {
return userWithPassword("other_password");
private UserDAO stubUserDAO;
private UserService userService;
public void initialization() {
stubUserDAO = new StubUserDAO();
userService = new UserService(stubUserDAO);
public void //
should_throw_exception_when_passwords_are_different_version1() throws Exception {
try {
userService.signIn(EMAIL, new Password("password"));
fail("No threw exception");
} catch (AuthenticationException e) {
// ok
@Test(expected = AuthenticationException.class)
public void //
should_throw_exception_when_passwords_are_different_version2() throws Exception {
userService.signIn(EMAIL, new Password("password"));
private User userWithPassword(String password) {
User user = new User();
return user;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment