use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class DeleteContextEntryCommandTest method testGraphCommandExecuteMultipleRows.
@Test
public void testGraphCommandExecuteMultipleRows() {
addContextEntries(3);
final ContextEntry firstEntry = context.getContextEntry().get(0);
final ContextEntry lastEntry = context.getContextEntry().get(2);
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
Assertions.assertThat(context.getContextEntry()).containsExactly(firstEntry, lastEntry);
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class DeleteContextEntryCommandTest method testGraphCommandUndoMultipleRows.
@Test
public void testGraphCommandUndoMultipleRows() {
addContextEntries(3);
final ContextEntry firstEntry = context.getContextEntry().get(0);
final ContextEntry originalEntry = context.getContextEntry().get(1);
final ContextEntry lastEntry = context.getContextEntry().get(2);
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
// Delete row and then undo
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
Assertions.assertThat(context.getContextEntry()).containsExactly(firstEntry, originalEntry, lastEntry);
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommandTest method testCanvasCommandExecuteInsertBelowThenUndo.
@Test
public void testCanvasCommandExecuteInsertBelowThenUndo() {
// The default behaviour of tests in this class is to "insert above"
final DecisionRule existingRule = new DecisionRule();
final DMNGridRow existingUiRow = new DMNGridRow();
dtable.getRule().add(existingRule);
uiModel.appendRow(existingUiRow);
makeCommand(1);
uiModel.appendColumn(uiInputClauseColumn);
uiModel.appendColumn(uiOutputClauseColumn);
uiModel.appendColumn(uiDescriptionColumn);
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
final Command<AbstractCanvasHandler, CanvasViolation> canvasCommand = command.newCanvasCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
canvasCommand.execute(canvasHandler);
canvasCommand.undo(canvasHandler);
assertEquals(1, uiModel.getRowCount());
assertEquals(existingUiRow, uiModel.getRow(0));
// one time in execute(), one time in undo()
verify(canvasOperation, times(2)).execute();
verify(command, times(2)).updateRowNumbers();
verify(command, times(2)).updateParentInformation();
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommandTest method testGraphCommandExecuteInsertBelow.
@Test
public void testGraphCommandExecuteInsertBelow() {
// The default behaviour of tests in this class is to "insert above"
final DecisionRule existingRule = new DecisionRule();
dtable.getRule().add(existingRule);
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
assertEquals(2, dtable.getRule().size());
assertEquals(existingRule, dtable.getRule().get(0));
assertEquals(rule, dtable.getRule().get(1));
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommandTest method testGraphCommandExecuteConstructedRuleInputs.
@Test
public void testGraphCommandExecuteConstructedRuleInputs() {
makeCommand(0);
assertEquals(0, dtable.getRule().size());
final int inputsCount = 2;
for (int i = 0; i < inputsCount; i++) {
dtable.getInput().add(new InputClause());
}
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(1, dtable.getRule().size());
assertEquals(rule, dtable.getRule().get(0));
assertEquals(inputsCount, rule.getInputEntry().size());
assertEquals(0, rule.getOutputEntry().size());
for (int inputIndex = 0; inputIndex < inputsCount; inputIndex++) {
assertTrue(rule.getInputEntry().get(inputIndex).getText() != null);
assertFalse(rule.getInputEntry().get(inputIndex).getText().isEmpty());
}
}
Aggregations