@Test
  public void storeParentChildDescendantProjectsAndRetrieveAncestry() throws Exception {
    final ProjectVersionRef r = new SimpleProjectVersionRef("org.test", "root", "1");
    final ProjectVersionRef p = new SimpleProjectVersionRef("org.test", "parent", "1.0");
    final ProjectVersionRef c = new SimpleProjectVersionRef("org.test", "child", "1.0");

    final EProjectDirectRelationships root =
        new EProjectDirectRelationships.Builder(sourceUri, r).build();
    final EProjectDirectRelationships parent =
        new EProjectDirectRelationships.Builder(sourceUri, p).withParent(r).build();
    final EProjectDirectRelationships child =
        new EProjectDirectRelationships.Builder(sourceUri, c).withParent(p).build();

    graph.storeRelationships(root.getExactAllRelationships());
    graph.storeRelationships(parent.getExactAllRelationships());
    graph.storeRelationships(child.getExactAllRelationships());

    final List<ProjectVersionRef> ancestry = CartoGraphUtils.getAncestry(c, graph);
    assertThat(ancestry, notNullValue());
    assertThat(ancestry.size(), equalTo(3));

    final Iterator<ProjectVersionRef> iterator = ancestry.iterator();
    assertThat(iterator.next(), equalTo(c));
    assertThat(iterator.next(), equalTo(p));
    assertThat(iterator.next(), equalTo(r));
  }
  @Test
  public void storeProjectWithParentAndVerifyParentRelationship() throws Exception {
    final ProjectVersionRef project =
        new SimpleProjectVersionRef("org.apache.maven", "maven-core", "3.0.3");
    final ProjectVersionRef parent =
        new SimpleProjectVersionRef("org.apache.maven", "maven", "3.0.3");

    final EProjectDirectRelationships rels =
        new EProjectDirectRelationships.Builder(sourceUri, project).withParent(parent).build();

    graph.storeRelationships(rels.getExactAllRelationships());

    final ProjectVersionRef parentResult = CartoGraphUtils.getParent(project, graph);
    assertThat(parentResult, equalTo(parent));
  }
  @Test
  public void storeProjectWithParentAndRetrieveAsChild() throws Exception {
    final ProjectVersionRef project =
        new SimpleProjectVersionRef("org.apache.maven", "maven-core", "3.0.3");
    final ProjectVersionRef parent =
        new SimpleProjectVersionRef("org.apache.maven", "maven", "3.0.3");

    final EProjectDirectRelationships rels =
        new EProjectDirectRelationships.Builder(sourceUri, project).withParent(parent).build();

    graph.storeRelationships(rels.getExactAllRelationships());

    final Set<ProjectVersionRef> children = CartoGraphUtils.getKnownChildren(parent, graph);

    assertThat(children.size(), equalTo(1));
    assertThat(children.iterator().next(), equalTo(project));
  }