### Question:
PercentileCalculator implements Function<double[], Double> { @Override public Double apply(double[] x) { ArgChecker.notNull(x, "x"); ArgChecker.isTrue(x.length > 0, "x cannot be empty"); int length = x.length; double[] copy = Arrays.copyOf(x, length); Arrays.sort(copy); double n = _percentile * (length - 1) + 1; if (Math.round(n) == 1) { return copy[0]; } if (Math.round(n) == length) { return copy[length - 1]; } double d = n % 1; int k = (int) Math.round(n - d); return copy[k - 1] + d * (copy[k] - copy[k - 1]); } PercentileCalculator(double percentile); void setPercentile(double percentile); @Override Double apply(double[] x);  }### Answer:
@Test public void testNullArray() { assertThatIllegalArgumentException() .isThrownBy(() -> CALCULATOR.apply((double[]) null)); }
@Test public void testEmptyArray() { assertThatIllegalArgumentException() .isThrownBy(() -> CALCULATOR.apply(new double[0])); }