@VisibleForTesting
    static String generateFile(Set<QualifiedVersion> versionsSet, String template) throws IOException {
        final Set<QualifiedVersion> versions = new TreeSet<>(reverseOrder());

        // For the purpose of generating the index, snapshot versions are the same as released versions. Prerelease versions are not.
        versionsSet.stream().map(v -> v.isSnapshot() ? v.withoutQualifier() : v).forEach(versions::add);

        final List<String> includeVersions = versions.stream().map(QualifiedVersion::toString).collect(Collectors.toList());

        final Map<String, Object> bindings = new HashMap<>();
        bindings.put("versions", versions);
        bindings.put("includeVersions", includeVersions);

        return TemplateUtils.render(template, bindings);
    }
@Test
    public void generateFile_rendersCorrectMarkup() throws Exception {
        // given:
        final Set<QualifiedVersion> versions = Stream.of(
            "8.0.0-alpha1",
            "8.0.0-beta2",
            "8.0.0-rc3",
            "8.0.0",
            "8.0.1",
            "8.0.2",
            "8.1.0",
            "8.1.1",
            "8.2.0-SNAPSHOT"
        ).map(QualifiedVersion::of).collect(Collectors.toSet());

        final String template = getResource("/templates/release-notes-index.asciidoc");
        final String expectedOutput = getResource(
            "/org/elasticsearch/gradle/internal/release/ReleaseNotesIndexGeneratorTest.generateFile.asciidoc"
        );

        // when:
        final String actualOutput = ReleaseNotesIndexGenerator.generateFile(versions, template);

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