@Override
    public Health health() {
        Map<String, Health> healths = circuitBreakerRegistry.getAllCircuitBreakers().stream()
            .filter(this::isRegisterHealthIndicator)
            .collect(Collectors.toMap(CircuitBreaker::getName,
                this::mapBackendMonitorState));

        Status status = this.statusAggregator.getAggregateStatus(healths.values().stream().map(Health::getStatus).collect(Collectors.toSet()));
        return Health.status(status).withDetails(healths).build();
    }
@Test
    public void testHealthStatus() {
        CircuitBreaker openCircuitBreaker = mock(CircuitBreaker.class);
        CircuitBreaker halfOpenCircuitBreaker = mock(CircuitBreaker.class);
        CircuitBreaker closeCircuitBreaker = mock(CircuitBreaker.class);

        Map<CircuitBreaker.State, CircuitBreaker> expectedStateToCircuitBreaker = new HashMap<>();
        expectedStateToCircuitBreaker.put(OPEN, openCircuitBreaker);
        expectedStateToCircuitBreaker.put(HALF_OPEN, halfOpenCircuitBreaker);
        expectedStateToCircuitBreaker.put(CLOSED, closeCircuitBreaker);
        CircuitBreakerConfigurationProperties.InstanceProperties instanceProperties =
            mock(CircuitBreakerConfigurationProperties.InstanceProperties.class);
        CircuitBreakerConfigurationProperties circuitBreakerProperties = mock(
            CircuitBreakerConfigurationProperties.class);

        // given
        CircuitBreakerRegistry registry = mock(CircuitBreakerRegistry.class);
        CircuitBreakerConfig config = mock(CircuitBreakerConfig.class);
        CircuitBreaker.Metrics metrics = mock(CircuitBreaker.Metrics.class);

        // when
        when(registry.getAllCircuitBreakers()).thenReturn(new HashSet<>(expectedStateToCircuitBreaker.values()));
        boolean allowHealthIndicatorToFail = true;
        expectedStateToCircuitBreaker.forEach(
            (state, circuitBreaker) -> setCircuitBreakerWhen(state, circuitBreaker, config, metrics, instanceProperties, circuitBreakerProperties, allowHealthIndicatorToFail));

        CircuitBreakersHealthIndicator healthIndicator =
            new CircuitBreakersHealthIndicator(registry, circuitBreakerProperties, new SimpleStatusAggregator());

        // then
        Health health = healthIndicator.health();

        then(health.getStatus()).isEqualTo(Status.DOWN);
        then(health.getDetails()).containsKeys(OPEN.name(), HALF_OPEN.name(), CLOSED.name());

        assertState(OPEN, Status.DOWN, health.getDetails());
        assertState(HALF_OPEN, new Status("CIRCUIT_HALF_OPEN"), health.getDetails());
        assertState(CLOSED, Status.UP, health.getDetails());

    }