use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddInputClauseCommandTest method testGraphCommandUndoJustLastInputClauseColumn.
@Test
public void testGraphCommandUndoJustLastInputClauseColumn() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneOldInput = "old rule 1";
final String ruleTwoOldInput = "old rule 2";
dtable.getInput().add(new InputClause());
addRuleWithInputClauseValues(ruleOneOldInput);
addRuleWithInputClauseValues(ruleTwoOldInput);
assertEquals(1, dtable.getInput().size());
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.undo(graphCommandExecutionContext));
assertEquals(1, dtable.getInput().size());
// first rule
assertEquals(1, dtable.getRule().get(0).getInputEntry().size());
assertEquals(ruleOneOldInput, dtable.getRule().get(0).getInputEntry().get(0).getText());
// second rule
assertEquals(1, dtable.getRule().get(1).getInputEntry().size());
assertEquals(ruleTwoOldInput, dtable.getRule().get(1).getInputEntry().get(0).getText());
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddInputClauseCommandTest method testGraphCommandExecuteExistingNotAffected.
@Test
public void testGraphCommandExecuteExistingNotAffected() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneOldInput = "old rule 1";
final String ruleTwoOldInput = "old rule 2";
dtable.getInput().add(new InputClause());
addRuleWithInputClauseValues(ruleOneOldInput);
addRuleWithInputClauseValues(ruleTwoOldInput);
assertEquals(1, dtable.getInput().size());
// Graph command will insert new InputClause at index 0 of the InputEntries
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(2, dtable.getInput().size());
// first rule
assertEquals(2, dtable.getRule().get(0).getInputEntry().size());
assertEquals(ruleOneOldInput, dtable.getRule().get(0).getInputEntry().get(1).getText());
assertEquals(AddInputClauseCommand.INPUT_CLAUSE_DEFAULT_VALUE, dtable.getRule().get(0).getInputEntry().get(0).getText());
// second rule
assertEquals(2, dtable.getRule().get(1).getInputEntry().size());
assertEquals(ruleTwoOldInput, dtable.getRule().get(1).getInputEntry().get(1).getText());
assertEquals(AddInputClauseCommand.INPUT_CLAUSE_DEFAULT_VALUE, dtable.getRule().get(1).getInputEntry().get(0).getText());
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddInputClauseCommandTest method testGraphCommandUndoNoInputClauseColumns.
@Test(expected = ArrayIndexOutOfBoundsException.class)
public void testGraphCommandUndoNoInputClauseColumns() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
dtable.getRule().add(new DecisionRule());
assertEquals(0, dtable.getInput().size());
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.undo(graphCommandExecutionContext));
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testGraphCommandExecute.
@Test
public void testGraphCommandExecute() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
dtable.getRule().add(new DecisionRule());
dtable.getRule().add(new DecisionRule());
assertEquals(0, dtable.getOutput().size());
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
// one new output column
assertEquals(1, dtable.getOutput().size());
// first rule
assertEquals(1, dtable.getRule().get(0).getOutputEntry().size());
assertEquals(AddOutputClauseCommand.OUTPUT_CLAUSE_DEFAULT_VALUE, dtable.getRule().get(0).getOutputEntry().get(0).getText());
// second rule
assertEquals(1, dtable.getRule().get(1).getOutputEntry().size());
assertEquals(AddOutputClauseCommand.OUTPUT_CLAUSE_DEFAULT_VALUE, dtable.getRule().get(1).getOutputEntry().get(0).getText());
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddParameterCommandTest method testGraphCommandUndoWithParameters.
@Test
public void testGraphCommandUndoWithParameters() {
final InformationItem otherParameter = new InformationItem();
function.getFormalParameter().add(otherParameter);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
// Add parameter and then undo
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
assertFormalParameters(1, otherParameter);
}
Aggregations