diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-26 21:19:41 +0200 |
---|---|---|
committer | Pekka Maanpää <pekkamaa@vaadin.com> | 2017-10-26 22:19:41 +0300 |
commit | 01c93a6aef27ef562267d7966c6386ecaa6c1f6b (patch) | |
tree | 438810691e69e7751710917c251c2ba677c969d4 /server/src/test | |
parent | 10bd7544fd22dccd7e8e32cb236eb50f102892d3 (diff) | |
download | vaadin-framework-01c93a6aef27ef562267d7966c6386ecaa6c1f6b.tar.gz vaadin-framework-01c93a6aef27ef562267d7966c6386ecaa6c1f6b.zip |
Use lambda with Listeners (#10222)
Also use "event" as the name for events
Diffstat (limited to 'server/src/test')
12 files changed, 33 insertions, 31 deletions
diff --git a/server/src/test/java/com/vaadin/data/BinderTestBase.java b/server/src/test/java/com/vaadin/data/BinderTestBase.java index 92edd734eb..8f4246489f 100644 --- a/server/src/test/java/com/vaadin/data/BinderTestBase.java +++ b/server/src/test/java/com/vaadin/data/BinderTestBase.java @@ -50,7 +50,8 @@ public abstract class BinderTestBase<BINDER extends Binder<ITEM>, ITEM> implemen protected Validator<String> notEmpty = Validator.from(val -> !val.isEmpty(), EMPTY_ERROR_MESSAGE); protected Converter<String, Integer> stringToInteger = Converter.from( - Integer::valueOf, String::valueOf, e -> NOT_NUMBER_ERROR_MESSAGE); + Integer::valueOf, String::valueOf, + e -> NOT_NUMBER_ERROR_MESSAGE); protected Validator<Integer> notNegative = Validator.from(x -> x >= 0, NEGATIVE_ERROR_MESSAGE); diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java index f6696155c2..131dc2025b 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java @@ -136,10 +136,10 @@ public class GridMultiSelectionModelTest { List<String> selectionChanges = new ArrayList<>(); Capture<List<String>> oldSelectionCapture = new Capture<>(); ((MultiSelectionModelImpl<String>) customGrid.getSelectionModel()) - .addMultiSelectionListener(e -> { - selectionChanges.addAll(e.getValue()); + .addMultiSelectionListener(event -> { + selectionChanges.addAll(event.getValue()); oldSelectionCapture - .setValue(new ArrayList<>(e.getOldSelection())); + .setValue(new ArrayList<>(event.getOldSelection())); }); customGrid.getSelectionModel().select("Foo"); diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java index 5791e2bc9d..4fb8b25199 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java @@ -75,7 +75,7 @@ public class GridSingleSelectionModelTest { selectionChanges = new ArrayList<>(); selectionModel.addSingleSelectionListener( - e -> selectionChanges.add(e.getValue())); + event -> selectionChanges.add(event.getValue())); } @Test(expected = IllegalStateException.class) @@ -99,9 +99,9 @@ public class GridSingleSelectionModelTest { List<String> selectionChanges = new ArrayList<>(); List<String> oldSelectionValues = new ArrayList<>(); ((SingleSelectionModelImpl<String>) customGrid.getSelectionModel()) - .addSingleSelectionListener(e -> { - selectionChanges.add(e.getValue()); - oldSelectionValues.add(e.getOldValue()); + .addSingleSelectionListener(event -> { + selectionChanges.add(event.getValue()); + oldSelectionValues.add(event.getOldValue()); }); customGrid.getSelectionModel().select("Foo"); diff --git a/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java b/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java index d7abcd7301..18b6a31b0d 100644 --- a/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java +++ b/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java @@ -34,8 +34,8 @@ public class TreeGridTest { treeData.addItem("Foo", "Baz"); treeGrid.setDataProvider(new TreeDataProvider<>(treeData)); - treeGrid.addExpandListener(e -> expandEventFired = true); - treeGrid.addCollapseListener(e -> collapseEventFired = true); + treeGrid.addExpandListener(event -> expandEventFired = true); + treeGrid.addCollapseListener(event -> collapseEventFired = true); // Test expand event assertFalse(expandEventFired); diff --git a/server/src/test/java/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotation.java b/server/src/test/java/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotation.java index 5a21e7e793..49f56b1889 100644 --- a/server/src/test/java/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotation.java +++ b/server/src/test/java/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotation.java @@ -28,8 +28,8 @@ public class ExtendedDesignWithEmptyAnnotation customField.setPlaceholder("Something"); addComponent(customField); - ok.addClickListener(e -> Notification.show("OK")); + ok.addClickListener(event -> Notification.show("OK")); - CaNCEL.addClickListener(e -> Notification.show("cancel")); + CaNCEL.addClickListener(event -> Notification.show("cancel")); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/button/ButtonClickTest.java b/server/src/test/java/com/vaadin/tests/server/component/button/ButtonClickTest.java index 45844bee25..985dc44358 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/button/ButtonClickTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/button/ButtonClickTest.java @@ -22,7 +22,7 @@ public class ButtonClickTest { public void clickDetachedButton() { Button b = new Button(); AtomicInteger counter = new AtomicInteger(0); - b.addClickListener(e -> counter.incrementAndGet()); + b.addClickListener(event -> counter.incrementAndGet()); b.click(); assertEquals(1, counter.get()); @@ -62,6 +62,6 @@ public class ButtonClickTest { private void addClickListener(Button b) { clicked = false; - b.addClickListener(e -> clicked = true); + b.addClickListener(event -> clicked = true); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java b/server/src/test/java/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java index 54fb58a9c3..dca55603d5 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java @@ -317,9 +317,9 @@ public class TabSheetTest { Button b3 = new Button("b3"); Button b4 = new Button("b4"); TestTabsheet tabsheet = new TestTabsheet(b1, b2, b3, b4); - tabsheet.addSelectedTabChangeListener(e -> { - userOriginated.set(e.isUserOriginated()); - selected.set(e.getTabSheet().getSelectedTab()); + tabsheet.addSelectedTabChangeListener(event -> { + userOriginated.set(event.isUserOriginated()); + selected.set(event.getTabSheet().getSelectedTab()); }); tabsheet.setSelectedTab(b2); diff --git a/server/src/test/java/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java b/server/src/test/java/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java index 50385c5aed..9b20015b37 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java @@ -220,7 +220,8 @@ public class AttachDetachWindowTest { final boolean[] eventFired = new boolean[1]; ui.addComponentAttachListener( - e -> eventFired[0] = e.getAttachedComponent().equals(window)); + event -> eventFired[0] = event.getAttachedComponent() + .equals(window)); ui.addWindow(window); assertTrue("Attach event is not fired for added window", eventFired[0]); } @@ -232,7 +233,8 @@ public class AttachDetachWindowTest { final boolean[] eventFired = new boolean[1]; ui.addComponentDetachListener( - e -> eventFired[0] = e.getDetachedComponent().equals(window)); + event -> eventFired[0] = event.getDetachedComponent() + .equals(window)); ui.addWindow(window); ui.removeWindow(window); diff --git a/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java index ee520a78f9..1d50bb8537 100644 --- a/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java +++ b/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java @@ -1167,13 +1167,10 @@ public class NavigatorTest { AtomicReference<Map<String, String>> mapRef = new AtomicReference<>(); AtomicReference<Map<String, String>> mapRefB = new AtomicReference<>(); - navigator.addViewChangeListener(new ViewChangeListener() { - @Override - public boolean beforeViewChange(ViewChangeEvent event) { - mapRef.set(event.getParameterMap()); - mapRefB.set(event.getParameterMap("b")); - return true; - } + navigator.addViewChangeListener(event -> { + mapRef.set(event.getParameterMap()); + mapRefB.set(event.getParameterMap("b")); + return true; }); navigator.navigateTo("view1"); diff --git a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java index 6dafbfb812..a89b4459b9 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java @@ -84,8 +84,10 @@ public class AbstractSingleSelectTest { selectionChanges = new ArrayList<>(); oldSelections = new ArrayList<>(); - listing.addSelectionListener(e -> selectionChanges.add(e.getValue())); - listing.addSelectionListener(e -> oldSelections.add(e.getOldValue())); + listing.addSelectionListener( + event -> selectionChanges.add(event.getValue())); + listing.addSelectionListener( + event -> oldSelections.add(event.getOldValue())); } public static final Person PERSON_C = new Person("c", 3); diff --git a/server/src/test/java/com/vaadin/ui/CheckBoxTest.java b/server/src/test/java/com/vaadin/ui/CheckBoxTest.java index 076c129914..63db70636c 100644 --- a/server/src/test/java/com/vaadin/ui/CheckBoxTest.java +++ b/server/src/test/java/com/vaadin/ui/CheckBoxTest.java @@ -50,7 +50,7 @@ public class CheckBoxTest { ui.setContent(cb); AtomicBoolean userOriginated = new AtomicBoolean(false); cb.addValueChangeListener( - e -> userOriginated.set(e.isUserOriginated())); + event -> userOriginated.set(event.isUserOriginated())); ComponentTest.syncToClient(cb); ServerRpcManager.getRpcProxy(cb, CheckBoxServerRpc.class) .setChecked(true, new MouseEventDetails()); @@ -69,7 +69,7 @@ public class CheckBoxTest { ui.setContent(cb); AtomicBoolean userOriginated = new AtomicBoolean(true); cb.addValueChangeListener( - e -> userOriginated.set(e.isUserOriginated())); + event -> userOriginated.set(event.isUserOriginated())); cb.setValue(true); assertFalse(userOriginated.get()); userOriginated.set(true); diff --git a/server/src/test/java/com/vaadin/ui/ComboBoxTest.java b/server/src/test/java/com/vaadin/ui/ComboBoxTest.java index 31ff6fda5a..ee88544305 100644 --- a/server/src/test/java/com/vaadin/ui/ComboBoxTest.java +++ b/server/src/test/java/com/vaadin/ui/ComboBoxTest.java @@ -30,7 +30,7 @@ public class ComboBoxTest { // Reset value whenever it changes (in a real case, this listener would // do something with the selected value before discarding it) - comboBox.addValueChangeListener(e -> comboBox.setValue(null)); + comboBox.addValueChangeListener(event -> comboBox.setValue(null)); // "Attach" the component and initialize diffstate new MockUI().setContent(comboBox); |