### Question:
SoapSecurityService extends AbstractService implements SecurityService { @Override public int changePassword(String sid, long userId, String oldPassword, String newPassword) throws Exception { checkAdministrator(sid); try { UserDAO userDao = (UserDAO) Context.get().getBean(UserDAO.class); User user = userDao.findById(userId); if (user == null) throw new Exception("User " + userId + " not found"); if (oldPassword != null && !CryptUtil.cryptString(oldPassword).equals(user.getPassword())) { return 1; } UserHistory history = null; user.setDecodedPassword(newPassword); user.setPasswordChanged(new Date()); history = new UserHistory(); history.setUser(user); history.setEvent(UserEvent.PASSWORDCHANGED.toString()); history.setComment(""); user.setRepass(""); UserDAO dao = (UserDAO) Context.get().getBean(UserDAO.class); boolean stored = dao.store(user, history); if (!stored) throw new Exception("User not stored"); return 0; } catch (Throwable e) { log.error(e.getMessage(), e); return 1; } }  @Override WSUser[] listUsers(String sid, String group); @Override WSGroup[] listGroups(String sid); @Override long storeUser(String sid, WSUser user); @Override long storeGroup(String sid, WSGroup group); @Override void deleteUser(String sid, long userId); @Override void deleteGroup(String sid, long groupId); @Override int changePassword(String sid, long userId, String oldPassword, String newPassword); @Override WSUser getUser(String sid, long userId); @Override WSUser getUserByUsername(String sid, String username); @Override WSGroup getGroup(String sid, long groupId);  }### Answer:
@Test public void testChangePassword() throws Exception { WSUser newUser = new WSUser(); newUser.setName("user test"); newUser.setUsername("user"); newUser.setFirstName("test"); newUser.setEmail("user@acme.com"); Long userId = securityServiceImpl.storeUser("", newUser); Assert.assertNotNull(userId); int changeResult = securityServiceImpl.changePassword("", userId, null, "newpassword"); Assert.assertEquals(0, changeResult); }