### Question:
DoubleSumAggregatorFunction implements Function<List<Double>, Double> { public Double evaluate(List<Double> data) { if (data == null || data.size() == 0) { return null; } double sum = 0.0; for (Double d : data) { sum += d; } return sum; }  Double evaluate(List<Double> data); @Override String toString();  }### Answer:
@Test public void testEmptyList() throws Exception { DoubleSumAggregatorFunction fct = (DoubleSumAggregatorFunction) makeFunctor(); List<Double> lst = null; Double res = fct.evaluate(lst); assertNull(res); lst = new ArrayList<Double>(); res = fct.evaluate(lst); assertNull(res); }
@Test public void testSum() throws Exception { DoubleSumAggregatorFunction fct = (DoubleSumAggregatorFunction) makeFunctor(); List<Double> lst = new ArrayList<Double>(); lst.add(0.0); double res = fct.evaluate(lst); assertEquals(res, 0.0, 0.01); lst.add(1.0); res = fct.evaluate(lst); assertEquals(res, 1.0, 0.01); lst.add(2.0); res = fct.evaluate(lst); assertEquals(res, 3.0, 0.01); lst.clear(); int calls = 31; double total = 0.0; Random rnd = new Random(); for (int i = 0; i < calls; i++) { double random = rnd.nextDouble(); lst.add(random); total += random; res = fct.evaluate(lst); assertEquals(res, total, 0.01); } }