### Question:
AddControlPointCommand extends AbstractControlPointCommand { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { checkAddControlPoint(getEdgeControlPoints(context).getControlPoints(), controlPoint, index); return GraphCommandResultBuilder.SUCCESS; } AddControlPointCommand(final @MapsTo("edgeUUID") String edgeUUID,
                                  final @MapsTo("controlPoint") ControlPoint controlPoint,
                                  final @MapsTo("index") int index); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context);  }### Answer:
@Test public void testCheck() { tested = new AddControlPointCommand(EDGE_UUID, newControlPoint, 0); CommandResult<RuleViolation> result = tested.check(graphCommandExecutionContext); assertFalse(CommandUtils.isError(result)); tested = new AddControlPointCommand(EDGE_UUID, newControlPoint, 1); result = tested.check(graphCommandExecutionContext); assertFalse(CommandUtils.isError(result)); tested = new AddControlPointCommand(EDGE_UUID, newControlPoint, 2); result = tested.check(graphCommandExecutionContext); assertFalse(CommandUtils.isError(result)); tested = new AddControlPointCommand(EDGE_UUID, newControlPoint, 3); result = tested.check(graphCommandExecutionContext); assertFalse(CommandUtils.isError(result)); }
@Test(expected = IllegalArgumentException.class) public void testInvalidIndex() { tested = new AddControlPointCommand(EDGE_UUID, newControlPoint, -1); tested.check(graphCommandExecutionContext); }
@Test(expected = IllegalArgumentException.class) public void testInvalidCPIndex() { tested = new AddControlPointCommand(EDGE_UUID, newControlPoint, 4); tested.check(graphCommandExecutionContext); }
@Test(expected = IllegalArgumentException.class) public void testInvalidCP() { tested = new AddControlPointCommand(EDGE_UUID, newControlPoint, 2); newControlPoint.setLocation(null); tested.check(graphCommandExecutionContext); }