@Test public void testGactivateUserSuccess() { User registratedUser = _userRepository.findByName(userName); String activationKey = registratedUser.getActivationKey(); try { _userService.activateUser(2L, activationKey); } catch (IpatException e) { String errorCode = e.getErrorInfos().get(0).getErrorCode(); fail("user registration should not fail here\nerrorCode:" + errorCode); } registratedUser = _userRepository.findByName(userName); assertEquals(true, registratedUser.isEnabled()); }
public void activateUser(long userId, String key) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(!user.isEnabled(), ErrorCodes.USER_ALREADY_ACTIVATED); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setEnabled(true); userRepository.save(user); }
UserService { public void activateUser(long userId, String key) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(!user.isEnabled(), ErrorCodes.USER_ALREADY_ACTIVATED); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setEnabled(true); userRepository.save(user); } }
UserService { public void activateUser(long userId, String key) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(!user.isEnabled(), ErrorCodes.USER_ALREADY_ACTIVATED); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setEnabled(true); userRepository.save(user); }  }
UserService { public void activateUser(long userId, String key) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(!user.isEnabled(), ErrorCodes.USER_ALREADY_ACTIVATED); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setEnabled(true); 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 activateUser(long userId, String key) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(!user.isEnabled(), ErrorCodes.USER_ALREADY_ACTIVATED); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setEnabled(true); 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);  }