EdgeListStreamWriter implements AutoCloseable { public void writeAll() throws IOException { while (inputStream.hasNextEdge()) { writeNextEdge(); } outputWriter.flush(); } EdgeListStreamWriter(EdgeListStream inputStream, OutputStream outputStream); void writeAll(); @Override void close();  }
@Test public void testWriteAllOnMockEdgeListStream() throws IOException { EdgeListStream edgeListStream = new MockEdgeListStream(edges); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try (EdgeListStreamWriter writer = new EdgeListStreamWriter(edgeListStream, outputStream)) { writer.writeAll(); assertEquals("Output of EdgeListStreamWriter is correct", expectedOutput, outputStream.toString()); } }