@Test public void testFcreatePasswordResetMailUserNotActivated() { try { _userService.createPasswordResetMail(userName); } catch (IpatException e) { assertEquals(ErrorCodes.USER_NOT_ACTIVATED, e.getErrorInfos().get(0).getErrorCode()); } }
public void createPasswordResetMail(String userName) throws IpatException { User user = getUser(userName); IpatPreconditions.checkArgument(user.isEnabled(), ErrorCodes.USER_NOT_ACTIVATED); user.setActivationKey(UUID.randomUUID().toString()); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.forgot.password.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.forgot.password.text", user.getLang().getLocale()); String mailText = createForgotPasswordMail(user, env.getProperty("ipat.host"), mailTemplateText); new Thread(new Runnable() { @Override public void run() { mailHelper.sendAMessage(mailSubject, mailText, user.getMail()); } }).start(); }
UserService { public void createPasswordResetMail(String userName) throws IpatException { User user = getUser(userName); IpatPreconditions.checkArgument(user.isEnabled(), ErrorCodes.USER_NOT_ACTIVATED); user.setActivationKey(UUID.randomUUID().toString()); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.forgot.password.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.forgot.password.text", user.getLang().getLocale()); String mailText = createForgotPasswordMail(user, env.getProperty("ipat.host"), mailTemplateText); new Thread(new Runnable() { @Override public void run() { mailHelper.sendAMessage(mailSubject, mailText, user.getMail()); } }).start(); } }
UserService { public void createPasswordResetMail(String userName) throws IpatException { User user = getUser(userName); IpatPreconditions.checkArgument(user.isEnabled(), ErrorCodes.USER_NOT_ACTIVATED); user.setActivationKey(UUID.randomUUID().toString()); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.forgot.password.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.forgot.password.text", user.getLang().getLocale()); String mailText = createForgotPasswordMail(user, env.getProperty("ipat.host"), mailTemplateText); new Thread(new Runnable() { @Override public void run() { mailHelper.sendAMessage(mailSubject, mailText, user.getMail()); } }).start(); }  }
UserService { public void createPasswordResetMail(String userName) throws IpatException { User user = getUser(userName); IpatPreconditions.checkArgument(user.isEnabled(), ErrorCodes.USER_NOT_ACTIVATED); user.setActivationKey(UUID.randomUUID().toString()); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.forgot.password.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.forgot.password.text", user.getLang().getLocale()); String mailText = createForgotPasswordMail(user, env.getProperty("ipat.host"), mailTemplateText); new Thread(new Runnable() { @Override public void run() { mailHelper.sendAMessage(mailSubject, mailText, user.getMail()); } }).start(); }  User createAnonymous(); UserReportData getUserDetails(String userName, boolean isEditAllowed); void editUser(String userName, String toEdit, String newEntry); String uploadUserImage(String userName, MultipartFile file); void registrateUser(UserRegistrationData userRegistrationData); void activateUser(long userId, String key); void createPasswordResetMail(String userName); String verifiyPasswordResetLink(long userId, String key); String resetPasswordForUser(long userId, String key, String password); User anonymizeUser(String userName); }
UserService { public void createPasswordResetMail(String userName) throws IpatException { User user = getUser(userName); IpatPreconditions.checkArgument(user.isEnabled(), ErrorCodes.USER_NOT_ACTIVATED); user.setActivationKey(UUID.randomUUID().toString()); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.forgot.password.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.forgot.password.text", user.getLang().getLocale()); String mailText = createForgotPasswordMail(user, env.getProperty("ipat.host"), mailTemplateText); new Thread(new Runnable() { @Override public void run() { mailHelper.sendAMessage(mailSubject, mailText, user.getMail()); } }).start(); }  User createAnonymous(); UserReportData getUserDetails(String userName, boolean isEditAllowed); void editUser(String userName, String toEdit, String newEntry); String uploadUserImage(String userName, MultipartFile file); void registrateUser(UserRegistrationData userRegistrationData); void activateUser(long userId, String key); void createPasswordResetMail(String userName); String verifiyPasswordResetLink(long userId, String key); String resetPasswordForUser(long userId, String key, String password); User anonymizeUser(String userName);  }