Search in sources :

Example 81 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class AddRelationColumnCommandTest method testCanvasCommandUndoWithRows.

@Test
public void testCanvasCommandUndoWithRows() {
    relation.getRow().add(new List());
    uiModel.appendRow(new BaseGridRow());
    uiModelMapper.fromDMNModel(0, 0);
    // Add Graph column first as RelationUIModelMapper relies on the model being first updated
    command.newGraphCommand(handler).execute(gce);
    // Add column and then undo
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    reset(command);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
    assertEquals(1, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(1, uiModel.getRowCount());
    assertEquals(1, uiModel.getRows().get(0).getCells().size());
    assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
    verify(command).updateParentInformation();
    verify(undoCanvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) List(org.kie.workbench.common.dmn.api.definition.model.List) Test(org.junit.Test)

Example 82 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow 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());
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) List(org.kie.workbench.common.dmn.api.definition.model.List) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 83 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class ExpressionEditorColumnTest method testMinimalWidthNoCellsInMiddleWithPadding.

/**
 * (10)[100](10)
 * (10)-(10)
 * (10)[50][60](10)
 */
@Test
public void testMinimalWidthNoCellsInMiddleWithPadding() {
    gridData.appendColumn(column);
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    mockCellsWithPadding(0, 0, PADDING, 100);
    mockCellsWithPadding(1, 0, PADDING);
    mockCellsWithPadding(2, 0, PADDING, 50, 60);
    assertThat(column.getMinimumWidth()).isEqualTo(130);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Test(org.junit.Test)

Example 84 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class ExpressionEditorColumnTest method testMinimalWidthTwoCellsSumWithPadding.

/**
 * (10)[100](10)
 * (10)[50][60](10)
 * (10)[105](10)
 */
@Test
public void testMinimalWidthTwoCellsSumWithPadding() {
    gridData.appendColumn(column);
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    mockCellsWithPadding(0, 0, PADDING, 100);
    mockCellsWithPadding(1, 0, PADDING, 50, 60);
    mockCellsWithPadding(2, 0, PADDING, 105);
    assertThat(column.getMinimumWidth()).isEqualTo(130);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Test(org.junit.Test)

Example 85 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class ExpressionEditorColumnTest method testMinimalWidthTwoCellsSum.

/**
 * [100]
 * [50][60]
 * [105]
 */
@Test
public void testMinimalWidthTwoCellsSum() {
    gridData.appendColumn(column);
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    mockCells(0, 0, 100);
    mockCells(1, 0, 50, 60);
    mockCells(2, 0, 105);
    assertThat(column.getMinimumWidth()).isEqualTo(110);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Test(org.junit.Test)

Aggregations

BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)104 Test (org.junit.Test)57 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)25 Before (org.junit.Before)24 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)19 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)18 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)18 List (org.kie.workbench.common.dmn.api.definition.model.List)14 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)14 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)11 Optional (java.util.Optional)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)10 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)10 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)9 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)9 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)9 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)9 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)8 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)8