### Question:
AddCanvasControlPointCommand extends AbstractCanvasCommand { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { allow(context); consumeControlPoints(context, candidate, view -> view.addControlPoint(controlPoint, index)); return buildResult(); } AddCanvasControlPointCommand(final Edge candidate,
                                        final ControlPoint controlPoint,
                                        final int index); @Override CommandResult<CanvasViolation> allow(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(AbstractCanvasHandler context); ControlPoint getControlPoint(); int getIndex(); static ControlPoint[] getControlPoints(final Edge edge); static void consumeControlPoints(final AbstractCanvasHandler context,
                                            final Edge edge,
                                            final Consumer<HasManageableControlPoints> consumer); static HasManageableControlPoints<?> getManageableControlPoints(final AbstractCanvasHandler context,
                                                                           final Edge candidate); static ControlPoint[] getViewControlPoints(final AbstractCanvasHandler context,
                                                      final Edge candidate); @Override String toString();  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testInvalidCPIndexDuringExecute() { tested = new AddCanvasControlPointCommand(edge, newControlPoint, 4); tested.execute(canvasHandler); }
@Test(expected = IllegalArgumentException.class) public void testInvalidCPDuringExecute() { tested = new AddCanvasControlPointCommand(edge, newControlPoint, 2); newControlPoint.setLocation(null); tested.execute(canvasHandler); }
@Test public void execute() { checkExecution(true); }