Search in sources :

Example 16 with BaseExpressionGrid

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

the class LiteralExpressionGridTest method testGetItemsWithParentThatDoesNotSupportCellControls.

@Test
public void testGetItemsWithParentThatDoesNotSupportCellControls() {
    setupGrid(0);
    final GridData parentGridData = mock(GridData.class);
    final BaseExpressionGrid parentGridWidget = mock(BaseExpressionGrid.class);
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(parentGridWidget));
    when(parentGridWidget.getModel()).thenReturn(parentGridData);
    final List<HasListSelectorControl.ListSelectorItem> items = grid.getItems(0, 0);
    assertThat(items).isEmpty();
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Test(org.junit.Test)

Example 17 with BaseExpressionGrid

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

the class CommandUtilsTest method testUpdateParentInformation_WithExpressionColumn.

@Test
public void testUpdateParentInformation_WithExpressionColumn() {
    setupUiModel(Pair.newPair(new ExpressionEditorColumn(gridLayer, new BaseHeaderMetaData("column"), gridWidget), (rowIndex) -> {
        final BaseExpressionGrid grid = mock(BaseExpressionGrid.class);
        final GridCellTuple gct = new GridCellTuple(rowIndex, 0, mock(GridWidget.class));
        when(grid.getParentInformation()).thenReturn(gct);
        return new ExpressionCellValue(Optional.of(grid));
    }));
    assertParentInformationValues(0);
    uiModel.moveRowTo(0, uiModel.getRow(ROW_COUNT - 1));
    CommandUtils.updateParentInformation(uiModel);
    assertParentInformationValues(0);
}
Also used : IntStream(java.util.stream.IntStream) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Arrays(java.util.Arrays) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) GridSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.layer.GridSelectionManager) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Function(java.util.function.Function) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ArrayList(java.util.ArrayList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) 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) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Assertions(org.assertj.core.api.Assertions) Assert.fail(org.junit.Assert.fail) Pair(org.uberfire.commons.data.Pair) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) GridPinnedModeManager(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.GridPinnedModeManager) List(java.util.List) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) GridCellValue(org.uberfire.ext.wires.core.grids.client.model.GridCellValue) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Optional(java.util.Optional) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Test(org.junit.Test)

Example 18 with BaseExpressionGrid

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

the class CommandUtilsTest method assertParentInformationValues.

private void assertParentInformationValues(final int expressionColumnIndex) {
    IntStream.range(0, ROW_COUNT).forEach(rowIndex -> {
        final ExpressionCellValue ecv = ((ExpressionCellValue) uiModel.getCell(rowIndex, expressionColumnIndex).getValue());
        final BaseExpressionGrid grid = ecv.getValue().get();
        assertEquals(rowIndex, grid.getParentInformation().getRowIndex());
        assertEquals(expressionColumnIndex, grid.getParentInformation().getColumnIndex());
    });
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 19 with BaseExpressionGrid

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

the class UndefinedExpressionGridTest method testGetItemsWithParentWithoutCellControls.

@Test
public void testGetItemsWithParentWithoutCellControls() {
    setupGrid(0);
    final GridData parentGridData = mock(GridData.class);
    final BaseExpressionGrid parentGridWidget = mock(BaseExpressionGrid.class);
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(parentGridWidget));
    when(parentGridWidget.getModel()).thenReturn(parentGridData);
    final List<HasListSelectorControl.ListSelectorItem> items = grid.getItems(0, 0);
    assertThat(items).isEmpty();
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

Example 20 with BaseExpressionGrid

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

the class UndefinedExpressionGridTest method testGetItemsWithParentThatDoesNotSupportCellControls.

@Test
public void testGetItemsWithParentThatDoesNotSupportCellControls() {
    setupGrid(0);
    final GridData parentGridData = mock(GridData.class);
    final BaseExpressionGrid parentGridWidget = mock(BaseExpressionGrid.class);
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(parentGridWidget));
    when(parentGridWidget.getModel()).thenReturn(parentGridData);
    final List<HasListSelectorControl.ListSelectorItem> items = grid.getItems(0, 0);
    assertThat(items).isEmpty();
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

Aggregations

BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)32 Test (org.junit.Test)15 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)13 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)13 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)11 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)11 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)8 List (java.util.List)7 Optional (java.util.Optional)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)7 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)7 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)7 ArrayList (java.util.ArrayList)6 HasName (org.kie.workbench.common.dmn.api.definition.HasName)6 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)6 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)6 DMNGridLayer (org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)6 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)5 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)5 ExpressionEditorColumn (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn)5