### Question:
DeleteCanvasConnectorCommand extends AbstractCanvasCommand { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { if (!checkShapeNotNull(context, candidate.getUUID())) { return buildResult(); } context.deregister(candidate); final Node source = candidate.getSourceNode(); if (null != source) { context.notifyCanvasElementUpdated(source); } final Node target = candidate.getTargetNode(); if (null != target) { context.notifyCanvasElementUpdated(target); } return buildResult(); } DeleteCanvasConnectorCommand(final Edge candidate); @Override CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); Edge getCandidate(); @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)).deregister(eq(candidate)); verify(canvasHandler, times(1)).notifyCanvasElementUpdated(eq(source)); verify(canvasHandler, times(1)).notifyCanvasElementUpdated(eq(target)); }
@Test @SuppressWarnings("unchecked") public void testExecuteNullSourceNode() { when(candidate.getSourceNode()).thenReturn(null); final CommandResult<CanvasViolation> result = tested.execute(canvasHandler); assertNotEquals(CommandResult.Type.ERROR, result.getType()); verify(canvasHandler, times(1)).deregister(eq(candidate)); verify(canvasHandler, never()).notifyCanvasElementUpdated(eq(source)); verify(canvasHandler, times(1)).notifyCanvasElementUpdated(eq(target)); }
@Test @SuppressWarnings("unchecked") public void testExecuteNullTargetNode() { when(candidate.getTargetNode()).thenReturn(null); final CommandResult<CanvasViolation> result = tested.execute(canvasHandler); assertNotEquals(CommandResult.Type.ERROR, result.getType()); verify(canvasHandler, times(1)).deregister(eq(candidate)); verify(canvasHandler, times(1)).notifyCanvasElementUpdated(eq(source)); verify(canvasHandler, never()).notifyCanvasElementUpdated(eq(target)); }
@Test public void testExecuteNullShape() { when(canvas.getShape(EDGE_ID)).thenReturn(null); assertFalse(CommandUtils.isError(tested.execute(canvasHandler))); verify(canvasHandler, never()).deregister(eq(candidate)); }