CsvParser implements ICsvParser<TEntity> { public Stream<CsvMappingResult<TEntity>> readFromFile(Path path, Charset charset) { try { return parse(Files.lines(path, charset)); } catch(IOException e) { throw new RuntimeException(e); } } 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_readFromFile_PathNotFound_Throws() { 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"; try { List<CsvMappingResult<Person>> result = new ArrayList<>(); JUnitUtils.assertThrows(() -> { try (Stream<CsvMappingResult<Person>> stream = parser.readFromFile(FileSystems.getDefault().getPath("aaaa", "aaaa.txt"), StandardCharsets.UTF_8)) { stream.collect(Collectors.toList()); } }); } catch (Exception e) { Assert.assertEquals(true, false); } }