### Question:
DoublePercentileAggregatorFunction implements Function<List<Double>, Double> { public Double evaluate(List<Double> data) { if (data == null || data.size() == 0) { return null; } List<Double> copy = data; if (useCopy) { copy = new ArrayList<Double>(data); } Collections.sort(copy); int rank = computeRank(data); return copy.get(rank); } DoublePercentileAggregatorFunction(double percentile);  DoublePercentileAggregatorFunction(double percentile, boolean useCopy); Double evaluate(List<Double> data); double getPercentile(); boolean isUseCopy(); @Override String toString();  }### Answer:
@Test public void testEvaluateNullEmpty() throws Exception { DoublePercentileAggregatorFunction fct = (DoublePercentileAggregatorFunction) makeFunctor(); List<Double> data = null; Double d = fct.evaluate(data); assertNull(d); data = new ArrayList<Double>(); d = fct.evaluate(data); assertNull(d); }
@Test public void testEvaluateNoCopy() throws Exception { DoublePercentileAggregatorFunction fct = (DoublePercentileAggregatorFunction) makeFunctor(); List<Double> data = new ArrayList<Double>(); data.add(4.0); data.add(3.0); data.add(2.0); data.add(1.0); data.add(0.0); Double d = fct.evaluate(data); assertEquals(d, 3.0, DELTA); assertEquals(data.get(0), 4.0, DELTA); assertEquals(data.get(1), 3.0, DELTA); assertEquals(data.get(2), 2.0, DELTA); assertEquals(data.get(3), 1.0, DELTA); assertEquals(data.get(4), 0.0, DELTA); fct = new DoublePercentileAggregatorFunction(DEF_PERC, true); d = fct.evaluate(data); assertEquals(d, 3.0, DELTA); assertEquals(data.get(0), 4.0, DELTA); assertEquals(data.get(1), 3.0, DELTA); assertEquals(data.get(2), 2.0, DELTA); assertEquals(data.get(3), 1.0, DELTA); assertEquals(data.get(4), 0.0, DELTA); fct = new DoublePercentileAggregatorFunction(DEF_PERC, false); d = fct.evaluate(data); assertEquals(d, 3.0, DELTA); assertEquals(data.get(4), 4.0, DELTA); assertEquals(data.get(3), 3.0, DELTA); assertEquals(data.get(2), 2.0, DELTA); assertEquals(data.get(1), 1.0, DELTA); assertEquals(data.get(0), 0.0, DELTA); }