@Test public void testQAnonymizeUser() { _dbInjecter.injectUser("UserToAnonymize", "userToAnonymize@iplantatree.de"); User user = null; try { user = _userService.anonymizeUser("Adam"); } catch (IpatException e) { } assertThat(user.getName(), containsString("Anonymous")); assertEquals(user.getMail(), ""); }
public User anonymizeUser(String userName) throws IpatException { User user = userRepository.findByName(userName); user.setName(createAnonymousUserName()); user.setAboutMe(""); user.setEnabled(false); user.setHomepage(""); user.setImageName(""); user.setLocation(""); user.setMail(""); user.setNewsletter(false); user.setOrganisation(""); user.setOrganizationType(OrganizationType.PRIVATE); user.setTeam(null); Set<Role> roles = new HashSet<Role>(); roles.add(Role.USER); user.setRoles(roles); userRepository.save(user); return user; }
UserService { public User anonymizeUser(String userName) throws IpatException { User user = userRepository.findByName(userName); user.setName(createAnonymousUserName()); user.setAboutMe(""); user.setEnabled(false); user.setHomepage(""); user.setImageName(""); user.setLocation(""); user.setMail(""); user.setNewsletter(false); user.setOrganisation(""); user.setOrganizationType(OrganizationType.PRIVATE); user.setTeam(null); Set<Role> roles = new HashSet<Role>(); roles.add(Role.USER); user.setRoles(roles); userRepository.save(user); return user; } }
UserService { public User anonymizeUser(String userName) throws IpatException { User user = userRepository.findByName(userName); user.setName(createAnonymousUserName()); user.setAboutMe(""); user.setEnabled(false); user.setHomepage(""); user.setImageName(""); user.setLocation(""); user.setMail(""); user.setNewsletter(false); user.setOrganisation(""); user.setOrganizationType(OrganizationType.PRIVATE); user.setTeam(null); Set<Role> roles = new HashSet<Role>(); roles.add(Role.USER); user.setRoles(roles); userRepository.save(user); return user; }  }
UserService { public User anonymizeUser(String userName) throws IpatException { User user = userRepository.findByName(userName); user.setName(createAnonymousUserName()); user.setAboutMe(""); user.setEnabled(false); user.setHomepage(""); user.setImageName(""); user.setLocation(""); user.setMail(""); user.setNewsletter(false); user.setOrganisation(""); user.setOrganizationType(OrganizationType.PRIVATE); user.setTeam(null); Set<Role> roles = new HashSet<Role>(); roles.add(Role.USER); user.setRoles(roles); userRepository.save(user); return 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 User anonymizeUser(String userName) throws IpatException { User user = userRepository.findByName(userName); user.setName(createAnonymousUserName()); user.setAboutMe(""); user.setEnabled(false); user.setHomepage(""); user.setImageName(""); user.setLocation(""); user.setMail(""); user.setNewsletter(false); user.setOrganisation(""); user.setOrganizationType(OrganizationType.PRIVATE); user.setTeam(null); Set<Role> roles = new HashSet<Role>(); roles.add(Role.USER); user.setRoles(roles); userRepository.save(user); return 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);  }