### Question:
NameBuilderParser { public NameBuilder getNameBuilder() { return nameBuilder; } NameBuilderParser(String expression); NameBuilder getNameBuilder();  }### Answer:
@Test void testExampleFromPDF() { Pattern pattern = Pattern.compile("slika(\\d+)-([^.]+)\\.jpg", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); NameBuilderParser nameBuilderParser = new NameBuilderParser("gradovi-${2}-${1,03}.jpg"); List<String> input = List.of( "slika1-zagreb.jpg", "slika2-zagreb.jpg", "slika3-zagreb.jpg", "slika4-zagreb.jpg", "slika1-zadar.jpg", "slika2-zadar.jpg", "slika3-zadar.jpg", "slika4-zadar.jpg" ); List<String> expectedOutput = List.of( "gradovi-zagreb-001.jpg", "gradovi-zagreb-002.jpg", "gradovi-zagreb-003.jpg", "gradovi-zagreb-004.jpg", "gradovi-zadar-001.jpg", "gradovi-zadar-002.jpg", "gradovi-zadar-003.jpg", "gradovi-zadar-004.jpg" ); List<String> actualOutput = input.stream() .map(pattern::matcher) .filter(Matcher::matches) .map(FilterResult::new) .map(fr -> { StringBuilder sb = new StringBuilder(); nameBuilderParser.getNameBuilder().execute(fr, sb); return sb.toString(); }).collect(Collectors.toList()); assertEquals(expectedOutput, actualOutput); }