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 24
24
import com .vaadin .flow .component .grid .FooterRow .FooterCell ;
25
25
import com .vaadin .flow .component .grid .Grid ;
26
26
import java .io .Serializable ;
27
+ import java .util .Objects ;
27
28
import lombok .RequiredArgsConstructor ;
28
29
29
30
@ SuppressWarnings ("serial" )
@@ -35,6 +36,7 @@ class FooterToolbarGridHelper implements Serializable {
35
36
private FooterCell footerCell ;
36
37
37
38
public void setFooterToolbar (Component toolBar ) {
39
+ Objects .requireNonNull (toolBar , "Toolbar component must not be null" );
38
40
Grid <?> grid = helper .getGrid ();
39
41
if (grid .getColumns ().isEmpty ()) {
40
42
throw new IllegalStateException ("Cannot set footer toolbar: Grid columns have not been configured." );
Original file line number Diff line number Diff line change 19
19
*/
20
20
package com .flowingcode .vaadin .addons .gridhelpers .test ;
21
21
22
+ import com .flowingcode .vaadin .addons .gridhelpers .GridHelper ;
22
23
import com .flowingcode .vaadin .addons .gridhelpers .GridHelper ;
23
24
import com .vaadin .flow .component .grid .Grid ;
24
25
import com .vaadin .flow .component .orderedlayout .HorizontalLayout ;
26
+ import org .junit .Assert ;
25
27
import org .junit .Test ;
26
28
27
29
public class FooterToolbarTest {
@@ -42,4 +44,16 @@ public void testSetFooterToolbarBeforeColumnsConfiguredThrowsException() {
42
44
var toolbarFooter = new HorizontalLayout ();
43
45
GridHelper .addToolbarFooter (grid , toolbarFooter );
44
46
}
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
+ }
45
59
}
You can’t perform that action at this time.
0 commit comments