### Question:
AddRuleAnnotationClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                          VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { decisionTable.getComponentWidths().add(uiColumnIndex, null); final int clauseIndex = getClauseIndex(); decisionTable.getAnnotations().add(clauseIndex, ruleAnnotationClause); ruleAnnotationClause.getName().setValue(getName()); decisionTable.getRule().forEach(rule -> { final RuleAnnotationClauseText ruleAnnotationClauseText = new RuleAnnotationClauseText(); ruleAnnotationClauseText.getText().setValue(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_EXPRESSION_TEXT); rule.getAnnotationEntry().add(clauseIndex, ruleAnnotationClauseText); ruleAnnotationClauseText.setParent(rule); }); ruleAnnotationClause.setParent(decisionTable); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { decisionTable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = decisionTable.getAnnotations().indexOf(ruleAnnotationClause); decisionTable.getRule().forEach(rule -> rule.getAnnotationEntry().remove(clauseIndex)); decisionTable.getAnnotations().remove(ruleAnnotationClause); return GraphCommandResultBuilder.SUCCESS; } }; } AddRuleAnnotationClauseCommand(final DecisionTable decisionTable,
                                          final RuleAnnotationClause ruleAnnotationClause,
                                          final GridData uiModel,
                                          final Supplier<RuleAnnotationClauseColumn> uiModelColumnSupplier,
                                          final int uiColumnIndex,
                                          final DecisionTableUIModelMapper uiModelMapper,
                                          final org.uberfire.mvp.Command executeCanvasOperation,
                                          final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation();  }### Answer:
@Test public void testNewGraphCommandUndo() { final AbstractCanvasHandler context = mock(AbstractCanvasHandler.class); final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(context); final GraphCommandExecutionContext executionContext = mock(GraphCommandExecutionContext.class); final int ruleAnnotationIndex = 3; final DecisionRule rule1 = mock(DecisionRule.class); final DecisionRule rule2 = mock(DecisionRule.class); final List rule1AnnotationEntries = mock(List.class); final List rule2AnnotationEntries = mock(List.class); final List<DecisionRule> rules = Arrays.asList(rule1, rule2); when(rule1.getAnnotationEntry()).thenReturn(rule1AnnotationEntries); when(rule2.getAnnotationEntry()).thenReturn(rule2AnnotationEntries); when(decisionTable.getRule()).thenReturn(rules); when(annotations.indexOf(ruleAnnotationClause)).thenReturn(ruleAnnotationIndex); final CommandResult<RuleViolation> undoResult = graphCommand.undo(executionContext); verify(componentsWidths).remove(uiColumnIndex); verify(rule1AnnotationEntries).remove(ruleAnnotationIndex); verify(rule2AnnotationEntries).remove(ruleAnnotationIndex); verify(annotations).remove(ruleAnnotationClause); assertEquals(GraphCommandResultBuilder.SUCCESS, undoResult); }