@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 healthMetricsAndConfig() {
        // given
        CircuitBreakerConfig config = mock(CircuitBreakerConfig.class);
        CircuitBreakerRegistry registry = mock(CircuitBreakerRegistry.class);
        CircuitBreaker.Metrics metrics = mock(CircuitBreaker.Metrics.class);
        CircuitBreaker circuitBreaker = mock(CircuitBreaker.class);
        CircuitBreakerConfigurationProperties.InstanceProperties instanceProperties =
            mock(CircuitBreakerConfigurationProperties.InstanceProperties.class);
        CircuitBreakerConfigurationProperties circuitBreakerProperties = mock(
            CircuitBreakerConfigurationProperties.class);
        CircuitBreakersHealthIndicator healthIndicator =
            new CircuitBreakersHealthIndicator(registry, circuitBreakerProperties, new SimpleStatusAggregator());

        //when
        when(config.getFailureRateThreshold()).thenReturn(30f);
        when(metrics.getFailureRate()).thenReturn(20f);
        when(metrics.getSlowCallRate()).thenReturn(20f);
        when(config.getSlowCallRateThreshold()).thenReturn(50f);
        when(metrics.getNumberOfBufferedCalls()).thenReturn(100);
        when(metrics.getNumberOfFailedCalls()).thenReturn(20);
        when(metrics.getNumberOfSlowCalls()).thenReturn(20);
        when(metrics.getNumberOfNotPermittedCalls()).thenReturn(0L);

        when(registry.getAllCircuitBreakers()).thenReturn(Set.of(circuitBreaker));
        when(circuitBreaker.getName()).thenReturn("test");
        when(circuitBreakerProperties.findCircuitBreakerProperties("test"))
            .thenReturn(Optional.of(instanceProperties));
        when(instanceProperties.getRegisterHealthIndicator()).thenReturn(true);
        when(instanceProperties.getAllowHealthIndicatorToFail()).thenReturn(true);
        when(circuitBreaker.getMetrics()).thenReturn(metrics);
        when(circuitBreaker.getCircuitBreakerConfig()).thenReturn(config);
        when(circuitBreaker.getState()).thenReturn(CLOSED, OPEN, HALF_OPEN, CLOSED);

        // then
        Health health = healthIndicator.health();
        then(health.getStatus()).isEqualTo(Status.UP);
        then(health.getDetails()).containsKey("test");
        then(health.getDetails().get("test")).isInstanceOf(Health.class);
        then(((Health) health.getDetails().get("test")).getDetails())
            .contains(
                entry("failureRate", "20.0%"),
                entry("slowCallRate", "20.0%"),
                entry("slowCallRateThreshold", "50.0%"),
                entry("failureRateThreshold", "30.0%"),
                entry("bufferedCalls", 100),
                entry("slowCalls", 20),
                entry("failedCalls", 20),
                entry("notPermittedCalls", 0L)
            );
    }