### Question:
MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                           VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler ach) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gcec) { if (index == uiModel.getRowCount() - 1) { return GraphCommandResultBuilder.failed(); } return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gcec) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gcec) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final List<ContextEntry> rowsToMove = uiRows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> context.getContextEntry().get(i)) .collect(Collectors.toList()); final List<ContextEntry> rows = context.getContextEntry(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Context context,
                           final DMNGridData uiModel,
                           final int index,
                           final List<GridRow> uiRows,
                           final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation();  }### Answer:
@Test public void testGraphCommandAllow() { setupCommand(0, uiModel.getRow(0)); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); }
@Test public void testGraphCommandExecuteMoveUp() { setupCommand(0, uiModel.getRow(1)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertContextEntryDefinitions(new int[]{1, 0}); }
@Test public void testGraphCommandExecuteMoveUpThreeRows() { addContextEntry(II3); addUiModelRow(2); setupCommand(0, uiModel.getRow(2)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertContextEntryDefinitions(new int[]{1, 2, 0}); }
@Test public void testGraphCommandExecuteMoveDown() { setupCommand(1, uiModel.getRow(0)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertContextEntryDefinitions(new int[]{1, 0}); }
@Test public void testGraphCommandExecuteMoveDownThreeRows() { addContextEntry(II3); addUiModelRow(2); setupCommand(2, uiModel.getRow(0)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertContextEntryDefinitions(new int[]{2, 0, 1}); }