diff options
author | Denis <denis@vaadin.com> | 2017-01-24 09:26:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-24 09:26:03 +0200 |
commit | 47f068408dd6b98deaf65bbb5d59607c4bc8ca35 (patch) | |
tree | 2b79a339df95112f7e53f0412cd78f43354284c3 /server | |
parent | ee7782f256a9b79f9cc13a659dd2bea930dd0e72 (diff) | |
download | vaadin-framework-47f068408dd6b98deaf65bbb5d59607c4bc8ca35.tar.gz vaadin-framework-47f068408dd6b98deaf65bbb5d59607c4bc8ca35.zip |
Use getFirstSelectedItem() instead of getFirstSelected(). (#8308)
* Use getFirstSelectedItem() instead of getFirstSelected().
Fixes vaadin/framework8-issues#596
Diffstat (limited to 'server')
5 files changed, 15 insertions, 15 deletions
diff --git a/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java b/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java index e00c60dca6..c2bc45fa3c 100644 --- a/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java +++ b/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java @@ -128,7 +128,7 @@ public class MultiSelectionEvent<T> extends ValueChangeEvent<Set<T>> } @Override - public Optional<T> getFirstSelected() { + public Optional<T> getFirstSelectedItem() { return getValue().stream().findFirst(); } diff --git a/server/src/main/java/com/vaadin/event/selection/SelectionEvent.java b/server/src/main/java/com/vaadin/event/selection/SelectionEvent.java index 5389014f93..5252413830 100644 --- a/server/src/main/java/com/vaadin/event/selection/SelectionEvent.java +++ b/server/src/main/java/com/vaadin/event/selection/SelectionEvent.java @@ -40,7 +40,7 @@ public interface SelectionEvent<T> extends Serializable { * * @return the first selected item. */ - Optional<T> getFirstSelected(); + Optional<T> getFirstSelectedItem(); /** * Gets all the currently selected items. diff --git a/server/src/main/java/com/vaadin/event/selection/SingleSelectionEvent.java b/server/src/main/java/com/vaadin/event/selection/SingleSelectionEvent.java index db78e0591b..36feafdd43 100644 --- a/server/src/main/java/com/vaadin/event/selection/SingleSelectionEvent.java +++ b/server/src/main/java/com/vaadin/event/selection/SingleSelectionEvent.java @@ -100,7 +100,7 @@ public class SingleSelectionEvent<T> extends ValueChangeEvent<T> } @Override - public Optional<T> getFirstSelected() { + public Optional<T> getFirstSelectedItem() { return getSelectedItem(); } diff --git a/server/src/test/java/com/vaadin/event/selection/SelectionEventTest.java b/server/src/test/java/com/vaadin/event/selection/SelectionEventTest.java index 8d3559642b..5328ae9336 100644 --- a/server/src/test/java/com/vaadin/event/selection/SelectionEventTest.java +++ b/server/src/test/java/com/vaadin/event/selection/SelectionEventTest.java @@ -34,25 +34,25 @@ public class SelectionEventTest { @Test public void getFirstSelected_mutliSelectEvent() { MultiSelectionEvent<?> event = Mockito.mock(MultiSelectionEvent.class); - Mockito.doCallRealMethod().when(event).getFirstSelected(); + Mockito.doCallRealMethod().when(event).getFirstSelectedItem(); Mockito.when(event.getValue()) .thenReturn(new LinkedHashSet(Arrays.asList("foo", "bar"))); - Optional<?> selected = event.getFirstSelected(); + Optional<?> selected = event.getFirstSelectedItem(); Mockito.verify(event).getValue(); Assert.assertEquals("foo", selected.get()); Mockito.when(event.getValue()).thenReturn(Collections.emptySet()); - Assert.assertFalse(event.getFirstSelected().isPresent()); + Assert.assertFalse(event.getFirstSelectedItem().isPresent()); } @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void getFirstSelected_singleSelectEvent() { SingleSelectionEvent event = Mockito.mock(SingleSelectionEvent.class); - Mockito.doCallRealMethod().when(event).getFirstSelected(); + Mockito.doCallRealMethod().when(event).getFirstSelectedItem(); Mockito.when(event.getSelectedItem()).thenReturn(Optional.of("foo")); @@ -62,7 +62,7 @@ public class SelectionEventTest { Assert.assertEquals("foo", selected.get()); Mockito.when(event.getSelectedItem()).thenReturn(Optional.empty()); - Assert.assertFalse(event.getFirstSelected().isPresent()); + Assert.assertFalse(event.getFirstSelectedItem().isPresent()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java index a692ecc566..73ef2fceeb 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java @@ -95,7 +95,7 @@ public class GridTest { SelectionEvent<String> event = eventCapture.getValue(); assertNotNull(event); assertFalse(event.isUserOriginated()); - assertEquals("foo", event.getFirstSelected().get()); + assertEquals("foo", event.getFirstSelectedItem().get()); assertEquals("foo", event.getAllSelectedItems().stream().findFirst().get()); @@ -104,7 +104,7 @@ public class GridTest { event = eventCapture.getValue(); assertNotNull(event); assertFalse(event.isUserOriginated()); - assertEquals("bar", event.getFirstSelected().get()); + assertEquals("bar", event.getFirstSelectedItem().get()); assertEquals("bar", event.getAllSelectedItems().stream().findFirst().get()); @@ -113,7 +113,7 @@ public class GridTest { event = eventCapture.getValue(); assertNotNull(event); assertFalse(event.isUserOriginated()); - assertEquals(Optional.empty(), event.getFirstSelected()); + assertEquals(Optional.empty(), event.getFirstSelectedItem()); assertEquals(0, event.getAllSelectedItems().size()); } @@ -131,7 +131,7 @@ public class GridTest { SelectionEvent<String> event = eventCapture.getValue(); assertNotNull(event); assertFalse(event.isUserOriginated()); - assertEquals("foo", event.getFirstSelected().get()); + assertEquals("foo", event.getFirstSelectedItem().get()); assertEquals("foo", event.getAllSelectedItems().stream().findFirst().get()); @@ -140,7 +140,7 @@ public class GridTest { event = eventCapture.getValue(); assertNotNull(event); assertFalse(event.isUserOriginated()); - assertEquals("foo", event.getFirstSelected().get()); + assertEquals("foo", event.getFirstSelectedItem().get()); assertEquals("foo", event.getAllSelectedItems().stream().findFirst().get()); Assert.assertArrayEquals(new String[] { "foo", "bar" }, @@ -151,7 +151,7 @@ public class GridTest { event = eventCapture.getValue(); assertNotNull(event); assertFalse(event.isUserOriginated()); - assertEquals("bar", event.getFirstSelected().get()); + assertEquals("bar", event.getFirstSelectedItem().get()); assertEquals("bar", event.getAllSelectedItems().stream().findFirst().get()); Assert.assertArrayEquals(new String[] { "bar" }, @@ -162,7 +162,7 @@ public class GridTest { event = eventCapture.getValue(); assertNotNull(event); assertFalse(event.isUserOriginated()); - assertEquals(Optional.empty(), event.getFirstSelected()); + assertEquals(Optional.empty(), event.getFirstSelectedItem()); assertEquals(0, event.getAllSelectedItems().size()); } |