UuidPredicate implements Predicate<NodeState>, com.google.common.base.Predicate<NodeState> { @Override public boolean test(NodeState node) { if (uuids.length == 0) { return false; } PropertyState uuidProperty = node.getProperty(JCR_UUID); if (uuidProperty == null) { return false; } String parentUuid = uuidProperty.getValue(Type.STRING); for (String uuid : uuids) { if (parentUuid.equals(uuid)) { return true; } } return false; } UuidPredicate(@NotNull String[] uuids); @Override boolean test(NodeState node); @Deprecated @Override boolean apply(NodeState node);  }
@Test public void emptyUuidList() { UuidPredicate p = new UuidPredicate(new String[] {}); NodeState tree = createNodeWithUuid(UUIDUtils.generateUUID()); assertFalse(p.test(tree)); }
@Test public void singleUuidMatch() { String uuid = UUIDUtils.generateUUID(); UuidPredicate p = new UuidPredicate(new String[] {uuid}); NodeState tree = createNodeWithUuid(uuid); assertTrue(p.test(tree)); }
@Test public void singleUuidMiss() { UuidPredicate p = new UuidPredicate(new String[] {UUIDUtils.generateUUID()}); NodeState tree = createNodeWithUuid(UUIDUtils.generateUUID()); assertFalse(p.test(tree)); }
@Test public void multipleUuidsMatch() { String uuid = UUIDUtils.generateUUID(); UuidPredicate p = new UuidPredicate( new String[] {UUIDUtils.generateUUID(), UUIDUtils.generateUUID(), uuid}); NodeState tree = createNodeWithUuid(uuid); assertTrue(p.test(tree)); }
@Test public void multipleUuidsMiss() { UuidPredicate p = new UuidPredicate( new String[] {UUIDUtils.generateUUID(), UUIDUtils.generateUUID(), UUIDUtils.generateUUID()}); NodeState tree = createNodeWithUuid(UUIDUtils.generateUUID()); assertFalse(p.test(tree)); }