### Question:
AddListRowCommand 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) { list.getExpression().add(uiRowIndex, hasExpression); hasExpression.asDMNModelInstrumentedBase().setParent(list); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { list.getExpression().remove(uiRowIndex); hasExpression.asDMNModelInstrumentedBase().setParent(null); return GraphCommandResultBuilder.SUCCESS; } }; } AddListRowCommand(final List list,
                             final HasExpression hasExpression,
                             final GridData uiModel,
                             final GridRow uiModelRow,
                             final int uiRowIndex,
                             final ListUIModelMapper uiModelMapper,
                             final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation();  }### Answer:
@Test public void testGraphCommandAllow() { makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); }
@Test public void testGraphCommandExecute() { makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(1, list.getExpression().size()); assertEquals(hasExpression, list.getExpression().get(0)); assertEquals(list, hasExpression.asDMNModelInstrumentedBase().getParent()); }
@Test public void testGraphCommandExecuteMultipleEntriesPresent() { final HasExpression firstEntry = HasExpression.wrap(list, new LiteralExpression()); list.getExpression().add(0, firstEntry); makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(2, list.getExpression().size()); assertEquals(firstEntry, list.getExpression().get(0)); assertEquals(hasExpression, list.getExpression().get(1)); assertEquals(list, hasExpression.asDMNModelInstrumentedBase().getParent()); }
@Test public void testGraphCommandUndo() { makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(0, list.getExpression().size()); assertNull(hasExpression.asDMNModelInstrumentedBase().getParent()); }
@Test public void testGraphCommandUndoMultipleEntriesPresent() { final HasExpression firstEntry = HasExpression.wrap(list, new LiteralExpression()); list.getExpression().add(0, firstEntry); makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(1, list.getExpression().size()); assertEquals(firstEntry, list.getExpression().get(0)); }