CircuitBreakerBuilder { public CircuitBreakerBuilder failureRateThreshold(double failureRateThreshold) { if (failureRateThreshold <= 0 || 1 < failureRateThreshold) { throw new IllegalArgumentException( "failureRateThreshold: " + failureRateThreshold + " (expected: > 0 and <= 1)"); } this.failureRateThreshold = failureRateThreshold; return this; } CircuitBreakerBuilder(String name);   CircuitBreakerBuilder(); CircuitBreakerBuilder failureRateThreshold(double failureRateThreshold); CircuitBreakerBuilder minimumRequestThreshold(long minimumRequestThreshold); CircuitBreakerBuilder trialRequestInterval(Duration trialRequestInterval); CircuitBreakerBuilder trialRequestIntervalMillis(long trialRequestIntervalMillis); CircuitBreakerBuilder circuitOpenWindow(Duration circuitOpenWindow); CircuitBreakerBuilder circuitOpenWindowMillis(long circuitOpenWindowMillis); CircuitBreakerBuilder counterSlidingWindow(Duration counterSlidingWindow); CircuitBreakerBuilder counterSlidingWindowMillis(long counterSlidingWindowMillis); CircuitBreakerBuilder counterUpdateInterval(Duration counterUpdateInterval); CircuitBreakerBuilder counterUpdateIntervalMillis(long counterUpdateIntervalMillis); CircuitBreakerBuilder listener(CircuitBreakerListener listener); CircuitBreaker build();  }
@Test void testFailureRateThreshold() { assertThat(confOf(builder().failureRateThreshold(0.123).build()).failureRateThreshold()) .isEqualTo(0.123); assertThat(confOf(builder().failureRateThreshold(1).build()).failureRateThreshold()) .isEqualTo(1.0); }
@Test void testFailureRateThresholdWithInvalidArgument() { assertThatThrownBy(() -> builder().failureRateThreshold(0)) .isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> builder().failureRateThreshold(-1)) .isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> builder().failureRateThreshold(1.1)) .isInstanceOf(IllegalArgumentException.class); }