File tree Expand file tree Collapse file tree 2 files changed +13
-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 +13
-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 2323import com .vaadin .flow .component .grid .Grid ;
2424import com .vaadin .flow .component .orderedlayout .HorizontalLayout ;
2525import org .junit .Test ;
26+ import org .junit .jupiter .api .Assertions ;
2627
2728public class FooterToolbarTest {
2829
@@ -42,4 +43,14 @@ public void testSetFooterToolbarBeforeColumnsConfiguredThrowsException() {
4243 var toolbarFooter = new HorizontalLayout ();
4344 GridHelper .addToolbarFooter (grid , toolbarFooter );
4445 }
46+
47+ @ Test
48+ public void testSetFooterToolbarWithNullToolbarThrowsException () {
49+ Grid <Bean > grid = new Grid <>(Bean .class , false );
50+ grid .addColumn (x -> x ).setHeader ("Header" );
51+ NullPointerException exception = Assertions .assertThrows (NullPointerException .class , () -> {
52+ GridHelper .addToolbarFooter (grid , null );
53+ });
54+ Assertions .assertEquals ("Toolbar component must not be null" , exception .getMessage ());
55+ }
4556}
You can’t perform that action at this time.
0 commit comments