@Test public void testOLeditUserEditLanguage() { try { _userService.editUser(userName, "LANGUAGE", Language.ENGLISH.toString()); } catch (IpatException e) { String errorCode = e.getErrorInfos().get(0).getErrorCode(); fail("edit language should not fail here\nerrorCode:" + errorCode); } User editedUser = _userRepository.findById(2L).orElse(null); assertNotNull(editedUser); assertEquals(Language.ENGLISH, editedUser.getLang()); }
public void editUser(String userName, String toEdit, String newEntry) throws IpatException { User user = getUser(userName); switch (toEdit) { case "NAME": IpatPreconditions.checkArgument((userRepository.userExists(newEntry) == 0), ErrorCodes.USER_ALREADY_EXISTS); user.setName(newEntry); break; case "ABOUTME": user.setAboutMe(newEntry); break; case "LOCATION": user.setLocation(newEntry); break; case "ORGANISATION": user.setOrganisation(newEntry); break; case "HOMEPAGE": user.setHomepage(newEntry); break; case "MAIL": IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(newEntry), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(newEntry) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); user.setMail(newEntry); break; case "NEWSLETTER": user.setNewsletter(newEntry.equals("JA") ? true : false); break; case "ORGANIZATION_TYPE": user.setOrganizationType(OrganizationType.valueOf(newEntry)); break; case "LANGUAGE": user.setLang(Language.valueOf(newEntry)); break; case "PASSWORD": user.setPassword(passwordEncrypter.encryptPassword(newEntry)); break; default: break; } userRepository.save(user); }
UserService { public void editUser(String userName, String toEdit, String newEntry) throws IpatException { User user = getUser(userName); switch (toEdit) { case "NAME": IpatPreconditions.checkArgument((userRepository.userExists(newEntry) == 0), ErrorCodes.USER_ALREADY_EXISTS); user.setName(newEntry); break; case "ABOUTME": user.setAboutMe(newEntry); break; case "LOCATION": user.setLocation(newEntry); break; case "ORGANISATION": user.setOrganisation(newEntry); break; case "HOMEPAGE": user.setHomepage(newEntry); break; case "MAIL": IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(newEntry), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(newEntry) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); user.setMail(newEntry); break; case "NEWSLETTER": user.setNewsletter(newEntry.equals("JA") ? true : false); break; case "ORGANIZATION_TYPE": user.setOrganizationType(OrganizationType.valueOf(newEntry)); break; case "LANGUAGE": user.setLang(Language.valueOf(newEntry)); break; case "PASSWORD": user.setPassword(passwordEncrypter.encryptPassword(newEntry)); break; default: break; } userRepository.save(user); } }
UserService { public void editUser(String userName, String toEdit, String newEntry) throws IpatException { User user = getUser(userName); switch (toEdit) { case "NAME": IpatPreconditions.checkArgument((userRepository.userExists(newEntry) == 0), ErrorCodes.USER_ALREADY_EXISTS); user.setName(newEntry); break; case "ABOUTME": user.setAboutMe(newEntry); break; case "LOCATION": user.setLocation(newEntry); break; case "ORGANISATION": user.setOrganisation(newEntry); break; case "HOMEPAGE": user.setHomepage(newEntry); break; case "MAIL": IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(newEntry), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(newEntry) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); user.setMail(newEntry); break; case "NEWSLETTER": user.setNewsletter(newEntry.equals("JA") ? true : false); break; case "ORGANIZATION_TYPE": user.setOrganizationType(OrganizationType.valueOf(newEntry)); break; case "LANGUAGE": user.setLang(Language.valueOf(newEntry)); break; case "PASSWORD": user.setPassword(passwordEncrypter.encryptPassword(newEntry)); break; default: break; } userRepository.save(user); }  }
UserService { public void editUser(String userName, String toEdit, String newEntry) throws IpatException { User user = getUser(userName); switch (toEdit) { case "NAME": IpatPreconditions.checkArgument((userRepository.userExists(newEntry) == 0), ErrorCodes.USER_ALREADY_EXISTS); user.setName(newEntry); break; case "ABOUTME": user.setAboutMe(newEntry); break; case "LOCATION": user.setLocation(newEntry); break; case "ORGANISATION": user.setOrganisation(newEntry); break; case "HOMEPAGE": user.setHomepage(newEntry); break; case "MAIL": IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(newEntry), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(newEntry) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); user.setMail(newEntry); break; case "NEWSLETTER": user.setNewsletter(newEntry.equals("JA") ? true : false); break; case "ORGANIZATION_TYPE": user.setOrganizationType(OrganizationType.valueOf(newEntry)); break; case "LANGUAGE": user.setLang(Language.valueOf(newEntry)); break; case "PASSWORD": user.setPassword(passwordEncrypter.encryptPassword(newEntry)); break; default: break; } userRepository.save(user); }  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 editUser(String userName, String toEdit, String newEntry) throws IpatException { User user = getUser(userName); switch (toEdit) { case "NAME": IpatPreconditions.checkArgument((userRepository.userExists(newEntry) == 0), ErrorCodes.USER_ALREADY_EXISTS); user.setName(newEntry); break; case "ABOUTME": user.setAboutMe(newEntry); break; case "LOCATION": user.setLocation(newEntry); break; case "ORGANISATION": user.setOrganisation(newEntry); break; case "HOMEPAGE": user.setHomepage(newEntry); break; case "MAIL": IpatPreconditions.checkArgument(CommonValidator.isValidEmailAddress(newEntry), ErrorCodes.INVALID_MAIL); IpatPreconditions.checkArgument((userRepository.userWithMailExists(newEntry) == 0), ErrorCodes.MAIL_ALREADY_EXISTS); user.setMail(newEntry); break; case "NEWSLETTER": user.setNewsletter(newEntry.equals("JA") ? true : false); break; case "ORGANIZATION_TYPE": user.setOrganizationType(OrganizationType.valueOf(newEntry)); break; case "LANGUAGE": user.setLang(Language.valueOf(newEntry)); break; case "PASSWORD": user.setPassword(passwordEncrypter.encryptPassword(newEntry)); break; default: break; } userRepository.save(user); }  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);  }