UserValidator extends DefaultValidator implements UserConstants { @Override public void propertyDeleted(PropertyState before) throws CommitFailedException { if (authorizableType == null) { return; } String name = before.getName(); if (REP_PASSWORD.equals(name) || REP_PRINCIPAL_NAME.equals(name) || REP_AUTHORIZABLE_ID.equals(name)) { String msg = "Authorizable property " + name + " may not be removed."; throw constraintViolation(25, msg); } } UserValidator(Tree parentBefore, Tree parentAfter, UserValidatorProvider provider); @Override void propertyAdded(PropertyState after); @Override void propertyChanged(PropertyState before, PropertyState after); @Override void propertyDeleted(PropertyState before); @Override Validator childNodeAdded(String name, NodeState after); @Override Validator childNodeChanged(String name, NodeState before, NodeState after); @Override Validator childNodeDeleted(String name, NodeState before);  }
@Test(expected = CommitFailedException.class) public void removePrincipalName2() throws Exception { try { Tree userTree = root.getTree(userPath); UserValidator validator = createUserValidator(userTree, userTree); validator.propertyDeleted(userTree.getProperty(REP_PRINCIPAL_NAME)); } catch (CommitFailedException e) { assertEquals(25, e.getCode()); assertTrue(e.isConstraintViolation()); throw e; } }