@Test public void testDARegistrateUserSuccess() { UserRegistrationData userRegistrationData = new UserRegistrationData(); userRegistrationData.setUsername(userName); userRegistrationData.setMail("user@iplantatree.de"); userRegistrationData.setOrgType(OrganizationType.PRIVATE.toString()); userRegistrationData.setLanguage(Language.DEUTSCH.toString()); try { _userService.registrateUser(userRegistrationData); } catch (IpatException e) { String errorCode = e.getErrorInfos().get(0).getErrorCode(); fail("user registration should not fail here\nerrorCode:" + errorCode); } assertEquals(2, _userRepository.count()); User registratedUser = _userRepository.findByName(userName); assertEquals(false, registratedUser.isEnabled()); }
public void registrateUser(UserRegistrationData userRegistrationData) throws IpatException { String userName = userRegistrationData.getUsername(); String mail = userRegistrationData.getMail(); IpatPreconditions.checkArgument((userRepository.userExists(userName) == 0), ErrorCodes.USER_ALREADY_EXISTS); IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(mail), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(mail) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); User user = convertUserRegDataToUser(userRegistrationData); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.registration.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.registration.text", user.getLang().getLocale()); String mailText = createUserRegistrationMailText(user, env.getProperty("ipat.host"), mailTemplateText); new Thread(new Runnable() { @Override public void run() { mailHelper.sendAMessage(mailSubject, mailText, user.getMail()); } }).start(); }
UserService { public void registrateUser(UserRegistrationData userRegistrationData) throws IpatException { String userName = userRegistrationData.getUsername(); String mail = userRegistrationData.getMail(); IpatPreconditions.checkArgument((userRepository.userExists(userName) == 0), ErrorCodes.USER_ALREADY_EXISTS); IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(mail), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(mail) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); User user = convertUserRegDataToUser(userRegistrationData); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.registration.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.registration.text", user.getLang().getLocale()); String mailText = createUserRegistrationMailText(user, env.getProperty("ipat.host"), mailTemplateText); new Thread(new Runnable() { @Override public void run() { mailHelper.sendAMessage(mailSubject, mailText, user.getMail()); } }).start(); } }
UserService { public void registrateUser(UserRegistrationData userRegistrationData) throws IpatException { String userName = userRegistrationData.getUsername(); String mail = userRegistrationData.getMail(); IpatPreconditions.checkArgument((userRepository.userExists(userName) == 0), ErrorCodes.USER_ALREADY_EXISTS); IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(mail), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(mail) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); User user = convertUserRegDataToUser(userRegistrationData); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.registration.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.registration.text", user.getLang().getLocale()); String mailText = createUserRegistrationMailText(user, env.getProperty("ipat.host"), mailTemplateText); new Thread(new Runnable() { @Override public void run() { mailHelper.sendAMessage(mailSubject, mailText, user.getMail()); } }).start(); }  }
UserService { public void registrateUser(UserRegistrationData userRegistrationData) throws IpatException { String userName = userRegistrationData.getUsername(); String mail = userRegistrationData.getMail(); IpatPreconditions.checkArgument((userRepository.userExists(userName) == 0), ErrorCodes.USER_ALREADY_EXISTS); IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(mail), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(mail) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); User user = convertUserRegDataToUser(userRegistrationData); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.registration.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.registration.text", user.getLang().getLocale()); String mailText = createUserRegistrationMailText(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 registrateUser(UserRegistrationData userRegistrationData) throws IpatException { String userName = userRegistrationData.getUsername(); String mail = userRegistrationData.getMail(); IpatPreconditions.checkArgument((userRepository.userExists(userName) == 0), ErrorCodes.USER_ALREADY_EXISTS); IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(mail), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(mail) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); User user = convertUserRegDataToUser(userRegistrationData); userRepository.save(user); String mailSubject = messageByLocaleService.getMessage("mail.registration.subject", user.getLang().getLocale()); String mailTemplateText = messageByLocaleService.getMessage("mail.registration.text", user.getLang().getLocale()); String mailText = createUserRegistrationMailText(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);  }