File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
main/java/com/flowingcode/vaadin/addons/gridhelpers
test/java/com/flowingcode/vaadin/addons/gridhelpers/test Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 2424import com .vaadin .flow .component .grid .FooterRow .FooterCell ;
2525import com .vaadin .flow .component .grid .Grid ;
2626import java .io .Serializable ;
27+ import java .util .Objects ;
2728import lombok .RequiredArgsConstructor ;
2829
2930@ SuppressWarnings ("serial" )
@@ -35,6 +36,7 @@ class FooterToolbarGridHelper implements Serializable {
3536 private FooterCell footerCell ;
3637
3738 public void setFooterToolbar (Component toolBar ) {
39+ Objects .requireNonNull (toolBar , "Toolbar component must not be null" );
3840 Grid <?> grid = helper .getGrid ();
3941 if (grid .getColumns ().isEmpty ()) {
4042 throw new IllegalStateException ("Cannot set footer toolbar: Grid columns have not been configured." );
Original file line number Diff line number Diff line change 1919 */
2020package com .flowingcode .vaadin .addons .gridhelpers .test ;
2121
22+ import com .flowingcode .vaadin .addons .gridhelpers .GridHelper ;
2223import com .flowingcode .vaadin .addons .gridhelpers .GridHelper ;
2324import com .vaadin .flow .component .grid .Grid ;
2425import com .vaadin .flow .component .orderedlayout .HorizontalLayout ;
26+ import org .junit .Assert ;
2527import org .junit .Test ;
2628
2729public class FooterToolbarTest {
@@ -42,4 +44,16 @@ public void testSetFooterToolbarBeforeColumnsConfiguredThrowsException() {
4244 var toolbarFooter = new HorizontalLayout ();
4345 GridHelper .addToolbarFooter (grid , toolbarFooter );
4446 }
47+
48+ @ Test (expected = NullPointerException .class )
49+ public void testSetFooterToolbarWithNullToolbarThrowsException () {
50+ Grid <Bean > grid = new Grid <>(Bean .class , false );
51+ grid .addColumn (x -> x ).setHeader ("Header" );
52+ try {
53+ GridHelper .addToolbarFooter (grid , null );
54+ } catch (NullPointerException e ) {
55+ Assert .assertEquals ("Toolbar component must not be null" , e .getMessage ());
56+ throw e ;
57+ }
58+ }
4559}
You can’t perform that action at this time.
0 commit comments