### Question:
HierarchicalBrowseResultResponse extends SearchResultResponse { public void removeContainersWithoutContents() { ListIterator<BriefObjectMetadata> resultIt = this.getResultList().listIterator(this.getResultList().size()); while (resultIt.hasPrevious()) { BriefObjectMetadata briefObject = resultIt.previous(); if (briefObject == null || briefObject.getResourceType() == null) { continue; } String resourceType = briefObject.getResourceType(); if ((!briefObject.getCountMap().containsKey("child") || briefObject.getCountMap().get("child") == 0) && !ResourceType.File.equals(resourceType)) { if (this.matchingContainerPids != null && this.matchingContainerPids.contains(briefObject.getId())) { } else { log.debug("Removing container " + briefObject.getId() + "from hierarchical result because it has no children"); resultIt.remove(); } } } } HierarchicalBrowseResultResponse(); void setSearchResultResponse(SearchResultResponse response); void removeContainersWithoutContents(); void populateMatchingContainerPids(SolrDocumentList containerList, String fieldName); void populateItemResults(List<BriefObjectMetadata> itemResults); void generateResultTree(); int getChildNodeIndex(String pid); ResultNode findNode(String pid); void addNodes(List<BriefObjectMetadata> nodes); Long getRootCount(); void setRootCount(Long rootCount); Set<String> getMatchingContainerPids(); void setMatchingContainerPids(Set<String> matchingContainerPids); void setMatchingContainerPids(List<String> matchingContainerPids); ResultNode getRootNode(); void setRootNode(ResultNode rootNode);  }### Answer:
@Test public void removeContainersWithoutContents() { HierarchicalBrowseResultResponse resp = new HierarchicalBrowseResultResponse(); resp.setResultList(getMetadataObjects()); resp.removeContainersWithoutContents(); assertEquals(1, resp.getResultList().size()); assertEquals("uuid:test2", resp.getResultList().get(0).getId()); }