EntryPredicate { @NotNull static Predicate<PermissionEntry> create(@Nullable String oakPath) { if (oakPath == null) { return permissionEntry -> permissionEntry.matches(); } else { return permissionEntry -> permissionEntry.matches(oakPath); } } private  EntryPredicate();   }
@Test public void testCreateNullPath() { Predicate<PermissionEntry> predicate = EntryPredicate.create(null); predicate.apply(pe); verify(pe, times(1)).matches(); verify(pe, never()).matches(Mockito.anyString()); verify(pe, never()).matches(Mockito.any(Tree.class), Mockito.any(PropertyState.class)); verify(pe, never()).getPrivilegeBits(); }
@Test public void testCreatePath() { Predicate<PermissionEntry> predicate = EntryPredicate.create(Mockito.anyString()); predicate.apply(pe); verify(pe, never()).matches(); verify(pe, times(1)).matches(Mockito.anyString()); verify(pe, never()).matches(Mockito.any(Tree.class), Mockito.any(PropertyState.class)); verify(pe, never()).getPrivilegeBits(); }
@Test public void testCreateNonExistingTree() { Predicate<PermissionEntry> predicate = EntryPredicate.create(tree, null); predicate.apply(pe); verify(pe, never()).matches(); verify(pe, times(1)).matches(tree.getPath()); verify(pe, times(0)).matches(PathUtils.ROOT_PATH); verify(pe, never()).matches(Mockito.any(Tree.class), Mockito.any(PropertyState.class)); verify(pe, never()).getPrivilegeBits(); }
@Test public void testCreateNonExistingTreeProperty() { Predicate<PermissionEntry> predicate = EntryPredicate.create(tree, propertyState); predicate.apply(pe); verify(pe, never()).matches(); verify(pe, times(1)).matches(PROP_PATH); verify(pe, never()).matches(tree.getPath()); verify(pe, never()).matches(Mockito.any(Tree.class), Mockito.any(PropertyState.class)); verify(pe, never()).getPrivilegeBits(); }
@Test public void testCreateExistingTree() { when(tree.exists()).thenReturn(true); Predicate<PermissionEntry> predicate = EntryPredicate.create(tree, null); predicate.apply(pe); verify(pe, never()).matches(); verify(pe, never()).matches(TREE_PATH); verify(pe, times(1)).matches(tree, null); verify(pe, never()).getPrivilegeBits(); }
@Test public void testCreateExistingTreeProperty() { when(tree.exists()).thenReturn(true); Predicate<PermissionEntry> predicate = EntryPredicate.create(tree, propertyState); predicate.apply(pe); verify(pe, never()).matches(); verify(pe, never()).matches(PROP_PATH); verify(pe, times(1)).matches(tree, propertyState); verify(pe, never()).matches(tree, PropertyStates.createProperty("another", "value")); verify(pe, never()).getPrivilegeBits(); }