### Question:
PdfListParser implements Function<Path, List<File>> { @Override public List<File> apply(Path listFile) { if (isNull(listFile)) { return Collections.emptyList(); } try { return Files.lines(listFile).filter(StringUtils::isNoneBlank).map(s -> { String[] items = s.split(","); if (items.length > 0) { return items[0]; } return ""; }).filter(s -> s.toUpperCase().endsWith("PDF")).map(Paths::get).filter(Files::exists) .filter(not(Files::isDirectory)).map(Path::toFile).collect(toList()); } catch (IOException e) { throw new RuntimeException(e); } }  @Override List<File> apply(Path listFile);  }### Answer:
@Test public void nullInput() { assertTrue(new PdfListParser().apply(null).isEmpty()); }
@Test public void apply() throws IOException { File file1 = tmp.newFile("file1.pdf"); File file2 = tmp.newFile("file2.PDF"); File file3 = tmp.newFile("file3.pdf"); Path list = tmp.newFile().toPath(); List<String> lines = new ArrayList<>(); lines.add(file1.getAbsolutePath()); lines.add("I don't exist"); lines.add(" "); lines.add(file2.getAbsolutePath() + ","); lines.add(file3.getAbsolutePath() + ",something,something else"); lines.add(tmp.newFile("file3.txt").getAbsolutePath()); lines.add(tmp.newFolder().getAbsolutePath()); Files.write(list, lines); List<File> parsed = new PdfListParser().apply(list); assertEquals(3, parsed.size()); assertThat(parsed, hasItems(file1, file2, file3)); }