@Test(expected = IllegalArgumentException.class) public final void shouldThrowExceptionIfUserNameIsNull() throws Exception { passwordReminderServiceImpl.generateAndSendNewPassword(null); }
@Override @Transactional public void generateAndSendNewPassword(final String userName) throws UsernameNotFoundException { Preconditions.checkArgument(StringUtils.isNotEmpty(userName), "user name should not be empty"); Entity userEntity = getUserEntity(userName); String userEmail = userEntity.getStringField("email"); if (!MailServiceImpl.isValidEmail(userEmail)) { throw new InvalidMailAddressException("invalid recipient email address"); } Preconditions.checkNotNull(userEmail, "e-mail for user " + userName + " was not specified."); String newPassword = passwordGeneratorService.generatePassword(); updateUserPassword(userEntity, newPassword); sendNewPassword(userEmail, userName, newPassword); }
PasswordReminderServiceImpl implements PasswordReminderService { @Override @Transactional public void generateAndSendNewPassword(final String userName) throws UsernameNotFoundException { Preconditions.checkArgument(StringUtils.isNotEmpty(userName), "user name should not be empty"); Entity userEntity = getUserEntity(userName); String userEmail = userEntity.getStringField("email"); if (!MailServiceImpl.isValidEmail(userEmail)) { throw new InvalidMailAddressException("invalid recipient email address"); } Preconditions.checkNotNull(userEmail, "e-mail for user " + userName + " was not specified."); String newPassword = passwordGeneratorService.generatePassword(); updateUserPassword(userEntity, newPassword); sendNewPassword(userEmail, userName, newPassword); } }
PasswordReminderServiceImpl implements PasswordReminderService { @Override @Transactional public void generateAndSendNewPassword(final String userName) throws UsernameNotFoundException { Preconditions.checkArgument(StringUtils.isNotEmpty(userName), "user name should not be empty"); Entity userEntity = getUserEntity(userName); String userEmail = userEntity.getStringField("email"); if (!MailServiceImpl.isValidEmail(userEmail)) { throw new InvalidMailAddressException("invalid recipient email address"); } Preconditions.checkNotNull(userEmail, "e-mail for user " + userName + " was not specified."); String newPassword = passwordGeneratorService.generatePassword(); updateUserPassword(userEntity, newPassword); sendNewPassword(userEmail, userName, newPassword); }  }
PasswordReminderServiceImpl implements PasswordReminderService { @Override @Transactional public void generateAndSendNewPassword(final String userName) throws UsernameNotFoundException { Preconditions.checkArgument(StringUtils.isNotEmpty(userName), "user name should not be empty"); Entity userEntity = getUserEntity(userName); String userEmail = userEntity.getStringField("email"); if (!MailServiceImpl.isValidEmail(userEmail)) { throw new InvalidMailAddressException("invalid recipient email address"); } Preconditions.checkNotNull(userEmail, "e-mail for user " + userName + " was not specified."); String newPassword = passwordGeneratorService.generatePassword(); updateUserPassword(userEntity, newPassword); sendNewPassword(userEmail, userName, newPassword); }  @Override @Transactional void generateAndSendNewPassword(final String userName); }
PasswordReminderServiceImpl implements PasswordReminderService { @Override @Transactional public void generateAndSendNewPassword(final String userName) throws UsernameNotFoundException { Preconditions.checkArgument(StringUtils.isNotEmpty(userName), "user name should not be empty"); Entity userEntity = getUserEntity(userName); String userEmail = userEntity.getStringField("email"); if (!MailServiceImpl.isValidEmail(userEmail)) { throw new InvalidMailAddressException("invalid recipient email address"); } Preconditions.checkNotNull(userEmail, "e-mail for user " + userName + " was not specified."); String newPassword = passwordGeneratorService.generatePassword(); updateUserPassword(userEntity, newPassword); sendNewPassword(userEmail, userName, newPassword); }  @Override @Transactional void generateAndSendNewPassword(final String userName);  }