Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.vaadin.flow.component.grid.FooterRow.FooterCell;
import com.vaadin.flow.component.grid.Grid;
import java.io.Serializable;
import java.util.Objects;
import lombok.RequiredArgsConstructor;

@SuppressWarnings("serial")
Expand All @@ -35,6 +36,7 @@ class FooterToolbarGridHelper implements Serializable {
private FooterCell footerCell;

public void setFooterToolbar(Component toolBar) {
Objects.requireNonNull(toolBar, "Toolbar component must not be null");
Grid<?> grid = helper.getGrid();
if (grid.getColumns().isEmpty()) {
throw new IllegalStateException("Cannot set footer toolbar: Grid columns have not been configured.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
*/
package com.flowingcode.vaadin.addons.gridhelpers.test;

import com.flowingcode.vaadin.addons.gridhelpers.GridHelper;
import com.flowingcode.vaadin.addons.gridhelpers.GridHelper;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import org.junit.Assert;
import org.junit.Test;

public class FooterToolbarTest {
Expand All @@ -42,4 +44,16 @@ public void testSetFooterToolbarBeforeColumnsConfiguredThrowsException() {
var toolbarFooter = new HorizontalLayout();
GridHelper.addToolbarFooter(grid, toolbarFooter);
}

@Test(expected = NullPointerException.class)
public void testSetFooterToolbarWithNullToolbarThrowsException() {
Grid<Bean> grid = new Grid<>(Bean.class, false);
grid.addColumn(x -> x).setHeader("Header");
try {
GridHelper.addToolbarFooter(grid, null);
} catch (NullPointerException e) {
Assert.assertEquals("Toolbar component must not be null", e.getMessage());
throw e;
}
}
}
Loading