CsvParser implements ICsvParser<TEntity> { public Stream<CsvMappingResult<TEntity>> readFromString(String csvData, CsvReaderOptions options) { return parse(Arrays.asList(csvData.split(options.getNewLine()))); } CsvParser(CsvParserOptions options, CsvMapping<TEntity> mapping); @Override Stream<CsvMappingResult<TEntity>> parse(Stream<String> stream); Stream<CsvMappingResult<TEntity>> parse(Iterable<String> csvData); Stream<CsvMappingResult<TEntity>> readFromFile(Path path, Charset charset); Stream<CsvMappingResult<TEntity>> readFromString(String csvData, CsvReaderOptions options); @Override String toString();  }
@Test public void testParse_ReadFromString() throws Exception { CsvParserOptions options = new CsvParserOptions(false, ","); PersonMapping mapping = new PersonMapping(() -> new Person()); CsvParser<Person> parser = new CsvParser<>(options, mapping); String lineSeparator = System.getProperty("line.separator"); String csvData = "Philipp,Wagner,1986-05-12" + lineSeparator + "Max,Musterman,2000-01-07"; List<CsvMappingResult<Person>> result = parser.readFromString(csvData, new CsvReaderOptions(lineSeparator)) .collect(Collectors.toList()); Assert.assertNotNull(result); Assert.assertEquals(2, result.size()); Person person0 = result.get(0).getResult(); Assert.assertEquals("Philipp", person0.firstName); Assert.assertEquals("Wagner", person0.lastName); Assert.assertEquals(1986, person0.getBirthDate().getYear()); Assert.assertEquals(5, person0.getBirthDate().getMonthValue()); Assert.assertEquals(12, person0.getBirthDate().getDayOfMonth()); Person person1 = result.get(1).getResult(); Assert.assertEquals("Max", person1.firstName); Assert.assertEquals("Musterman", person1.lastName); Assert.assertEquals(2000, person1.getBirthDate().getYear()); Assert.assertEquals(1, person1.getBirthDate().getMonthValue()); Assert.assertEquals(7, person1.getBirthDate().getDayOfMonth()); }