@Test
public void testAddDependency() {

    Node n1 = graph.getOrCreateNodeByName("v1");
    Node n2 = graph.getOrCreateNodeByName("v2");
    assertNull(graph.getEdge(n1, n2));
    assertThat(graph.getAllNodes(), hasSize(2));
    assertThat(graph.getAllEdges(), hasSize(0));
    graph.addDependency(n1, n2, DependencyType.READ_ONLY);
    assertThat(graph.getAllEdges(), hasSize(1));
    assertNotNull(graph.getEdge(n1, n2));
    assertNull(graph.getEdge(n2, n1));
    Dependency dep = graph.getAllEdges().iterator().next();
    assertEquals(dep.getSource(), n1);
    assertEquals(dep.getTarget(), n2);
    assertEquals(DependencyType.READ_ONLY, dep.getDependencyType());
    // Test overwriting the dependency type:
    graph.addDependency(n1, n2, DependencyType.CREATE); // type is "higher", old dependency will be changed
    assertThat(graph.getAllEdges(), hasSize(1)); // still 1! no additional dependency.
    dep = graph.getAllEdges().iterator().next();
    assertEquals(dep.getSource(), n1);
    assertEquals(dep.getTarget(), n2);
    assertEquals(DependencyType.CREATE, dep.getDependencyType());
    // but it won't replace a "lower" dependency:
    graph.addDependency(n1, n2, DependencyType.READ_WRITE); // type is "lower", no change
    assertThat(graph.getAllEdges(), hasSize(1)); // still 1! no additional dependency.
    dep = graph.getAllEdges().iterator().next();
    assertEquals(dep.getSource(), n1);
    assertEquals(dep.getTarget(), n2);
    assertEquals(DependencyType.CREATE, dep.getDependencyType()); // still the higher dependency.
}