public Optional<Violation> validate(IndexSetConfig newConfig) {

        // Don't validate prefix conflicts in case of an update
        if (Strings.isNullOrEmpty(newConfig.id())) {
            final Violation prefixViolation = validatePrefix(newConfig);
            if (prefixViolation != null) {
                return Optional.of(prefixViolation);
            }
        }

        final Violation fieldMappingViolation = validateMappingChangesAreLegal(newConfig);
        if (fieldMappingViolation != null) {
            return Optional.of(fieldMappingViolation);
        }

        Violation refreshIntervalViolation = validateSimpleIndexSetConfig(newConfig);
        if (refreshIntervalViolation != null){
            return Optional.of(refreshIntervalViolation);
        }
        return Optional.empty();
    }
@Test
    public void validateIndexAction() {
        final String prefix = "graylog_index";
        final Duration fieldTypeRefreshInterval = Duration.standardSeconds(1L);
        final IndexSetConfig newConfig = mock(IndexSetConfig.class);
        final IndexSet indexSet = mock(IndexSet.class);
        final RetentionStrategyConfig retentionStrategyConfig = mock(RetentionStrategyConfig.class);

        when(indexSet.getIndexPrefix()).thenReturn("foo");
        when(indexSetRegistry.iterator()).thenReturn(Collections.singleton(indexSet).iterator());
        when(newConfig.indexPrefix()).thenReturn(prefix);
        when(newConfig.fieldTypeRefreshInterval()).thenReturn(fieldTypeRefreshInterval);
        when(newConfig.retentionStrategyConfig()).thenReturn(retentionStrategyConfig);

        final Optional<IndexSetValidator.Violation> violation = validator.validate(newConfig);

        assertThat(violation).isPresent();
    }