### Question:
SetKindCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                          VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) { if (!editor.isPresent()) { editor = editorSupplier.get(); } final ExpressionCellValue value = new ExpressionCellValue(editor); final GridData gridData = cellTuple.getGridWidget().getModel(); gridData.setCellValue(cellTuple.getRowIndex(), cellTuple.getColumnIndex(), value); executeCanvasOperation.execute(editor); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { if (oldCellValue.isPresent()) { cellTuple.getGridWidget().getModel().setCellValue(cellTuple.getRowIndex(), cellTuple.getColumnIndex(), oldCellValue.get()); } else { cellTuple.getGridWidget().getModel().deleteCell(cellTuple.getRowIndex(), cellTuple.getColumnIndex()); } undoCanvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } SetKindCommand(final GridCellTuple cellTuple,
                          final FunctionDefinition function,
                          final FunctionDefinition.Kind kind,
                          final Optional<Expression> expression,
                          final ParameterizedCommand<Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>>> executeCanvasOperation,
                          final org.uberfire.mvp.Command undoCanvasOperation,
                          final Supplier<Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>>> editorSupplier);   }### Answer:
@Test public void testCanvasCommandAllow() { setupCommand(); final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.allow(handler)); }
@Test public void testCanvasCommandExecute() { setupCommand(); final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.execute(handler)); assertEquals(newEditor, ((ExpressionCellValue) uiModel.getCell(0, 0).getValue()).getValue().get()); verify(executeCanvasOperation).execute(Optional.of(newEditor)); }
@Test public void testCanvasCommandUndo() { setupCommand(); final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.execute(handler)); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.undo(handler)); assertEquals(originalEditor, ((ExpressionCellValue) uiModel.getCell(0, 0).getValue()).getValue().get()); verify(undoCanvasOperation).execute(); }