PasswordChangeAction extends AbstractAuthorizableAction { @Override public void onPasswordChange(@NotNull User user, String newPassword, @NotNull Root root, @NotNull NamePathMapper namePathMapper) throws RepositoryException { if (newPassword == null) { throw new ConstraintViolationException("Expected a new password that is not null."); } String pwHash = getPasswordHash(root, user); if (PasswordUtil.isSame(pwHash, newPassword)) { throw new ConstraintViolationException("New password is identical to the old password."); } }  @Override void onPasswordChange(@NotNull User user, String newPassword, @NotNull Root root, @NotNull NamePathMapper namePathMapper);  }
@Test(expected = ConstraintViolationException.class) public void testNullPassword() throws Exception { pwChangeAction.onPasswordChange(user, null, createRoot(null), namePathMapper); }
@Test(expected = ConstraintViolationException.class) public void testSamePassword() throws Exception { pwChangeAction.onPasswordChange(user, "pw", createRoot("pw"), namePathMapper); }
@Test public void testPasswordChange() throws Exception { pwChangeAction.onPasswordChange(user, "changedPassword", createRoot("pw"), namePathMapper); }
@Test public void testUserWithoutPassword() throws Exception { try { pwChangeAction.onPasswordChange(user, "changedPassword", createRoot(null), namePathMapper); } finally { user.remove(); } }