### Question:
DataUtils { public static <X extends Number, Y extends Number> int insertionIndex(ChartData<X, Y> data, double x) { int index = binarySearch(data, x); return index >= 0 ? index : -index - 1; } private  DataUtils(); static int insertionIndex(ChartData<X, Y> data, double x); static int binarySearch(ChartData<X, Y> data, double x);  }### Answer:
@Test(expected = NullPointerException.class) public void testNullList() { DataUtils.insertionIndex(null, 0); }
@Test public void testCompareNumbers() { ChartData<Number, Number> data = ArrayData.of(new int[] {0,1,2}, new int[] {0,1,2}); assertThat(DataUtils.insertionIndex(data, -1), is(0)); assertThat(DataUtils.insertionIndex(data, 0), is(0)); assertThat(DataUtils.insertionIndex(data, 1), is(1)); assertThat(DataUtils.insertionIndex(data, 1.5), is(2)); assertThat(DataUtils.insertionIndex(data, 2), is(2)); assertThat(DataUtils.insertionIndex(data, 3), is(3)); }
@Test public void testCompareListNumbers() { List<Data<Number, Number>> rawData = Arrays.asList(new Data<>(0, 0), new Data<>(1, 1), new Data<>(2, 2)); ChartData<Number, Number> data = new ListData<>(FXCollections.observableArrayList(rawData)); assertThat(DataUtils.insertionIndex(data, -1), is(0)); assertThat(DataUtils.insertionIndex(data, 0), is(0)); assertThat(DataUtils.insertionIndex(data, 1), is(1)); assertThat(DataUtils.insertionIndex(data, 1.5), is(2)); assertThat(DataUtils.insertionIndex(data, 2), is(2)); assertThat(DataUtils.insertionIndex(data, 3), is(3)); }