### Question:
DeleteRelationRowCommand 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) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
                                    final GridData uiModel,
                                    final int uiRowIndex,
                                    final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation();  }### Answer:
@Test public void testGraphCommandAllow() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); }
@Test public void testGraphCommandExecuteWithColumns() { relation.getColumn().add(new InformationItem()); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression())); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(0, relation.getRow().size()); assertEquals(1, relation.getColumn().size()); }
@Test public void testGraphCommandExecuteRemoveMiddleWithColumns() { uiModel.appendRow(new BaseGridRow()); uiModel.appendRow(new BaseGridRow()); final List firstRow = new List(); final List lastRow = new List(); relation.getRow().add(0, firstRow); relation.getRow().add(lastRow); relation.getColumn().add(new InformationItem()); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression())); makeCommand(1); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(2, relation.getRow().size()); assertEquals(firstRow, relation.getRow().get(0)); assertEquals(lastRow, relation.getRow().get(1)); assertEquals(1, relation.getColumn().size()); }
@Test public void testGraphCommandExecuteWithNoColumns() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(0, relation.getRow().size()); }
@Test public void testGraphCommandUndoWithColumns() { relation.getColumn().add(new InformationItem()); final LiteralExpression literalExpression = new LiteralExpression(); literalExpression.getText().setValue(VALUE); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression)); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(1, relation.getColumn().size()); assertEquals(1, relation.getRow().size()); assertEquals(1, relation.getRow().get(0).getExpression().size()); assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0).getExpression()).getText().getValue()); }
@Test public void testGraphCommandUndoWithNoColumns() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(0, relation.getColumn().size()); assertEquals(1, relation.getRow().size()); }