Permalink
Browse files

Exclude tombstone resources when getting a resource's children

  • Loading branch information...
cbeer committed Oct 19, 2014
1 parent 58e32d1 commit b88d360314fdfced960e1ca42c8fe3893d0b896f
@@ -172,7 +172,9 @@ public String getPath() {
public boolean apply(final Node n) {
LOGGER.trace("Testing child node {}", n);
try {
return (isInternalNode.apply(n) || n.getName().equals(JCR_CONTENT));
return isInternalNode.apply(n)
|| n.getName().equals(JCR_CONTENT)
|| TombstoneImpl.hasMixin(n);
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
@@ -638,4 +638,15 @@ public void testGetChildrenWithHierarchy() throws RepositoryException {
assertEquals(resource, container.getChildren().next());
}
@Test
public void testGetChildrenTombstonesAreHidden() throws RepositoryException {
final String pid = getRandomPid();
final FedoraObject container = objectService.findOrCreateObject(session, "/" + pid);
final FedoraResource resource = objectService.findOrCreateObject(session, "/" + pid + "/a");
resource.delete();
assertFalse(container.getChildren().hasNext());
}
}
@@ -391,6 +391,15 @@ public void testGetChildrenExcludesModeSystem() throws RepositoryException {
assertFalse("Expected an empty iterator", children.hasNext());
}
@Test
public void testGetChildrenExcludesTombstones() throws RepositoryException {
when(mockNode.getNodes()).thenReturn(nodeIterator(mockChild));
when(mockChild.isNodeType("fedora:tombstone")).thenReturn(true);
when(mockChild.getName()).thenReturn("x");
final Iterator<FedoraResource> children = testObj.getChildren();
assertFalse("Expected an empty iterator", children.hasNext());
}
@Test
public void testGetChildrenExcludesJcrContent() throws RepositoryException {
when(mockNode.getNodes()).thenReturn(nodeIterator(mockChild));

0 comments on commit b88d360

Please sign in to comment.