@Test
public void writeRelationship() throws Exception {

    String metadataId = BdioObject.randomId();
    ZonedDateTime creationDateTime = ZonedDateTime.now(ZoneId.systemDefault());
    graph.addVertex(
            T.label, TT.Metadata,
            TT.id, metadataId,
            Bdio.DataProperty.creationDateTime.name(), creationDateTime.toString());
    String fileId = BdioObject.randomId();
    Vertex file = graph.addVertex(
            T.label, Bdio.Class.File.name(),
            TT.id, fileId);
    String projectId = BdioObject.randomId();
    graph.addVertex(
            T.label, Bdio.Class.Project.name(),
            TT.id, projectId)
            .addEdge(Bdio.ObjectProperty.base.name(), file);
    commit();
    HeapOutputStream outputStream = new HeapOutputStream();
    graph.io(testBdio(TT.Metadata, TT.id)).writeGraph(new BdioFile(outputStream));
    List<String> entries = BdioTest.zipEntries(outputStream.getInputStream());
    assertThat(entries).hasSize(2);
    assertThatJson(entries.get(0)).at("/@id").isEqualTo(metadataId);
    assertThatJson(entries.get(0)).at(Bdio.DataProperty.creationDateTime, 0, "@value").isEqualTo(creationDateTime.toString());
    assertThatJson(entries.get(0)).arrayAt("/@graph").hasSize(0);
    assertThatJson(entries.get(1)).at("/@id").isEqualTo(metadataId);
    assertThatJson(entries.get(1)).arrayAt("/@graph").hasSize(2);
    int projectIndex = BdioTest.nodeIdentifiers(entries.get(1)).indexOf(projectId);
    assertThat(projectIndex).isAtLeast(0);
    assertThatJson(entries.get(1)).at("@graph", projectIndex, Bdio.ObjectProperty.base, 0, "@id").isEqualTo(fileId);
}