PrivilegeContext implements Context, PrivilegeConstants { @Override public boolean definesProperty(@NotNull Tree parent, @NotNull PropertyState property) { return PRIVILEGE_PROPERTY_NAMES.contains(property.getName()) && definesTree(parent); } private  PrivilegeContext(); @Override boolean definesProperty(@NotNull Tree parent, @NotNull PropertyState property); @Override boolean definesContextRoot(@NotNull Tree tree); @Override boolean definesTree(@NotNull Tree tree); @Override boolean definesLocation(@NotNull TreeLocation location); @Override boolean definesInternal(@NotNull Tree tree);  }
@Test public void testDefinesProperty() { for (String propName : PrivilegeConstants.PRIVILEGE_PROPERTY_NAMES) { PropertyState property = PropertyStates.createProperty(propName, "value"); for (String ntName : PrivilegeConstants.PRIVILEGE_NODETYPE_NAMES) { assertTrue(ctx.definesProperty(mockTree("anyName", ntName), property)); } } }
@Test public void testNameNotDefinesProperty() { for (String propName : new String[] {"anyName", JcrConstants.JCR_PRIMARYTYPE}) { PropertyState property = PropertyStates.createProperty(propName, "value"); for (String ntName : PrivilegeConstants.PRIVILEGE_NODETYPE_NAMES) { assertFalse(ctx.definesProperty(mockTree("anyName", ntName), property)); } } }
@Test public void testParentNotDefinesProperty() { for (String propName : PrivilegeConstants.PRIVILEGE_PROPERTY_NAMES) { PropertyState property = PropertyStates.createProperty(propName, "value"); for (String ntName : new String[] {JcrConstants.NT_BASE, JcrConstants.NT_UNSTRUCTURED}) { assertFalse(ctx.definesProperty(mockTree("anyName", ntName), property)); } } }