BdioWriter implements Closeable { public void start() throws IOException { checkState(started.compareAndSet(false, true), "already started"); out = entryStreams.newStream(); Writer writer = new OutputStreamWriter(out, UTF_8); JsonUtils.writePrettyPrint(writer, metadata.asNamedGraph()); writer.flush(); } BdioWriter(BdioMetadata metadata, StreamSupplier entryStreams); void start(); void next(Map<String, Object> node); @Override void close(); void closeEntry();  }
@Test(expected = IllegalStateException.class) public void doubleStart() throws IOException { try (BdioWriter writer = new BdioWriter(metadata, NULL_STREAM_SUPPLIER)) { writer.start(); writer.start(); } }
@Test public void noNextCalls() throws IOException { HeapOutputStream buffer = new HeapOutputStream(); try (BdioWriter writer = new BdioWriter(metadata, new BdioFile(buffer))) { writer.start(); } List<String> entries = BdioTest.zipEntries(buffer.getInputStream()); assertThat(entries).hasSize(1); assertThatJson(entries.get(0)).at("/@id").isEqualTo(metadata.id()); assertThatJson(entries.get(0)).arrayAt("/@graph").hasSize(0); }