### Question:
RemoveParameterCommand 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) { function.getFormalParameter().remove(parameter); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { function.getFormalParameter().add(oldParameterIndex, parameter); return GraphCommandResultBuilder.SUCCESS; } }; } RemoveParameterCommand(final FunctionDefinition function,
                                  final InformationItem parameter,
                                  final org.uberfire.mvp.Command canvasOperation);   }### Answer:
@Test public void testGraphCommandAllow() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); }
@Test public void testGraphCommandExecuteWithParameters() { final InformationItem otherParameter = new InformationItem(); function.getFormalParameter().add(otherParameter); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertFormalParameters(otherParameter); }
@Test public void testGraphCommandExecuteWithNoParameters() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertFormalParameters(); }
@Test public void testGraphCommandUndoWithParameters() { final InformationItem otherParameter = new InformationItem(); function.getFormalParameter().add(otherParameter); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertFormalParameters(parameter, otherParameter); }
@Test public void testRemoveFromMiddleThenUndo() { final InformationItem firstParameter = new InformationItem(); firstParameter.setName(new Name("first")); function.getFormalParameter().add(0, firstParameter); final InformationItem lastParameter = new InformationItem(); lastParameter.setName(new Name("last")); function.getFormalParameter().add(lastParameter); this.command = new RemoveParameterCommand(function, parameter, canvasOperation); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertFormalParameters(firstParameter, lastParameter); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertFormalParameters(firstParameter, parameter, lastParameter); }
@Test public void testGraphCommandUndoWithNoParameters() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertFormalParameters(parameter); }