BaseGridRenderer implements GridRenderer { int getMergedCellsCount(final GridData model, final int rowIndex) { int currentIndex = rowIndex; GridCell<?> cell = model.getCell(rowIndex, getHighlightCellColumnIndex()); while (cell.getMergedCellCount() == 0 && currentIndex >= 0) { currentIndex--; cell = model.getCell(currentIndex, getHighlightCellColumnIndex()); } return cell.getMergedCellCount(); } BaseGridRenderer(final GridRendererTheme theme); @Override double getHeaderHeight(); @Override double getHeaderRowHeight(); @Override GridRendererTheme getTheme(); @Override void setTheme(final GridRendererTheme theme); @Override RendererCommand renderSelector(final double width,
                                          final double height,
                                          final BaseGridRendererHelper.RenderingInformation renderingInformation); @Override RendererCommand renderSelectedCells(final GridData model,
                                               final GridBodyRenderContext context,
                                               final BaseGridRendererHelper rendererHelper,
                                               final List<GridData.SelectedCell> selectedCells,
                                               final BiFunction<SelectedRange, Integer, Double> selectedCellsYOffsetStrategy,
                                               final Function<SelectedRange, Double> selectedCellsHeightStrategy); @Override List<RendererCommand> renderHeader(final GridData model,
                                              final GridHeaderRenderContext context,
                                              final BaseGridRendererHelper rendererHelper,
                                              final BaseGridRendererHelper.RenderingInformation renderingInformation); @Override RendererCommand renderHeaderBodyDivider(final double width); @Override List<RendererCommand> renderBody(final GridData model,
                                            final GridBodyRenderContext context,
                                            final BaseGridRendererHelper rendererHelper,
                                            final BaseGridRendererHelper.RenderingInformation renderingInformation); @Override RendererCommand renderGridBoundary(final GridBoundaryRenderContext context); @Override boolean onGroupingToggle(double cellX,
                                    double cellY,
                                    double cellWidth,
                                    double cellHeight); @Override void setColumnRenderConstraint(final BiFunction<Boolean, GridColumn<?>, Boolean> columnRenderingConstraint); void clearCellHighlight(); void highlightCell(final int column, final int row); Integer getHighlightCellColumnIndex(); Integer getHighlightCellRowIndex();  }
@Test public void testGetMergedCellsCount() { final GridData model = mock(GridData.class); final GridCell cell = mock(GridCell.class); final int rowIndex = 0; final int columnIndex = 1; final int mergedCellsCount = 1; when(renderer.getHighlightCellColumnIndex()).thenReturn(columnIndex); when(model.getCell(rowIndex, columnIndex)).thenReturn(cell); when(cell.getMergedCellCount()).thenReturn(mergedCellsCount); final int actual = renderer.getMergedCellsCount(model, rowIndex); assertEquals(mergedCellsCount, actual); }