use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testGraphCommandExecuteRemoveMiddleWithColumns.
@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());
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchLevel1Tests method testAddNewEdgeAndNode.
@Test
public void testAddNewEdgeAndNode() {
Command<GraphCommandExecutionContext, RuleViolation> command = addNewEdgeAndNodeIntoParent(graph.containerNode);
ContextualGraphCommandExecutionContext executionContext = createConstrainedExecutionContext();
CommandResult<RuleViolation> result = command.allow(executionContext);
assertSuccessfullResult(result);
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class GraphBuilder method addEdge.
@SuppressWarnings("unchecked")
private void addEdge(Edge<? extends View<?>, Node> edge, Node source, Connection sourceConnection, List<Point2D> controlPoints, Node target, Connection targetConnection) {
final DeferredCompositeCommand.Builder<GraphCommandExecutionContext, RuleViolation> commandBuilder = new DeferredCompositeCommand.Builder<>();
addConnector(commandBuilder, source, edge, sourceConnection);
final ControlPoint[] cps = new ControlPoint[controlPoints.size()];
for (int i = 0; i < cps.length; i++) {
final ControlPoint cp = ControlPoint.build(controlPoints.get(i));
addControlPoint(commandBuilder, edge, cp, i);
}
setTargetNode(commandBuilder, target, edge, targetConnection);
execute(commandBuilder.build());
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommandTest method testGraphCommandExecuteInsertBelowThenUndo.
@Test
public void testGraphCommandExecuteInsertBelowThenUndo() {
// 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);
graphCommand.undo(graphCommandExecutionContext);
assertEquals(1, dtable.getRule().size());
assertEquals(existingRule, dtable.getRule().get(0));
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testGraphCommandExecuteExistingNotAffected.
@Test
public void testGraphCommandExecuteExistingNotAffected() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneOldOutput = "old rule 1";
final String ruleTwoOldOutput = "old rule 2";
dtable.getOutput().add(new OutputClause());
addRuleWithOutputClauseValues(ruleOneOldOutput);
addRuleWithOutputClauseValues(ruleTwoOldOutput);
assertEquals(1, dtable.getOutput().size());
// Graph command will insert new OutputClause at index 0 of the OutputEntries
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(2, dtable.getOutput().size());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_PREFIX + "1", dtable.getOutput().get(0).getName());
assertNull(dtable.getOutput().get(1).getName());
// first rule
final List<LiteralExpression> outputEntriesRuleOne = dtable.getRule().get(0).getOutputEntry();
assertEquals(2, outputEntriesRuleOne.size());
assertEquals(ruleOneOldOutput, outputEntriesRuleOne.get(1).getText().getValue());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT, outputEntriesRuleOne.get(0).getText().getValue());
assertEquals(dtable.getRule().get(0), outputEntriesRuleOne.get(0).getParent());
// second rule
final List<LiteralExpression> outputEntriesRuleTwo = dtable.getRule().get(1).getOutputEntry();
assertEquals(2, outputEntriesRuleTwo.size());
assertEquals(ruleTwoOldOutput, outputEntriesRuleTwo.get(1).getText().getValue());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT, outputEntriesRuleTwo.get(0).getText().getValue());
assertEquals(dtable.getRule().get(1), outputEntriesRuleTwo.get(0).getParent());
assertEquals(dtable, outputClause.getParent());
}
Aggregations