StringListStreamConverter implements InputStreamConverter<List<String>> { @Override public List<String> readStream(InputStream inputStream) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); List<String> stringList = reader.lines().collect(Collectors.toList()); reader.close(); return stringList; }  @Override List<String> readStream(InputStream inputStream);  }
@Test public void shouldReadStreamAsNewlineSeparatedStrings() throws IOException { StringListStreamConverter converter = new StringListStreamConverter(); String originalString = "abc\ndef"; InputStream stringStream = new ByteArrayInputStream(originalString.getBytes()); assertEquals(Arrays.asList("abc", "def"), converter.readStream(stringStream)); }