Hierarchy implements Serializable { public Iterator<HierarchyNode> iteratorXUsesYHierarchy(HierarchyNode node) { if (node == null) { return topLevelNodes.iterator(); } return getDependenciesFor(node).iterator(); } Hierarchy(Project project, Collection<HierarchyNode> collection); Project getProject(); HierarchyNode getNode(File file); int getFileCount(); boolean fileHasDependency(File file, File dependency); Collection<HierarchyNode> getAllNodes(); Set<HierarchyNode> getTopLevelNodes(); Set<HierarchyNode> getBottomLevelNodes(); Set<HierarchyNode> getDependenciesFor(HierarchyNode node); Set<HierarchyNode> getParentsFor(HierarchyNode node); Iterator<HierarchyNode> iteratorFlatHierarchy(); Iterator<HierarchyNode> iteratorXUsesYHierarchy(HierarchyNode node); Iterator<HierarchyNode> iteratorXUsedByYHierarchy(HierarchyNode node); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void iteratorXUsesYHierarchy() { Hierarchy clone = (Hierarchy) SerializationUtils.clone(hierarchy); Iterator<HierarchyNode> iterator = clone.iteratorXUsesYHierarchy(null); assertEquals(root, iterator.next()); assertFalse(iterator.hasNext()); iterator = clone.iteratorXUsesYHierarchy(root); assertEquals(left, iterator.next()); assertEquals(right, iterator.next()); assertFalse(iterator.hasNext()); iterator = clone.iteratorXUsesYHierarchy(right); assertEquals(rightDep, iterator.next()); assertFalse(iterator.hasNext()); iterator = clone.iteratorXUsesYHierarchy(left); assertFalse(iterator.hasNext()); iterator = clone.iteratorXUsesYHierarchy(rightDep); assertFalse(iterator.hasNext()); }