@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 testGetValidatedEnrichers() {
        // create two enrichers with non-overlapping keys
        final FailureEnricher firstEnricher = new TestEnricher("key1");
        final FailureEnricher secondEnricher = new TestEnricher("key2");

        final Set<FailureEnricher> enrichers =
                new HashSet<FailureEnricher>() {
                    {
                        add(firstEnricher);
                        add(secondEnricher);
                    }
                };

        final Collection<FailureEnricher> validatedEnrichers =
                FailureEnricherUtils.filterInvalidEnrichers(enrichers);

        // expect both enrichers to be valid
        assertThat(validatedEnrichers).hasSize(2);
        assertThat(validatedEnrichers).contains(firstEnricher, secondEnricher);
    }