@VisibleForTesting
    static Collection<FailureEnricher> filterInvalidEnrichers(
            final Set<FailureEnricher> failureEnrichers) {
        final Map<String, Set<Class<?>>> enrichersByKey = new HashMap<>();
        failureEnrichers.forEach(
                enricher ->
                        enricher.getOutputKeys()
                                .forEach(
                                        enricherKey ->
                                                enrichersByKey
                                                        .computeIfAbsent(
                                                                enricherKey,
                                                                ignored -> new HashSet<>())
                                                        .add(enricher.getClass())));
        final Set<Class<?>> invalidEnrichers =
                enrichersByKey.entrySet().stream()
                        .filter(entry -> entry.getValue().size() > 1)
                        .flatMap(
                                entry -> {
                                    LOG.warn(
                                            "Following enrichers have have registered duplicate output key [%s] and will be ignored: {}.",
                                            entry.getValue().stream()
                                                    .map(Class::getName)
                                                    .collect(Collectors.joining(", ")));
                                    return entry.getValue().stream();
                                })
                        .collect(Collectors.toSet());
        return failureEnrichers.stream()
                .filter(enricher -> !invalidEnrichers.contains(enricher.getClass()))
                .collect(Collectors.toList());
    }
@Test
    public void testValidatedEnrichersWithInvalidEntries() {
        // create two enrichers with overlapping keys and a valid one -- must be different classes
        final FailureEnricher validEnricher = new TestEnricher("validKey");
        final FailureEnricher firstOverlapEnricher = new AnotherTestEnricher("key1", "key2");
        final FailureEnricher secondOverlapEnricher = new AndAnotherTestEnricher("key2", "key3");

        final Set<FailureEnricher> enrichers =
                new HashSet<FailureEnricher>() {
                    {
                        add(validEnricher);
                        add(firstOverlapEnricher);
                        add(secondOverlapEnricher);
                    }
                };

        final Collection<FailureEnricher> validatedEnrichers =
                FailureEnricherUtils.filterInvalidEnrichers(enrichers);
        // Only one enricher is valid
        assertThat(validatedEnrichers).hasSize(1);
    }