@VisibleForTesting
    static String generateFile(QualifiedVersion version, String template, List<ChangelogEntry> entries) throws IOException {
        final List<String> priorVersions = new ArrayList<>();

        if (version.minor() > 0) {
            final int major = version.major();
            for (int minor = version.minor() - 1; minor >= 0; minor--) {
                String majorMinor = major + "." + minor;
                priorVersions.add("{ref-bare}/" + majorMinor + "/release-highlights.html[" + majorMinor + "]");
            }
        }

        final Map<Boolean, List<ChangelogEntry.Highlight>> groupedHighlights = entries.stream()
            .map(ChangelogEntry::getHighlight)
            .filter(Objects::nonNull)
            .sorted(Comparator.comparingInt(ChangelogEntry.Highlight::getPr))
            .collect(Collectors.groupingBy(ChangelogEntry.Highlight::isNotable, Collectors.toList()));

        final List<ChangelogEntry.Highlight> notableHighlights = groupedHighlights.getOrDefault(true, List.of());
        final List<ChangelogEntry.Highlight> nonNotableHighlights = groupedHighlights.getOrDefault(false, List.of());

        final Map<String, Object> bindings = new HashMap<>();
        bindings.put("priorVersions", priorVersions);
        bindings.put("notableHighlights", notableHighlights);
        bindings.put("nonNotableHighlights", nonNotableHighlights);

        return TemplateUtils.render(template, bindings);
    }
@Test
    public void generateFile_rendersCorrectMarkup() throws Exception {
        // given:
        final String template = getResource("/templates/release-highlights.asciidoc");
        final String expectedOutput = getResource(
            "/org/elasticsearch/gradle/internal/release/ReleaseHighlightsGeneratorTest.generateFile.asciidoc"
        );

        final List<ChangelogEntry> entries = getEntries();

        // when:
        final String actualOutput = ReleaseHighlightsGenerator.generateFile(QualifiedVersion.of("8.4.0-SNAPSHOT"), template, entries);

        // then:
        assertThat(actualOutput, equalTo(expectedOutput));
    }