### Question:
TemplatePattern { public String extractTemplateName(String str) { return templatePrefixes.stream() .filter(str::startsWith) .map(prefix -> str.replaceFirst(prefix, "")) .map(key -> key.split("\\.")[0]) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Incorrect template " + str)); }  static TemplatePattern defaultPattern(); boolean startsWithTemplatePrefix(String key); String extractTemplateType(String str); String extractTemplateName(String str); static final Pattern DEFAULT_PATTERN; }### Answer:
@Test void extractTemplateName() { assertEquals("logback", templatePattern.extractTemplateName(microTemplate)); assertEquals("t2", templatePattern.extractTemplateName(mgmtTemplate)); assertThrows(IllegalArgumentException.class, () -> templatePattern.extractTemplateName("bad")); }