ColumnRenderingStrategyMerged { protected static boolean isCollapsedRowMultiValue(final GridData model, final GridColumn<?> column, final GridCell<?> cell, final int rowIndex) { GridRow row; int rowOffset = 1; final int columnIndex = column.getIndex(); while ((row = model.getRow(rowIndex - rowOffset)).isCollapsed()) { final GridCell<?> nc = row.getCells().get(columnIndex); if (!Objects.equals(nc, cell)) { return true; } rowOffset++; } final GridCell<?> nc = row.getCells().get(columnIndex); if (!Objects.equals(nc, cell)) { return true; } return false; }  static List<GridRenderer.RendererCommand> render(final GridColumn<?> column,
                                                            final GridBodyColumnRenderContext context,
                                                            final BaseGridRendererHelper rendererHelper,
                                                            final BaseGridRendererHelper.RenderingInformation renderingInformation,
                                                            final BiFunction<Boolean, GridColumn<?>, Boolean> columnRenderingConstraint);  }
@Test public void testIsCollapsedRowMixedValueThreeDifferentValues() { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("two", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("three", 0); final GridRow gridRowOne = mock(GridRow.class); final GridRow gridRowTwo = mock(GridRow.class); final GridRow gridRowThree = mock(GridRow.class); doReturn(gridRowOne).when(gridData).getRow(0); doReturn(gridRowTwo).when(gridData).getRow(1); doReturn(gridRowThree).when(gridData).getRow(2); doReturn(false).when(gridRowOne).isCollapsed(); doReturn(true).when(gridRowTwo).isCollapsed(); doReturn(true).when(gridRowThree).isCollapsed(); doReturn(Collections.singletonMap(0, cellOne)).when(gridRowOne).getCells(); doReturn(Collections.singletonMap(0, cellTwo)).when(gridRowTwo).getCells(); doReturn(Collections.singletonMap(0, cellThree)).when(gridRowThree).getCells(); assertThat(ColumnRenderingStrategyMerged.isCollapsedRowMultiValue(gridData, gridColumn, cellThree, 2)).isTrue(); }
@Test public void testIsCollapsedRowMixedValueOneDifferentValue_1() { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("two", 0); final GridRow gridRowOne = mock(GridRow.class); final GridRow gridRowTwo = mock(GridRow.class); final GridRow gridRowThree = mock(GridRow.class); doReturn(gridRowOne).when(gridData).getRow(0); doReturn(gridRowTwo).when(gridData).getRow(1); doReturn(gridRowThree).when(gridData).getRow(2); doReturn(false).when(gridRowOne).isCollapsed(); doReturn(true).when(gridRowTwo).isCollapsed(); doReturn(true).when(gridRowThree).isCollapsed(); doReturn(Collections.singletonMap(0, cellOne)).when(gridRowOne).getCells(); doReturn(Collections.singletonMap(0, cellTwo)).when(gridRowTwo).getCells(); doReturn(Collections.singletonMap(0, cellThree)).when(gridRowThree).getCells(); assertThat(ColumnRenderingStrategyMerged.isCollapsedRowMultiValue(gridData, gridColumn, cellThree, 2)).isTrue(); }
@Test public void testIsCollapsedRowMixedValueOneDifferentValue_2() { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("two", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("one", 0); final GridRow gridRowOne = mock(GridRow.class); final GridRow gridRowTwo = mock(GridRow.class); final GridRow gridRowThree = mock(GridRow.class); doReturn(gridRowOne).when(gridData).getRow(0); doReturn(gridRowTwo).when(gridData).getRow(1); doReturn(gridRowThree).when(gridData).getRow(2); doReturn(false).when(gridRowOne).isCollapsed(); doReturn(true).when(gridRowTwo).isCollapsed(); doReturn(true).when(gridRowThree).isCollapsed(); doReturn(Collections.singletonMap(0, cellOne)).when(gridRowOne).getCells(); doReturn(Collections.singletonMap(0, cellTwo)).when(gridRowTwo).getCells(); doReturn(Collections.singletonMap(0, cellThree)).when(gridRowThree).getCells(); assertThat(ColumnRenderingStrategyMerged.isCollapsedRowMultiValue(gridData, gridColumn, cellThree, 2)).isTrue(); }
@Test public void testIsCollapsedRowMixedValueOneDifferentValue_3() { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("two", 0); final GridRow gridRowOne = mock(GridRow.class); final GridRow gridRowTwo = mock(GridRow.class); final GridRow gridRowThree = mock(GridRow.class); doReturn(gridRowOne).when(gridData).getRow(0); doReturn(gridRowTwo).when(gridData).getRow(1); doReturn(gridRowThree).when(gridData).getRow(2); doReturn(false).when(gridRowOne).isCollapsed(); doReturn(true).when(gridRowTwo).isCollapsed(); doReturn(true).when(gridRowThree).isCollapsed(); doReturn(Collections.singletonMap(0, cellOne)).when(gridRowOne).getCells(); doReturn(Collections.singletonMap(0, cellTwo)).when(gridRowTwo).getCells(); doReturn(Collections.singletonMap(0, cellThree)).when(gridRowThree).getCells(); assertThat(ColumnRenderingStrategyMerged.isCollapsedRowMultiValue(gridData, gridColumn, cellThree, 2)).isTrue(); }
@Test public void testIsCollapsedRowMixedValue() { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("one", 0); final GridRow gridRowOne = mock(GridRow.class); final GridRow gridRowTwo = mock(GridRow.class); final GridRow gridRowThree = mock(GridRow.class); doReturn(gridRowOne).when(gridData).getRow(0); doReturn(gridRowTwo).when(gridData).getRow(1); doReturn(gridRowThree).when(gridData).getRow(2); doReturn(false).when(gridRowOne).isCollapsed(); doReturn(true).when(gridRowTwo).isCollapsed(); doReturn(true).when(gridRowThree).isCollapsed(); doReturn(Collections.singletonMap(0, cellOne)).when(gridRowOne).getCells(); doReturn(Collections.singletonMap(0, cellTwo)).when(gridRowTwo).getCells(); doReturn(Collections.singletonMap(0, cellThree)).when(gridRowThree).getCells(); assertThat(ColumnRenderingStrategyMerged.isCollapsedRowMultiValue(gridData, gridColumn, cellThree, 2)).isFalse(); }