@Override public void edit(final GridCell<Boolean> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<Boolean>> callback) { callback.accept(new BaseGridCellValue<>(!cell.getValue().getValue())); } }
void selectExpressionEditorFirstCell() { final GridCellValue<?> value = model.getCell(0, 0).getValue(); final Optional<BaseExpressionGrid> grid = ((ExpressionCellValue) value).getValue(); grid.ifPresent(beg -> { //It's not possible to set-up GridLayer for ExpressionContainerGrid in Unit Tests so defensively handle nulls Optional.ofNullable(getLayer()).ifPresent(layer -> ((DMNGridLayer) layer).select(beg)); beg.selectFirstCell(); }); }
public static Optional<GridCellValue<?>> extractGridCellValue(final GridCellTuple cellTuple) { final GridCell<?> cell = cellTuple.getGridWidget().getModel().getCell(cellTuple.getRowIndex(), cellTuple.getColumnIndex()); return Optional.ofNullable(cell == null ? null : cell.getValue()); } }
@Test public void testNullCellValue() { doReturn(null).when(cell).getValue(); assertNull(renderer.renderCell(cell, context)); }
@Test public void testNullCellValue() { doReturn(null).when(cell).getValue(); assertNull(renderer.renderCell(cell, context)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, e -> e.getWidget().setValue(assertCell(cell).getValue().getValue()), e -> e.getWidget().setFocus(true)); }
@Test public void testRendering() { doReturn(cellValue).when(cell).getValue(); doReturn(getValueToRender()).when(cellValue).getValue(); final Group g = renderer.renderCell(cell, context); assertNotNull(g); assertEquals(1, g.getChildNodes().size()); assertEquals(text, g.getChildNodes().get(0)); }
@Test public void testInitialisationOfBooleanCellsWithoutDefaultValue() throws VetoException { setupBooleanColumn((c) -> {/*Nothing*/ }); modelSynchronizer.appendRow(); assertFalse(model.getData().get(0).get(2).getBooleanValue()); assertFalse((Boolean) uiModel.getCell(0, 2).getValue().getValue()); }
@Test public void testDeleteRowNumbers() throws VetoException { modelSynchronizer.appendRow(); modelSynchronizer.appendRow(); modelSynchronizer.deleteRow(0); assertEquals(1, uiModel.getRow(0).getCells().get(0).getValue().getValue()); assertEquals(1, model.getData().get(0).get(0).getNumericValue()); }
@Test public void testInitialisationOfBooleanCellsWithNullDefaultValue() throws VetoException { setupBooleanColumn((c) -> c.setDefaultValue(new DTCellValue52((Boolean) null))); modelSynchronizer.appendRow(); assertFalse(model.getData().get(0).get(2).getBooleanValue()); assertFalse((Boolean) uiModel.getCell(0, 2).getValue().getValue()); }
@Test public void testSetCellValueWhenExistingBaseGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(""))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(BaseGridCell.class); }
@Test public void testSetCellValueWhenExistingCustomGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new CustomGridCell<>(new BaseGridCellValue<>("hello"))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(CustomGridCell.class); }
@Test public void testSetCellValueWhenExistingBaseGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(""))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(BaseGridCell.class); }