public void ensureIndexTemplate(IndexSet indexSet) {
        final IndexSetConfig indexSetConfig = indexSet.getConfig();
        final String templateName = indexSetConfig.indexTemplateName();
        try {
            var template = buildTemplate(indexSet, indexSetConfig);
            if (indicesAdapter.ensureIndexTemplate(templateName, template)) {
                LOG.info("Successfully ensured index template {}", templateName);
            } else {
                LOG.warn("Failed to create index template {}", templateName);
            }
        } catch (IgnoreIndexTemplate e) {
            LOG.warn(e.getMessage());
            if (e.isFailOnMissingTemplate() && !indicesAdapter.indexTemplateExists(templateName)) {
                throw new IndexTemplateNotFoundException(f("No index template with name '%s' (type - '%s') found in Elasticsearch",
                        templateName, indexSetConfig.indexTemplateType().orElse(null)));
            }
        }
    }
@Test
    public void ensureIndexTemplate_IfIndexTemplateExistsOnIgnoreIndexTemplate_thenNoExceptionThrown() {
        when(indexMappingFactory.createIndexMapping(any()))
                .thenThrow(new IgnoreIndexTemplate(true,
                        "Reasom", "test", "test-template", null));

        when(indicesAdapter.indexTemplateExists("test-template")).thenReturn(true);

        assertThatCode(() -> underTest.ensureIndexTemplate(
                indexSetConfig("test", "test-template", "custom")))
                .doesNotThrowAnyException();
    }