### Question:
LinearFitter implements DistributionFitter { public static LinearFitter create(int numFiniteIntervals, double width, double offset) { checkArgument(numFiniteIntervals > 0, "numFiniteIntervals must be greater than 0"); checkArgument(width > 0, "width must be greater than 0"); checkDouble(offset); ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder(); for (int i = 0; i < numFiniteIntervals + 1; i++) { boundaries.add(width * i + offset); } return new AutoValue_LinearFitter(width, offset, boundaries.build()); }  static LinearFitter create(int numFiniteIntervals, double width, double offset); abstract double width(); abstract double offset(); @Override abstract ImmutableSortedSet<Double> boundaries();  }### Answer:
@Test public void testCreateLinearFitter_zeroNumIntervals_throwsException() throws Exception { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> LinearFitter.create(0, 3.0, 0.0)); assertThat(thrown).hasMessageThat().contains("numFiniteIntervals must be greater than 0"); }
@Test public void testCreateLinearFitter_negativeNumIntervals_throwsException() throws Exception { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> LinearFitter.create(0, 3.0, 0.0)); assertThat(thrown).hasMessageThat().contains("numFiniteIntervals must be greater than 0"); }
@Test public void testCreateLinearFitter_zeroWidth_throwsException() throws Exception { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> LinearFitter.create(3, 0.0, 0.0)); assertThat(thrown).hasMessageThat().contains("width must be greater than 0"); }
@Test public void testCreateLinearFitter_negativeWidth_throwsException() throws Exception { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> LinearFitter.create(3, 0.0, 0.0)); assertThat(thrown).hasMessageThat().contains("width must be greater than 0"); }
@Test public void testCreateLinearFitter_NaNWidth_throwsException() throws Exception { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> LinearFitter.create(3, Double.NaN, 0.0)); assertThat(thrown).hasMessageThat().contains("width must be greater than 0"); }
@Test public void testCreateLinearFitter_NaNOffset_throwsException() throws Exception { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> LinearFitter.create(3, 1.0, Double.NaN)); assertThat(thrown).hasMessageThat().contains("value must be finite, not NaN, and not -0.0"); }