@Test
  public void testCheckForAchievementMilestoneInvalidEmail() {
    dbStub.setValidResults(Achievements.GOLD.getAwardThreshold());
    emailStub.setEmailSent(false);
    test.checkForAchievementMilestone(invalidEmail);

    assertFalse(emailStub.emailSent());
  }
  @Test
  public void testRegisterUserValidEmailFaultyDatabase() {
    RegistrationPack registrationPack = new RegistrationPack();
    registrationPack.setEmailAddress(validEmail);

    dbStub.setEmailRegistered(false);
    assertFalse(test.registerUser(registrationPack));
  }
  @Test
  public void testChangeEmailAddressValidEmailFaultyDatabase() {
    RegistrationPack registrationPack = new RegistrationPack();
    registrationPack.setEmailAddress(validEmail);
    dbStub.setEmailChanged(false);

    assertFalse(test.changeEmailAddress(registrationPack));
  }
  @Test
  public void testRegisterUserValidEmail() {
    RegistrationPack registrationPack = new RegistrationPack();
    registrationPack.setEmailAddress(validEmail);

    dbStub.setEmailRegistered(true);
    assertTrue(test.registerUser(registrationPack));
  }
  @Test
  public void testChangeEmailAddressValidEmail() {
    RegistrationPack registrationPack = new RegistrationPack();
    registrationPack.setEmailAddress(validEmail);
    dbStub.setEmailChanged(true);

    assertTrue(test.changeEmailAddress(registrationPack));
  }
  @Test
  public void testCheckForAchievementMilestoneBronze() {
    dbStub.setValidResults(Achievements.BRONZE.getAwardThreshold());
    emailStub.setEmailSent(false);
    test.checkForAchievementMilestone(validEmail);

    assertTrue(emailStub.emailSent());
  }
 @Before
 public void setUp() throws Exception {
   dbStub = new UserDetailsJDBCStub();
   emailStub = new EmailSenderStub();
   test = new UserDetailsManager(detailsManagerStub, dbStub);
   test.setEmailSender(emailStub);
   validEmail = "*****@*****.**";
   invalidEmail = "invalid email";
 }
 @Test
 public void testRegisterUserInvalidEmail() {
   RegistrationPack registrationPack = new RegistrationPack();
   registrationPack.setEmailAddress(invalidEmail);
   assertFalse(test.registerUser(registrationPack));
 }
 @Test
 public void testChangeEmailAddressInvalidEmail() {
   RegistrationPack registrationPack = new RegistrationPack();
   registrationPack.setEmailAddress(invalidEmail);
   assertFalse(test.changeEmailAddress(registrationPack));
 }
 @Test
 public void testRetrieveDedicatedUserEmails() {
   test.retrieveDedicatedUserEmails();
   assertTrue(dbStub.isGetUserEmailsCalled());
 }