### Question:
SetParametersCommand 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().clear(); function.getFormalParameter().addAll(parameters); parameters.forEach(parameter -> parameter.setParent(function)); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { function.getFormalParameter().clear(); function.getFormalParameter().addAll(oldParameters); parameters.forEach(parameter -> parameter.setParent(function)); return GraphCommandResultBuilder.SUCCESS; } }; } SetParametersCommand(final FunctionDefinition function,
                                final List<InformationItem> parameters,
                                final org.uberfire.mvp.Command canvasOperation);   }### Answer:
@Test public void testGraphCommandAllow() { setupCommand(); 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); setupCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertFormalParameters(parameter1, parameter2); assertEquals(function, parameter1.getParent()); assertEquals(function, parameter2.getParent()); }
@Test public void testGraphCommandExecuteWithNoParameters() { setupCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertFormalParameters(parameter1, parameter2); assertEquals(function, parameter1.getParent()); assertEquals(function, parameter2.getParent()); }
@Test public void testGraphCommandUndoWithParameters() { final InformationItem otherParameter = new InformationItem(); function.getFormalParameter().add(otherParameter); setupCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertFormalParameters(otherParameter); }
@Test public void testGraphCommandUndoWithNoParameters() { setupCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertFormalParameters(); }