SearchCoverage { public Double getMaxWaitAfterCoverageFactor() { return maxWaitAfterCoverageFactor; } private  SearchCoverage(Builder builder); Double getMinimum(); Double getMinWaitAfterCoverageFactor(); Double getMaxWaitAfterCoverageFactor();  }
@Test public void requireThatInvalidMaxWaitAfterCoverageFactorCanNotBeSet() { SearchCoverage.Builder coverage = new SearchCoverage.Builder(); coverage.setMaxWaitAfterCoverageFactor(0.5); assertEquals(0.5, coverage.build().getMaxWaitAfterCoverageFactor(), 1E-6); try { coverage.setMaxWaitAfterCoverageFactor(-0.5); fail(); } catch (IllegalArgumentException e) { assertEquals("Expected value in range [0, 1], got -0.5.", e.getMessage()); } assertEquals(0.5, coverage.build().getMaxWaitAfterCoverageFactor(), 1E-6); try { coverage.setMaxWaitAfterCoverageFactor(1.5); fail(); } catch (IllegalArgumentException e) { assertEquals("Expected value in range [0, 1], got 1.5.", e.getMessage()); } assertEquals(0.5, coverage.build().getMaxWaitAfterCoverageFactor(), 1E-6); }
@Test public void requireThatMaxWaitCanNotBeSetSmallerThanMaxWait() { SearchCoverage.Builder coverage = new SearchCoverage.Builder(); coverage.setMinWaitAfterCoverageFactor(0.5); coverage.setMaxWaitAfterCoverageFactor(0.6); assertEquals(0.6, coverage.build().getMaxWaitAfterCoverageFactor(), 1E-6); coverage.setMaxWaitAfterCoverageFactor(0.5); assertEquals(0.5, coverage.build().getMaxWaitAfterCoverageFactor(), 1E-6); try { coverage.setMaxWaitAfterCoverageFactor(0.4); fail(); } catch (IllegalArgumentException e) { assertEquals("Maximum wait (got 0.4) must be no smaller than minimum wait (was 0.5).", e.getMessage()); } assertEquals(0.5, coverage.build().getMaxWaitAfterCoverageFactor(), 1E-6); }