use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class AddRelationColumnCommandTest method testCanvasCommandExecuteWithRows.
@Test
public void testCanvasCommandExecuteWithRows() {
relation.getRow().add(new List());
uiModel.appendRow(new DMNGridRow());
uiModelMapper.fromDMNModel(0, 0);
// Add Graph column first as RelationUIModelMapper relies on the model being first updated
command.newGraphCommand(handler).execute(gce);
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
assertEquals(2, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiModelColumn, uiModel.getColumns().get(1));
assertEquals(1, uiModel.getRowCount());
assertEquals(2, uiModel.getRows().get(0).getCells().size());
assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
assertEquals("", uiModel.getCell(0, 1).getValue().getValue());
verify(command).updateParentInformation();
verify(canvasOperation).execute();
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class AddRelationColumnCommandTest method testCanvasCommandExecuteWithRowsAddColumnMiddle.
@Test
public void testCanvasCommandExecuteWithRowsAddColumnMiddle() {
makeCommand(2);
final InformationItem existingInformationItemFirst = new InformationItem();
relation.getColumn().add(existingInformationItemFirst);
final InformationItem existingInformationItemLast = new InformationItem();
relation.getColumn().add(existingInformationItemLast);
uiModel.appendColumn(mock(RelationColumn.class));
uiModel.appendColumn(mock(RelationColumn.class));
uiModel.appendRow(new DMNGridRow());
// Add Graph column first as RelationUIModelMapper relies on the model being first updated
command.newGraphCommand(handler).execute(gce);
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
assertEquals(4, uiModel.getColumnCount());
assertEquals(uiModelColumn, uiModel.getColumns().get(2));
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class DeleteRelationColumnCommandTest method testCanvasCommandUndoWithRows.
@Test
public void testCanvasCommandUndoWithRows() {
relation.getRow().add(new List());
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.setText(VALUE);
relation.getRow().get(0).getExpression().add(literalExpression);
uiModel.appendRow(new DMNGridRow());
uiModelMapper.fromDMNModel(0, 1);
makeCommand();
// Delete column and then undo
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
reset(command, canvasOperation);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
assertEquals(2, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiModelColumn, uiModel.getColumns().get(1));
assertEquals(1, uiModel.getRowCount());
assertEquals(1, uiModel.getRows().get(0).getCells().size());
assertEquals(VALUE, uiModel.getCell(0, 1).getValue().getValue());
verify(command).updateParentInformation();
verify(canvasOperation).execute();
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testCanvasCommandUndoWithColumns.
@Test
public void testCanvasCommandUndoWithColumns() {
relation.getColumn().add(new InformationItem());
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.setText(VALUE);
relation.getRow().get(0).getExpression().add(literalExpression);
uiModel.appendColumn(uiModelColumn);
uiModelMapper.fromDMNModel(0, 0);
uiModelMapper.fromDMNModel(0, 1);
// Delete row and then undo
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
reset(command, canvasOperation);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
assertEquals(2, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiModelColumn, uiModel.getColumns().get(1));
assertEquals(1, uiModel.getRowCount());
assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
assertEquals(VALUE, uiModel.getCell(0, 1).getValue().getValue());
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
verify(canvasOperation).execute();
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testCanvasCommandExecuteRemoveMiddleWithColumns.
@Test
public void testCanvasCommandExecuteRemoveMiddleWithColumns() {
uiModel.appendColumn(uiModelColumn);
final DMNGridRow firstRow = new DMNGridRow();
final DMNGridRow lastRow = new DMNGridRow();
uiModel.insertRow(0, firstRow);
uiModel.appendRow(lastRow);
relation.getRow().add(0, new List());
relation.getRow().add(new List());
makeCommand(1);
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
assertEquals(2, uiModel.getRowCount());
assertEquals(firstRow, uiModel.getRow(0));
assertEquals(lastRow, uiModel.getRow(1));
assertEquals(2, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiModelColumn, uiModel.getColumns().get(1));
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
verify(canvasOperation).execute();
}
Aggregations