Dependency extends AbstractGraphElement { public void addBaseDependency(Dependency baseDep) { if (!baseDependencies.contains(baseDep)) { this.baseDependencies.add(baseDep); } } Dependency(Node source, Node target, DependencyType dependencyType); Node getSource(); Node getTarget(); DependencyType getDependencyType(); void setDependencyType(DependencyType dependencyType); void addBaseDependency(Dependency baseDep); Set<Dependency> getBaseDependencies(); @Override String toString();  }
@Test public void testAddBaseDependency() { Node n1 = new Node("n1"); Node n2 = new Node("n2"); Dependency dependency = new Dependency(n1, n2, DependencyType.CREATE); assertThat(dependency.getBaseDependencies().isEmpty(), is(true)); Node n3 = new Node("n3"); Node n4 = new Node("n4"); Dependency dep2 = new Dependency(n3, n4, DependencyType.READ_ONLY); dependency.addBaseDependency(dep2); assertThat(dependency.getBaseDependencies(), hasSize(1)); Node n5 = new Node("n5"); Node n6 = new Node("n6"); Dependency dep3 = new Dependency(n5, n6, DependencyType.READ_WRITE); dependency.addBaseDependency(dep3); assertThat(dependency.getBaseDependencies(), hasSize(2)); dependency.addBaseDependency(dep2); assertThat(dependency.getBaseDependencies(), hasSize(2)); Dependency dep2b = new Dependency(n3, n4, DependencyType.READ_WRITE); dependency.addBaseDependency(dep2b); assertThat(dependency.getBaseDependencies(), hasSize(3)); }