CircuitBreakerClient extends AbstractCircuitBreakerClient<HttpRequest, HttpResponse> implements HttpClient { public static Function<? super HttpClient, CircuitBreakerClient> newPerHostDecorator(Function<String, ? extends CircuitBreaker> factory, CircuitBreakerRule rule) { return newDecorator(CircuitBreakerMapping.perHost(factory), rule); } CircuitBreakerClient(HttpClient delegate, CircuitBreakerMapping mapping, CircuitBreakerRule rule);   CircuitBreakerClient(HttpClient delegate, CircuitBreakerMapping mapping,
                         CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent);   CircuitBreakerClient(HttpClient delegate, CircuitBreakerMapping mapping,
                         CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent, int maxContentLength); static Function<? super HttpClient, CircuitBreakerClient> newDecorator(CircuitBreaker circuitBreaker, CircuitBreakerRule rule); static Function<? super HttpClient, CircuitBreakerClient> newDecorator(CircuitBreaker circuitBreaker, CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent); static Function<? super HttpClient, CircuitBreakerClient> newDecorator(CircuitBreakerMapping mapping, CircuitBreakerRule rule); static Function<? super HttpClient, CircuitBreakerClient> newDecorator(CircuitBreakerMapping mapping, CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent); static Function<? super HttpClient, CircuitBreakerClient> newPerMethodDecorator(Function<String, ? extends CircuitBreaker> factory, CircuitBreakerRule rule); static Function<? super HttpClient, CircuitBreakerClient> newPerMethodDecorator(Function<String, ? extends CircuitBreaker> factory,
                          CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent); static Function<? super HttpClient, CircuitBreakerClient> newPerHostDecorator(Function<String, ? extends CircuitBreaker> factory, CircuitBreakerRule rule); static Function<? super HttpClient, CircuitBreakerClient> newPerHostDecorator(Function<String, ? extends CircuitBreaker> factory,
                        CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent); static Function<? super HttpClient, CircuitBreakerClient> newPerHostAndMethodDecorator(BiFunction<String, String, ? extends CircuitBreaker> factory,
                                 CircuitBreakerRule rule); static Function<? super HttpClient, CircuitBreakerClient> newPerHostAndMethodDecorator(BiFunction<String, String, ? extends CircuitBreaker> factory,
                                 CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent); static CircuitBreakerClientBuilder builder(CircuitBreakerRule rule); static CircuitBreakerClientBuilder builder(
            CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent); static CircuitBreakerClientBuilder builder(
            CircuitBreakerRuleWithContent<HttpResponse> ruleWithContent, int maxContentLength);  }
@Test void testPerHostDecorator() { final CircuitBreaker circuitBreaker = mock(CircuitBreaker.class); when(circuitBreaker.canRequest()).thenReturn(false); @SuppressWarnings("unchecked") final Function<String, CircuitBreaker> factory = mock(Function.class); when(factory.apply(any())).thenReturn(circuitBreaker); final int COUNT = 2; failFastInvocation(CircuitBreakerClient.newPerHostDecorator(factory, rule()), HttpMethod.GET, COUNT); verify(circuitBreaker, times(COUNT)).canRequest(); verify(factory, times(1)).apply("dummyhost:8080"); }