### Question:
AddCanvasConnectorCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { context.register(shapeSetId, candidate); if (candidate.getContent() instanceof ViewConnector) { final HasManageableControlPoints<?> view = (HasManageableControlPoints<?>) ShapeUtils.getConnectorShape(candidate, context).getShapeView(); final ControlPoint[] controlPoints = ((ViewConnector) candidate.getContent()).getControlPoints(); if (null != controlPoints) { for (int i = 0; i < controlPoints.length; i++) { view.addControlPoint(controlPoints[i], i); } } } applyConnections(candidate, context, MutationContext.STATIC); context.applyElementMutation(candidate, MutationContext.STATIC); final Node source = candidate.getSourceNode(); if (null != source) { context.notifyCanvasElementUpdated(source); } return buildResult(); } AddCanvasConnectorCommand(final Edge candidate,
                                     final String shapeSetId); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); Edge getCandidate(); String getShapeSetId(); @Override String toString();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testExecute() { final CommandResult<CanvasViolation> result = tested.execute(canvasHandler); assertNotEquals(CommandResult.Type.ERROR, result.getType()); verify(canvasHandler, times(1)).register(eq(SHAPE_SET_ID), eq(candidate)); verify(canvasHandler, times(1)).applyElementMutation(eq(candidate), any(MutationContext.class)); verify(canvasHandler, times(1)).notifyCanvasElementUpdated(eq(source)); verify(candidateShape, times(1)).applyConnections(eq(candidate), eq(sourceShapeView), any(ShapeView.class), any(MutationContext.class)); }