CircuitBreakerRegistry createCircuitBreakerRegistry(
        CircuitBreakerConfigurationProperties circuitBreakerProperties,
        RegistryEventConsumer<CircuitBreaker> circuitBreakerRegistryEventConsumer,
        CompositeCustomizer<CircuitBreakerConfigCustomizer> compositeCircuitBreakerCustomizer) {

        Map<String, CircuitBreakerConfig> configs = circuitBreakerProperties.getConfigs()
            .entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
                entry -> circuitBreakerProperties.createCircuitBreakerConfig(entry.getKey(), entry.getValue(), compositeCircuitBreakerCustomizer)));

        return CircuitBreakerRegistry.of(configs, circuitBreakerRegistryEventConsumer, Map.copyOf(circuitBreakerProperties.getTags()));
    }
@Test
    public void testCreateCircuitBreakerRegistry() {
        InstanceProperties instanceProperties1 = new InstanceProperties();
        instanceProperties1.setSlidingWindowSize(1000);
        InstanceProperties instanceProperties2 = new InstanceProperties();
        instanceProperties2.setSlidingWindowSize(1337);
        CircuitBreakerConfigurationProperties circuitBreakerConfigurationProperties = new CircuitBreakerConfigurationProperties();
        circuitBreakerConfigurationProperties.setCircuitBreakerAspectOrder(400);
        circuitBreakerConfigurationProperties.getInstances().put("backend1", instanceProperties1);
        circuitBreakerConfigurationProperties.getInstances().put("backend2", instanceProperties2);
        CircuitBreakerConfiguration circuitBreakerConfiguration = new CircuitBreakerConfiguration(
            circuitBreakerConfigurationProperties);
        DefaultEventConsumerRegistry<CircuitBreakerEvent> eventConsumerRegistry = new DefaultEventConsumerRegistry<>();

        CircuitBreakerRegistry circuitBreakerRegistry = circuitBreakerConfiguration
            .circuitBreakerRegistry(eventConsumerRegistry,
                new CompositeRegistryEventConsumer<>(emptyList()),
                compositeCircuitBreakerCustomizerTestInstance());

        assertThat(circuitBreakerConfigurationProperties.getCircuitBreakerAspectOrder())
            .isEqualTo(400);
        assertThat(circuitBreakerRegistry.getAllCircuitBreakers().size()).isEqualTo(2);
        CircuitBreaker circuitBreaker1 = circuitBreakerRegistry.circuitBreaker("backend1");
        assertThat(circuitBreaker1).isNotNull();
        assertThat(circuitBreaker1.getCircuitBreakerConfig().getSlidingWindowSize())
            .isEqualTo(1000);
        CircuitBreaker circuitBreaker2 = circuitBreakerRegistry.circuitBreaker("backend2");
        assertThat(circuitBreaker2).isNotNull();
        assertThat(circuitBreaker2.getCircuitBreakerConfig().getSlidingWindowSize())
            .isEqualTo(1337);
        assertThat(eventConsumerRegistry.getAllEventConsumer()).hasSize(2);
    }