PrivilegeContext implements Context, PrivilegeConstants { @Override public boolean definesLocation(@NotNull TreeLocation location) { return Text.isDescendantOrEqual(PRIVILEGES_PATH, location.getPath()); } 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 testDefinesLocation() { List<String> paths = ImmutableList.of( PrivilegeConstants.PRIVILEGES_PATH, PrivilegeConstants.PRIVILEGES_PATH + "/child", PrivilegeConstants.PRIVILEGES_PATH + "/another/child" ); for (String path : paths) { TreeLocation location = Mockito.mock(TreeLocation.class); when(location.getPath()).thenReturn(path); assertTrue(path, ctx.definesLocation(location)); } }
@Test public void testNotDefinesLocation() { List<String> paths = ImmutableList.of( PathUtils.ROOT_PATH, PrivilegeConstants.PRIVILEGES_PATH + "sibling", "/some/other/path", "" ); for (String path : paths) { TreeLocation location = Mockito.mock(TreeLocation.class); when(location.getPath()).thenReturn(path); assertFalse(path, ctx.definesLocation(location)); } }