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 AddParameterBindingCommandTest method testGraphCommandExecuteInsertToFirstPlace.
@Test
public void testGraphCommandExecuteInsertToFirstPlace() {
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);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertBindingDefinitions(binding, firstBinding, secondBinding);
assertEquals(invocation, binding.getParent());
assertEquals(binding, binding.getParameter().getParent());
}
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 BaseGridRow());
uiModel.appendRow(new BaseGridRow());
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 DeleteListRowCommandTest method testGraphCommandExecuteRemoveMiddle.
@Test
public void testGraphCommandExecuteRemoveMiddle() {
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
final HasExpression firstRow = HasExpression.wrap(list, new LiteralExpression());
final HasExpression lastRow = HasExpression.wrap(list, new LiteralExpression());
list.getExpression().add(0, firstRow);
list.getExpression().add(lastRow);
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(2, list.getExpression().size());
assertEquals(firstRow, list.getExpression().get(0));
assertEquals(lastRow, list.getExpression().get(1));
}
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(HasExpression.wrap(row, existingLiteralExpressionFirst));
row.getExpression().add(HasExpression.wrap(row, 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(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
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).getExpression());
assertTrue(relation.getRow().get(0).getExpression().get(1).getExpression() instanceof LiteralExpression);
assertEquals(existingLiteralExpressionLast, relation.getRow().get(0).getExpression().get(2).getExpression());
assertEquals(relation, informationItem.getParent());
assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(1).getExpression().getParent());
}
Aggregations