### Question:
DefaultDataReducer implements DataReducer<X, Y> { @Override public List<Data<X, Y>> reduce(ChartData<X, Y> data, Range<Double> dataRange, int maxPointsCount) { Objects.requireNonNull(data, "List of points must not be null"); Objects.requireNonNull(dataRange, "The indexRange must not be null"); if (maxPointsCount < MIN_POINTS_COUNT) { throw new IllegalArgumentException("Max number of points must be at least " + MIN_POINTS_COUNT); } if (data.size() == 0) { return Collections.emptyList(); } return extractRemainingPoints(data, findRemainingIndices(data, toIndexRange(data, dataRange), maxPointsCount)); }  @Override List<Data<X, Y>> reduce(ChartData<X, Y> data, Range<Double> dataRange, int maxPointsCount);  }### Answer:
@Test(expected = NullPointerException.class) public void testReduceWithNullPointsList() { reducer.reduce(null, null, 3); }
@Test(expected = IllegalArgumentException.class) public void testReduceWithTargetPointsCountLessThanTwo() { reducer.reduce(new ListData<>(FXCollections.observableArrayList(asList(new Data<Number, Number>(0, 0)))), new Range<>(0., 0.), 1); }
@Test public void testReduceWithEmptyPointsList() { assertTrue(reducer.reduce(new ListData<>(FXCollections.observableArrayList(emptyList())), new Range<>(0., 0.), 3).isEmpty()); }
@Test public void testReduceWithOnePoint() { Data<Number, Number> point = new Data<>(0, 0); List<Data<Number, Number>> reduced = reducer.reduce(new ListData<>(FXCollections.observableArrayList(asList(point))), new Range<>(0., 0.), 3); assertEquals(1, reduced.size()); assertEquals(point, reduced.get(0)); }
@Test public void testArgumentListNotReturned() { List<Data<Number, Number>> points = asList(new Data<Number, Number>(0, 0)); List<Data<Number, Number>> reduced = reducer.reduce(new ListData<>(FXCollections.observableArrayList(points)), new Range<>(0., 0.), 3); assertFalse(points == reduced); }
@Test public void testReduceFlatLineWithThreePoints() { List<Data<Number, Number>> points = new ArrayList<>(); points.add(new Data<Number, Number>(0, 0)); points.add(new Data<Number, Number>(1, 0)); points.add(new Data<Number, Number>(2, 0)); List<Data<Number, Number>> reduced = reducer.reduce(new ListData<>(FXCollections.observableArrayList(points)), new Range<>(0., 2.), 2); assertEquals(2, reduced.size()); assertEquals(points.get(0), reduced.get(0)); assertEquals(points.get(2), reduced.get(1)); }