use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddParameterBindingCommandTest method testGraphCommandUndoFromStart.
@Test
public void testGraphCommandUndoFromStart() {
final Binding firstBinding = new Binding();
final Binding secondBinding = new Binding();
invocation.getBinding().add(firstBinding);
invocation.getBinding().add(secondBinding);
makeCommand(0);
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));
assertBindingDefinitions(firstBinding, secondBinding);
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class DeleteParameterBindingCommandTest method testGraphCommandExecuteRemoveFromMiddle.
@Test
public void testGraphCommandExecuteRemoveFromMiddle() {
final Binding firstBinding = new Binding();
final Binding lastBinding = new Binding();
invocation.getBinding().add(0, firstBinding);
invocation.getBinding().add(lastBinding);
uiModel.appendRow(new DMNGridRow());
uiModel.appendRow(new DMNGridRow());
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
Assertions.assertThat(invocation.getBinding()).containsExactly(firstBinding, lastBinding);
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class AddRelationColumnCommandTest method testGraphCommandExecuteWithExistingColumn_InsertMiddle.
@Test
public void testGraphCommandExecuteWithExistingColumn_InsertMiddle() {
makeCommand(2);
final InformationItem existingInformationItemFirst = new InformationItem();
relation.getColumn().add(existingInformationItemFirst);
final InformationItem existingInformationItemLast = new InformationItem();
relation.getColumn().add(existingInformationItemLast);
final List row = new List();
relation.getRow().add(row);
final LiteralExpression existingLiteralExpressionFirst = new LiteralExpression();
final LiteralExpression existingLiteralExpressionLast = new LiteralExpression();
row.getExpression().add(existingLiteralExpressionFirst);
row.getExpression().add(existingLiteralExpressionLast);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(3, relation.getColumn().size());
assertEquals(existingInformationItemFirst, relation.getColumn().get(0));
assertEquals(informationItem, relation.getColumn().get(1));
assertEquals(existingInformationItemLast, relation.getColumn().get(2));
assertEquals(1, relation.getRow().size());
assertEquals(3, relation.getRow().get(0).getExpression().size());
assertEquals(existingLiteralExpressionFirst, relation.getRow().get(0).getExpression().get(0));
assertTrue(relation.getRow().get(0).getExpression().get(1) instanceof LiteralExpression);
assertEquals(existingLiteralExpressionLast, relation.getRow().get(0).getExpression().get(2));
}
use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.
the class DeleteRelationColumnCommandTest method testGraphCommandExecuteWithRows.
@Test
public void testGraphCommandExecuteWithRows() {
relation.getRow().add(new List());
relation.getRow().get(0).getExpression().add(new LiteralExpression());
makeCommand();
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(0, relation.getColumn().size());
assertEquals(1, relation.getRow().size());
assertEquals(0, relation.getRow().get(0).getExpression().size());
}
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 DMNGridRow());
uiModel.appendRow(new DMNGridRow());
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(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());
}
Aggregations