Skip to content

Commit

Permalink
Exclude tombstone resources when getting a resource's children
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Oct 19, 2014
1 parent 58e32d1 commit b88d360
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Expand Up @@ -172,7 +172,9 @@ public Iterator<FedoraResource> apply(final Node input) {
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);
}
Expand Down
Expand Up @@ -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());
}
}
Expand Up @@ -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));
Expand Down

0 comments on commit b88d360

Please sign in to comment.