UserManagerImpl extends AbstractUserManager implements RoleMappingUserManager { @Override public void changePassword(final String userId, final String newPassword) throws UserNotFoundException { final CUser secUser = configuration.readUser(userId); if (STATUS_CHANGE_PASSWORD.equals(secUser.getStatus())) { secUser.setStatus(STATUS_ACTIVE); } secUser.setPassword(hashPassword(newPassword)); configuration.updateUser(secUser); User user = getUser(userId); eventManager.post(new UserUpdatedEvent(user)); } @Inject  UserManagerImpl(final EventManager eventManager,
                         final SecurityConfigurationManager configuration,
                         final SecuritySystem securitySystem,
                         final PasswordService passwordService,
                         final PasswordValidator passwordValidator); @Override Set<User> listUsers(); @Override Set<String> listUserIds(); @Override User getUser(String userId); @Override String getSource(); @Override boolean supportsWrite(); @Override User addUser(final User user, String password); @Override void changePassword(final String userId, final String newPassword); @Override User updateUser(final User user); @Override void deleteUser(final String userId); @Override Set<RoleIdentifier> getUsersRoles(final String userId, final String source); @Override Set<User> searchUsers(final UserSearchCriteria criteria); @Override void setUsersRoles(final String userId, final String userSource, final Set<RoleIdentifier> roleIdentifiers); @Override String getAuthenticationRealmName();  }
@Test public void testChangePassword() throws Exception { CUser user = new MemoryCUser(); user.setStatus(CUser.STATUS_CHANGE_PASSWORD); user.setId("test"); when(securityConfigurationManager.readUser("test")).thenReturn(user); underTest.changePassword("test", "newpass"); assertThat(user.getStatus(), is(CUser.STATUS_ACTIVE)); verify(passwordValidator).validate("newpass"); }