ScenarioGridColumnRenderer extends StringColumnRenderer { @Override public Group renderCell(final GridCell<String> cell, final GridBodyCellRenderContext context) { if (cell == null || cell.getValue() == null || (cell.getValue().getValue() == null && cell.getValue().getPlaceHolder() == null)) { return null; } final ScenarioGridRendererTheme theme = (ScenarioGridRendererTheme) context.getRenderer().getTheme(); Text text; String value; if ((cell instanceof ScenarioGridCell) && cell.getValue() != null && (cell.getValue().getValue() == null || cell.getValue().getValue().isEmpty() ) && cell.getValue().getPlaceHolder() != null) { text = theme.getPlaceholderText(); value = cell.getValue().getPlaceHolder(); } else { text = ((ScenarioGridCell) cell).isErrorMode() ? theme.getErrorText() : theme.getBodyText(); value = getValueToShow((ScenarioGridCell) cell); } return internalRenderCell(cell, context, text, value); }  @Override Group renderCell(final GridCell<String> cell,
                            final GridBodyCellRenderContext context); @Override List<GridRenderer.RendererCommand> renderColumn(GridColumn<?> column, GridBodyColumnRenderContext context, BaseGridRendererHelper rendererHelper, BaseGridRendererHelper.RenderingInformation renderingInformation, BiFunction<Boolean, GridColumn<?>, Boolean> columnRenderingConstraint);  }
@Test public void renderCell() { GridCell<String> cell = null; Group retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNull(retrieved); verify(scenarioGridColumnRenderer, never()).internalRenderCell(any(), eq(contextMock), any(), anyString()); verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean()); cell = new ScenarioGridCell(null); retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNull(retrieved); verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean()); verify(scenarioGridColumnRenderer, never()).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(null)); reset(scenarioGridColumnRenderer); cell = new ScenarioGridCell(new ScenarioGridCellValue(null)); retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNull(retrieved); verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean()); verify(scenarioGridColumnRenderer, never()).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(null)); reset(scenarioGridColumnRenderer); cell = new ScenarioGridCell(new ScenarioGridCellValue(MULTIPART_VALUE)); retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNotNull(retrieved); verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean()); verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(MULTIPART_VALUE)); reset(scenarioGridColumnRenderer); ScenarioGridCell scenarioGridCell = new ScenarioGridCell(new ScenarioGridCellValue(MULTIPART_VALUE, PLACEHOLDER)); retrieved = scenarioGridColumnRenderer.renderCell(scenarioGridCell, contextMock); assertNotNull(retrieved); verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean()); verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(MULTIPART_VALUE)); reset(scenarioGridColumnRenderer); scenarioGridCell = new ScenarioGridCell(new ScenarioGridCellValue(null, PLACEHOLDER)); retrieved = scenarioGridColumnRenderer.renderCell(scenarioGridCell, contextMock); assertNotNull(retrieved); verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(placeholderMock), eq(PLACEHOLDER)); verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean()); reset(scenarioGridColumnRenderer); cell = new ScenarioGridCell(new ScenarioGridCellValue(LIST_VALUE)); ((ScenarioGridCell) cell).setListMap(true); retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNotNull(retrieved); verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(LIST_VALUE)); verify(scenarioGridColumnRenderer, times(1)).getCollectionString(eq(LIST_VALUE), eq(true)); reset(scenarioGridColumnRenderer); cell = new ScenarioGridCell(new ScenarioGridCellValue(MAP_VALUE)); ((ScenarioGridCell) cell).setListMap(false); retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNotNull(retrieved); verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(MAP_VALUE)); verify(scenarioGridColumnRenderer, times(1)).getCollectionString(eq(MAP_VALUE), eq(false)); reset(scenarioGridColumnRenderer); cell = new ScenarioGridCell(new ScenarioGridCellValue(EXPRESSION_VALUE)); ((ScenarioGridCell) cell).setListMap(true); retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNotNull(retrieved); verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(EXPRESSION_VALUE)); verify(scenarioGridColumnRenderer, times(1)).getCollectionString(eq(EXPRESSION_VALUE), eq(true)); reset(scenarioGridColumnRenderer); cell = new ScenarioGridCell(new ScenarioGridCellValue(EXPRESSION_VALUE)); ((ScenarioGridCell) cell).setListMap(false); retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNotNull(retrieved); verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(EXPRESSION_VALUE)); verify(scenarioGridColumnRenderer, times(1)).getCollectionString(eq(EXPRESSION_VALUE), eq(false)); reset(scenarioGridColumnRenderer); cell = new ScenarioGridCell(new ScenarioGridCellValue(MULTIPART_VALUE)); ((ScenarioGridCell) cell).setErrorMode(true); retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock); assertNotNull(retrieved); verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean()); verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(errorTextMock), eq(MULTIPART_VALUE)); reset(scenarioGridColumnRenderer); }