### Question:
DeleteDecisionRuleCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                     VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { dtable.getRule().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { dtable.getRule().add(uiRowIndex, oldRule); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteDecisionRuleCommand(final DecisionTable dtable,
                                     final GridData uiModel,
                                     final int uiRowIndex,
                                     final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation();  }### Answer:
@Test public void testGraphCommandAllow() throws Exception { makeCommand(0); final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler); assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.allow(graphCommandExecutionContext)); }
@Test public void testGraphCommandCheck() throws Exception { makeCommand(0); final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler); assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.allow(graphCommandExecutionContext)); }
@Test public void testGraphCommandExecute() { makeCommand(0); final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler); assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext)); assertEquals(0, dtable.getRule().size()); }
@Test public void testGraphCommandExecuteRemoveFromMiddle() throws Exception { final DecisionRule firstRule = mock(DecisionRule.class); final DecisionRule lastRule = mock(DecisionRule.class); dtable.getRule().add(0, firstRule); dtable.getRule().add(lastRule); uiModel.appendRow(new BaseGridRow()); uiModel.appendRow(new BaseGridRow()); makeCommand(1); assertEquals(3, dtable.getRule().size()); final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler); assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext)); assertEquals(2, dtable.getRule().size()); assertEquals(firstRule, dtable.getRule().get(0)); assertEquals(lastRule, dtable.getRule().get(1)); }
@Test public void testGraphCommandExecuteAndThenUndo() { makeCommand(0); final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler); graphCommand.execute(graphCommandExecutionContext); assertEquals(0, dtable.getRule().size()); assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.undo(graphCommandExecutionContext)); assertEquals(1, dtable.getRule().size()); assertEquals(rule, dtable.getRule().get(0)); }