HierarchyNode implements Serializable { public void addDependency(HierarchyNode node) { if (dependencies.contains(node.getFile())) { return; } if (canFormCyclicDependency(this, node)) { return; } dependencies.add(node.getFile()); node.parent = this; } HierarchyNode(File file, HierarchyNode parent); void addDependency(HierarchyNode node); void addMissingDependency(String name); boolean hasDependencies(); File getFile(); Set<File> getDependencies(); Set<String> getMissingDependencies(); boolean containsDependency(File dependency); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test(expected = NullPointerException.class) public void addDependencyNullArgument() { root.addDependency(null); }
@Test public void addDependency() throws Exception { File file = new File("a_file_name", null, null); HierarchyNode node = new HierarchyNode(file, null); root.addDependency(node); assertEquals(root, node.getParent()); assertTrue(root.getDependencies().contains(file)); }