@Override
    public void upgrade() {
        Optional<IndexSetTemplate> defaultIndexSetTemplate = indexSetDefaultTemplateService.getDefaultIndexSetTemplate();
        if (defaultIndexSetTemplate.isEmpty()) {
            IndexSetsDefaultConfiguration legacyDefaultConfig = clusterConfigService.get(IndexSetsDefaultConfiguration.class);
            if (legacyDefaultConfig == null) {
                saveDefaultTemplate(factory.create());
            } else {
                saveDefaultTemplate(createTemplateConfig(legacyDefaultConfig));
                removeLegacyConfig();
            }
        } else {
            LOG.debug("Migration already completed.");
        }
    }
@Test
    void testDefaultConfigWithDataTiering() throws JsonProcessingException {
        when(clusterConfigService.get(IndexSetsDefaultConfiguration.class)).thenReturn(readLegacyConfig(CONFIG_WITH_DATA_TIERING));
        IndexSetTemplateConfig defaultConfiguration = readConfig(CONFIG_WITH_DATA_TIERING).toBuilder().useLegacyRotation(true).build();

        underTest.upgrade();

        verify(indexSetDefaultTemplateService).createAndSaveDefault(createTemplate(defaultConfiguration));
        verify(clusterConfigService).remove(IndexSetsDefaultConfiguration.class);
    }