PermissionEntry implements Comparable<PermissionEntry>, PermissionConstants { boolean matchesParent(@NotNull String parentPath) { return Text.isDescendantOrEqual(path, parentPath) && (restriction == RestrictionPattern.EMPTY || restriction.matches(parentPath)); } PermissionEntry(@NotNull String path, boolean isAllow, int index,
                    @NotNull PrivilegeBits privilegeBits,
                    @NotNull RestrictionPattern restriction); @Override int compareTo(@NotNull PermissionEntry pe); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testMatchesParentEmptyPattern() { assertTrue(entry.matchesParent(path)); assertTrue(entry.matchesParent(PathUtils.concat(path, "parent", "of", "target"))); assertFalse(entry.matchesParent(PathUtils.getParentPath(path))); assertFalse(entry.matchesParent("/another/path")); }
@Test public void testMatchesParent() { when(pattern.matches(anyString())).thenReturn(true); assertTrue(entryWithNonEmptyPattern.matchesParent(path)); assertTrue(entryWithNonEmptyPattern.matchesParent(PathUtils.concat(path, "parent", "of", "target"))); assertFalse(entryWithNonEmptyPattern.matchesParent(PathUtils.getParentPath(path))); assertFalse(entryWithNonEmptyPattern.matchesParent("/another/path")); when(pattern.matches(anyString())).thenReturn(false); assertFalse(entryWithNonEmptyPattern.matchesParent(path)); assertFalse(entryWithNonEmptyPattern.matchesParent(PathUtils.concat(path, "parent", "of", "target"))); assertFalse(entryWithNonEmptyPattern.matchesParent(PathUtils.getParentPath(path))); assertFalse(entryWithNonEmptyPattern.matchesParent("/another/path")); }