Search in sources :

Example 31 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class MoveColumnsCommandTest method addUiModelRow.

@Override
protected void addUiModelRow(final int rowIndex) {
    final DMNGridRow uiRow = new DMNGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>("value0"));
    uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>("value1"));
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)

Example 32 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class ExpressionContainerUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    uiModel = new BaseGridData();
    uiModel.appendRow(new DMNGridRow());
    uiModel.appendColumn(uiExpressionColumn);
    doReturn(0).when(uiExpressionColumn).getIndex();
    doReturn(MINIMUM_COLUMN_WIDTH).when(uiExpressionColumn).getMinimumWidth();
    parent = new GridCellTuple(0, 0, expressionContainerGrid);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    mapper = new ExpressionContainerUIModelMapper(parent, () -> uiModel, () -> Optional.ofNullable(expression), () -> NODE_UUID, () -> hasExpression, () -> Optional.of(hasName), expressionEditorDefinitionsSupplier, listSelector);
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 33 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class UndefinedExpressionUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiColumn);
    this.uiModel.appendRow(new DMNGridRow());
    this.mapper = new UndefinedExpressionUIModelMapper(() -> uiModel, () -> Optional.ofNullable(expression), listSelector, hasExpression, new GridCellTuple(PARENT_ROW_INDEX, PARENT_COLUMN_INDEX, parentGridWidget));
    this.cellValueSupplier = () -> Optional.of(new ExpressionCellValue(Optional.of(editor)));
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    when(parentGridUiModel.getCell(eq(PARENT_ROW_INDEX), eq(PARENT_COLUMN_INDEX))).thenReturn(parentGridUiCell);
    when(parentGridUiCell.getSelectionStrategy()).thenReturn(parentGridUiCellCellSelectionStrategy);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 34 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method testSelectFirstCellWithRowAndRowNumberColumn.

@Test
public void testSelectFirstCellWithRowAndRowNumberColumn() {
    grid.getModel().appendRow(new DMNGridRow());
    appendColumns(RowNumberColumn.class);
    grid.selectFirstCell();
    assertThat(grid.getModel().getSelectedCells()).isEmpty();
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Test(org.junit.Test)

Example 35 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method testUpdateWidthOfPeers.

/*
     * Test that parent column width is updated to sum of nested columns
     * The update is forced from nested column at position indexOfColumnToUpdate
     * The default width of parent column is 100
     */
private void testUpdateWidthOfPeers(final int indexOfColumnToUpdate, final double... widthsOfNestedColumns) {
    // parent column
    final BaseExpressionGrid parentGrid = mock(BaseExpressionGrid.class);
    final GridData parentGridData = mock(GridData.class);
    final DMNGridColumn parentColumn = mockColumn(100, null);
    doReturn(parentGrid).when(parentCell).getGridWidget();
    doReturn(parentGridData).when(parentGrid).getModel();
    doReturn(Collections.singletonList(parentColumn)).when(parentGridData).getColumns();
    doReturn(Collections.singleton(parentGrid)).when(gridLayer).getGridWidgets();
    // nested columns
    final List<DMNGridColumn> columns = Arrays.stream(widthsOfNestedColumns).mapToObj(width -> mockColumn(width, grid)).collect(Collectors.toList());
    grid.getModel().appendRow(new DMNGridRow());
    columns.stream().forEach(column -> grid.getModel().appendColumn(column));
    // force the peers width update
    columns.get(indexOfColumnToUpdate).updateWidthOfPeers();
    // assert parent width is equal to sum of nested columns widths
    final double padding = BaseExpressionGrid.DEFAULT_PADDING * 2;
    Assertions.assertThat(parentColumn.getWidth()).isEqualTo(Arrays.stream(widthsOfNestedColumns).sum() + padding);
}
Also used : DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) IntStream(java.util.stream.IntStream) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Captor(org.mockito.Captor) GridLayerRedrawManager(org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLayerRedrawManager) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) ArgumentCaptor(org.mockito.ArgumentCaptor) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Matchers.eq(org.mockito.Matchers.eq) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) Assertions(org.assertj.core.api.Assertions) GridColumnRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.columns.GridColumnRenderer) Mockito.doReturn(org.mockito.Mockito.doReturn) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Collectors(java.util.stream.Collectors) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) Mockito.verify(org.mockito.Mockito.verify) Matchers.any(org.mockito.Matchers.any) HasName(org.kie.workbench.common.dmn.api.definition.HasName) List(java.util.List) Mockito.never(org.mockito.Mockito.never) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData)

Aggregations

DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)67 Test (org.junit.Test)32 Before (org.junit.Before)16 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)13 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)12 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)12 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)12 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)11 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)10 Optional (java.util.Optional)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)6 ContextEntry (org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)6 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)6 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)6 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)5 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)4 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)4