From c39b1a97873dec26f5143739f5d460455ee864a7 Mon Sep 17 00:00:00 2001 From: Vaadin Bot Date: Mon, 28 Nov 2022 13:00:41 +0100 Subject: [PATCH] fix: use correct null check in setTooltipGenerator (#4236) (#4239) Co-authored-by: Serhii Kulykov --- .../src/main/java/com/vaadin/flow/component/grid/Grid.java | 2 +- .../java/com/vaadin/flow/component/grid/GridTooltipTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java b/vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java index 70cbdc8336c..d7bcc3d9875 100755 --- a/vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java +++ b/vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java @@ -1044,7 +1044,7 @@ public Column setClassNameGenerator( */ public Column setTooltipGenerator( SerializableFunction tooltipGenerator) { - Objects.requireNonNull(classNameGenerator, + Objects.requireNonNull(tooltipGenerator, "Tooltip generator can not be null"); if (!getGrid().getElement().getChildren().anyMatch( diff --git a/vaadin-grid-flow-parent/vaadin-grid-flow/src/test/java/com/vaadin/flow/component/grid/GridTooltipTest.java b/vaadin-grid-flow-parent/vaadin-grid-flow/src/test/java/com/vaadin/flow/component/grid/GridTooltipTest.java index 4418a9bedbc..19702f60a19 100644 --- a/vaadin-grid-flow-parent/vaadin-grid-flow/src/test/java/com/vaadin/flow/component/grid/GridTooltipTest.java +++ b/vaadin-grid-flow-parent/vaadin-grid-flow/src/test/java/com/vaadin/flow/component/grid/GridTooltipTest.java @@ -71,6 +71,11 @@ public void setAnotherTooltipGenerator_hasOneTooltipElement() { Assert.assertEquals(1, getTooltipElements(grid).count()); } + @Test(expected = NullPointerException.class) + public void setNullTooltipGenerator_throws() { + grid.addColumn(item -> item).setTooltipGenerator(null); + } + private Optional getTooltipElement(Grid grid) { return getTooltipElements(grid).findFirst(); }