Hierarchy implements Serializable { public Set<HierarchyNode> getParentsFor(HierarchyNode node) { Validate.notNull(node, "Hierarchy node can't be null"); Set<HierarchyNode> parents = new LinkedHashSet<HierarchyNode>(); for (HierarchyNode n : nodes.values()) { if (n.getDependencies().contains(node.getFile())) { parents.add(n); } } return parents; } 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 getParentsFor() { assertEquals(0, hierarchy.getParentsFor(root).size()); assertEquals(1, hierarchy.getParentsFor(right).size()); assertEquals(1, hierarchy.getParentsFor(left).size()); assertEquals(1, hierarchy.getParentsFor(rightDep).size()); }
@Test(expected = IllegalArgumentException.class) public void getParentsForNullArgument() { hierarchy.getParentsFor(null); }