UserService { public void updatePassword(User user) { User currentUser = authenticationService.getCurrentUser(); String password = user.getPassword(); StandardPasswordEncoder encoder = new StandardPasswordEncoder(); String encryptedPassword = encoder.encode(password); currentUser.setPassword(encryptedPassword); log.debug("Password encrypted to : {}", encryptedPassword); try { userRepository.updateUser(currentUser); } catch (ConstraintViolationException cve) { log.info("Constraint violated while updating user " + user + " : " + cve); throw cve; } }  User getUserByLogin(String login); String getLoginByRssUid(String rssUid); User getUserByUsername(String username); Collection<User> getUsersByLogin(Collection<String> logins); List<User> getUsersForCurrentDomain(int pagination); void updateUser(User user); void updatePassword(User user); void createUser(User user); void createTatamibot(String domain); void deleteUser(User user); @Secured("ROLE_ADMIN") @CacheEvict(value = {"group-user-cache", "group-cache","suggest-users-cache"}, allEntries = true) boolean desactivateUser( String username ); void registerUser(User user); void lostPassword(User user); String validateRegistration(String key); void updateWeeklyDigestRegistration(boolean registration); void updateDailyDigestRegistration(boolean registration); String updateRssTimelinePreferences(boolean booleanPreferencesRssTimeline); boolean isDomainHandledByLDAP(String domain); Collection<UserDTO> buildUserDTOList(Collection<User> users); UserDTO buildUserDTO(User user);  }
@Test public void testUpdatePassword() { String login = "jdubois@ippon.fr"; mockAuthenticationOnUserService(login); User testUser = userService.getUserByLogin(login); assertNull(testUser.getPassword()); testUser.setPassword("newPassword"); userService.updatePassword(testUser); testUser = userService.getUserByLogin(login); assertNotNull(testUser.getPassword()); assertNotEquals("newPassword", testUser.getPassword()); }