UserValidator extends DefaultValidator implements UserConstants { @Override public void propertyAdded(PropertyState after) throws CommitFailedException { if (authorizableType == null) { return; } String name = after.getName(); if (REP_DISABLED.equals(name) && isAdminUser(parentAfter)) { String msg = "Admin user cannot be disabled."; throw constraintViolation(20, msg); } if (JcrConstants.JCR_UUID.equals(name) && !isValidUUID(parentAfter, after.getValue(Type.STRING))) { String msg = "Invalid jcr:uuid for authorizable " + parentAfter.getName(); throw constraintViolation(21, 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 public void testDisableAdminUserNonExistingTree() throws Exception { String adminId = getConfig().getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID); Authorizable admin = getUserManager(root).getAuthorizable(adminId); Tree userTree = root.getTree(checkNotNull(admin).getPath()); UserValidator validator = createUserValidator(userTree, userTree); userTree.remove(); validator.propertyAdded(PropertyStates.createProperty(REP_DISABLED, "disabled")); }