use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class DeleteRelationColumnCommandTest method testGraphCommandExecuteDeleteMiddleWithRows.
@Test
public void testGraphCommandExecuteDeleteMiddleWithRows() {
uiModel.appendColumn(mock(RelationColumn.class));
uiModel.appendColumn(mock(RelationColumn.class));
relation.getColumn().add(new InformationItem());
relation.getColumn().add(new InformationItem());
relation.getRow().add(new List());
final LiteralExpression firstExpression = new LiteralExpression();
final LiteralExpression lastExpression = new LiteralExpression();
relation.getRow().get(0).getExpression().add(firstExpression);
relation.getRow().get(0).getExpression().add(new LiteralExpression());
relation.getRow().get(0).getExpression().add(lastExpression);
makeCommand(2);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(2, relation.getColumn().size());
assertEquals(1, relation.getRow().size());
assertEquals(2, relation.getRow().get(0).getExpression().size());
assertEquals(firstExpression, relation.getRow().get(0).getExpression().get(0));
assertEquals(lastExpression, relation.getRow().get(0).getExpression().get(1));
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testGraphCommandExecuteWithColumns.
@Test
public void testGraphCommandExecuteWithColumns() {
relation.getColumn().add(new InformationItem());
relation.getRow().get(0).getExpression().add(new LiteralExpression());
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(0, relation.getRow().size());
assertEquals(1, relation.getColumn().size());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testGraphCommandUndoWithColumns.
@Test
public void testGraphCommandUndoWithColumns() {
relation.getColumn().add(new InformationItem());
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.setText(VALUE);
relation.getRow().get(0).getExpression().add(literalExpression);
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));
assertEquals(1, relation.getColumn().size());
assertEquals(1, relation.getRow().size());
assertEquals(1, relation.getRow().get(0).getExpression().size());
assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0)).getText());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class AbstractEdgeBuilder method buildTargetNode.
private Node buildTargetNode(BuilderContext context, String outgoingNodeId, GraphCommandFactory commandFactory) {
GraphObjectBuilder<?, ?> outgoingNodeBuilder = getBuilder(context, outgoingNodeId);
if (outgoingNodeBuilder == null) {
throw new RuntimeException("No edge for " + outgoingNodeId);
}
Node node = (Node) outgoingNodeBuilder.build(context);
AddNodeCommand addNodeCommand = commandFactory.addNode(node);
CommandResult<RuleViolation> addEdgeResult = context.execute(addNodeCommand);
if (hasErrors(addEdgeResult)) {
throw new RuntimeException("Error building BPMN graph. Command 'addNodeCommand' execution failed.");
}
return node;
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class AbstractEdgeBuilder method buildControlPoints.
private void buildControlPoints(BuilderContext context, T edge, GraphCommandFactory commandFactory) {
if (dockers.size() > 2) {
Counter indexCounter = new Counter(0);
ControlPoint[] controlPoints = dockers.subList(1, dockers.size() - 1).stream().sequential().map(docker -> (docker.length == 2 ? new Point2D(docker[0], docker[1]) : null)).filter(Objects::nonNull).map(point -> new ControlPointImpl(point, indexCounter.increment())).toArray(ControlPoint[]::new);
CommandResult<RuleViolation> addControlPointsResult = context.execute(commandFactory.addControlPoint(edge, controlPoints));
if (hasErrors(addControlPointsResult)) {
throw new RuntimeException("Error building BPMN graph. Command 'AddControlPointCommand' execution failed." + addControlPointsResult);
}
}
}
Aggregations