PartialHealthCheckStrategyBuilder { PartialHealthCheckStrategy build() { final EndpointLimitingFunction endpointLimitingFunction; if (maxEndpointCount != null) { endpointLimitingFunction = EndpointLimitingFunction.ofCount(maxEndpointCount); } else if (maxEndpointRatio != null) { endpointLimitingFunction = EndpointLimitingFunction.ofRatio(maxEndpointRatio); } else { throw new IllegalStateException("The maximum endpoint count or ratio must be set."); } return new PartialHealthCheckStrategy(endpointLimitingFunction); }    }
@Test void buildWhenMaximumIsNotSet() { assertThrows(IllegalStateException.class, () -> builder.build()); }
@Test void build() { builder.maxEndpointRatio(MAX_RATIO); final PartialHealthCheckStrategy actualStrategy = builder.build(); actualStrategy.updateCandidates(createCandidates(10)); assertThat(actualStrategy.getSelectedEndpoints()).hasSize(7); actualStrategy.updateCandidates(createCandidates(20)); assertThat(actualStrategy.getSelectedEndpoints()).hasSize(14); }