### Question:
ControlPointValidations { public static void checkAddControlPoint(final ControlPoint[] controlPoints, final ControlPoint controlPoint, final int index) { if (isControlPointIndexInvalid.test(index)) { throw new IllegalArgumentException("The given index [" + index + "] for the new CP is not valid."); } if (isAddingControlPointIndexForbidden.test(controlPoints, index)) { throw new IllegalArgumentException("Cannot add a new CP at the given index [" + index + "]."); } if (isControlPointInvalid.test(controlPoint)) { throw new IllegalArgumentException("The given CP is not valid"); } }  static void checkAddControlPoint(final ControlPoint[] controlPoints,
                                            final ControlPoint controlPoint,
                                            final int index); static void checkDeleteControlPoint(final ControlPoint[] controlPoints,
                                               final int index); static void checkUpdateControlPoint(final ControlPoint[] controlPoints1,
                                               final ControlPoint[] controlPoints2); static Predicate<Integer> isControlPointIndexInvalid; static Predicate<ControlPoint> isControlPointInvalid; static BiPredicate<ControlPoint[], Integer> isAddingControlPointIndexForbidden; static BiPredicate<ControlPoint[], Integer> isDeletingControlPointIndexForbidden; static BiPredicate<ControlPoint[], ControlPoint[]> cannotControlPointsBeUpdated; }### Answer:
@Test public void testValidCheckAddControlPoint() { ControlPoint cp = ControlPoint.build(1, 1); checkAddControlPoint(controlPoints, cp, 0); checkAddControlPoint(controlPoints, cp, 1); }
@Test(expected = IllegalArgumentException.class) public void testInvalidCheckAddControlPoint() { ControlPoint cp = ControlPoint.build(1, 1); checkAddControlPoint(controlPoints, cp, 2); }
@Test(expected = IllegalArgumentException.class) public void testInvalidCheckAddControlPoint2() { ControlPoint cp = ControlPoint.build(1, 1); checkAddControlPoint(controlPoints, cp, 3); }