@Test
public void shouldAddNewUserToDatabase() throws UserAlreadyRegisteredException, IOException {

    UserRegistration testee = new UserRegistration(mockDatabase, mockEmailSender);

    String emailAddress = "foo@example.com";
    when(mockDatabase.hasUser(emailAddress)).thenReturn(false);

    when(mockEmailSender
            .sendRegistrationEmail(any(RegistrationEmail.class)))
            .thenReturn(true);

    testee.registerNewUser(emailAddress);
    Mockito.verify(mockDatabase).addUser(emailAddress);
}