BooleanUiColumn extends BaseMultipleDOMElementUiColumn<Boolean, CheckBox, CheckBoxDOMElement, CheckBoxDOMElementFactory> { @Override public void edit( final GridCell<Boolean> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<Boolean>> callback ) { if ( !isEditable() ) { return; } callback.accept( new GuidedDecisionTableUiCell<>( !cell.getValue().getValue() ) ); } BooleanUiColumn( final List<HeaderMetaData> headerMetaData,
                            final double width,
                            final boolean isResizable,
                            final boolean isVisible,
                            final GuidedDecisionTablePresenter.Access access,
                            final CheckBoxDOMElementFactory factory ); @Override void edit( final GridCell<Boolean> cell,
                      final GridBodyCellRenderContext context,
                      final Consumer<GridCellValue<Boolean>> callback );  }
@Test @SuppressWarnings("unchecked") public void editTrueToFalse() { when( access.isEditable() ).thenReturn( true ); final GridCell<Boolean> cell = new BaseGridCell<>( new BaseGridCellValue<>( true ) ); column.edit( cell, context, callback ); verify( callback, times( 1 ) ).accept( callbackArgumentCaptor.capture() ); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertFalse( callbackArgument.getValue() ); }
@Test @SuppressWarnings("unchecked") public void editFalseToTrue() { when( access.isEditable() ).thenReturn( true ); final GridCell<Boolean> cell = new BaseGridCell<>( new BaseGridCellValue<>( false ) ); column.edit( cell, context, callback ); verify( callback, times( 1 ) ).accept( callbackArgumentCaptor.capture() ); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertTrue( callbackArgument.getValue() ); }
@Test @SuppressWarnings("unchecked") public void editReadOnly() { when( access.isEditable() ).thenReturn( false ); final GridCell<Boolean> cell = new BaseGridCell<>( new BaseGridCellValue<>( true ) ); column.edit( cell, context, callback ); verify( callback, never() ).accept( any( BaseGridCellValue.class ) ); }