aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/test')
-rw-r--r--server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java2
-rw-r--r--server/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java24
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractListingTest.java4
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java118
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java122
-rw-r--r--server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java5
6 files changed, 123 insertions, 152 deletions
diff --git a/server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java b/server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java
index f8a4313b09..c4725471da 100644
--- a/server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java
@@ -157,7 +157,7 @@ public class BinderMultiSelectTest
converterBinder.readBean(new AtomicReference<>("TWO"));
assertEquals(Collections.singleton(TestEnum.TWO),
- select.getSelectionModel().getSelectedItems());
+ select.getSelectedItems());
}
@Test
diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java
index 0522e26ac9..572413bb99 100644
--- a/server/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java
+++ b/server/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java
@@ -1,5 +1,7 @@
package com.vaadin.tests.components.grid;
+import java.util.Optional;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -18,17 +20,17 @@ public class GridSelectionTest {
@Test
public void testGridWithSingleSelection() {
- Assert.assertFalse(grid.isSelected("Foo"));
- grid.select("Foo");
- Assert.assertTrue(grid.isSelected("Foo"));
- Assert.assertEquals(1, grid.getSelectedItems().size());
- Assert.assertEquals("Foo", grid.getSelectedItems().iterator().next());
- grid.select("Bar");
- Assert.assertFalse(grid.isSelected("Foo"));
- Assert.assertTrue(grid.isSelected("Bar"));
- grid.deselect("Bar");
- Assert.assertFalse(grid.isSelected("Bar"));
- Assert.assertEquals(0, grid.getSelectedItems().size());
+ Assert.assertFalse(grid.getSelectionModel().isSelected("Foo"));
+ grid.getSelectionModel().select("Foo");
+ Assert.assertTrue(grid.getSelectionModel().isSelected("Foo"));
+ Assert.assertEquals(Optional.of("Foo"), grid.getSelectedItem());
+ grid.getSelectionModel().select("Bar");
+ Assert.assertFalse(grid.getSelectionModel().isSelected("Foo"));
+ Assert.assertTrue(grid.getSelectionModel().isSelected("Bar"));
+ grid.getSelectionModel().deselect("Bar");
+ Assert.assertFalse(grid.getSelectionModel().isSelected("Bar"));
+ Assert.assertFalse(
+ grid.getSelectionModel().getSelectedItem().isPresent());
}
}
diff --git a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
index 585dce1f5e..494fc2e1c5 100644
--- a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
+++ b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
@@ -22,10 +22,6 @@ public class AbstractListingTest {
private final class TestListing extends AbstractSingleSelect<String> {
- protected TestListing() {
- setSelectionModel(new SimpleSingleSelection());
- }
-
/**
* Used to execute data generation
*/
diff --git a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java
index 6d748f076a..92c288fc34 100644
--- a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java
+++ b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java
@@ -37,7 +37,6 @@ import org.junit.runners.Parameterized.Parameters;
import org.mockito.Mockito;
import com.vaadin.data.HasValue.ValueChangeEvent;
-import com.vaadin.data.SelectionModel.Multi;
import com.vaadin.event.selection.MultiSelectionEvent;
import com.vaadin.event.selection.MultiSelectionListener;
import com.vaadin.server.data.DataSource;
@@ -56,18 +55,16 @@ public class AbstractMultiSelectTest {
@Parameter
public AbstractMultiSelect<String> selectToTest;
- private Multi<String> selectionModel;
private MultiSelectServerRpc rpc;
private Registration registration;
@Before
public void setUp() {
- selectToTest.getSelectionModel().deselectAll();
+ selectToTest.deselectAll();
// Intentional deviation from upcoming selection order
selectToTest.setDataSource(
DataSource.create("3", "2", "1", "5", "8", "7", "4", "6"));
- selectionModel = selectToTest.getSelectionModel();
rpc = ComponentTest.getRpcProxy(selectToTest,
MultiSelectServerRpc.class);
}
@@ -82,28 +79,28 @@ public class AbstractMultiSelectTest {
@Test
public void stableSelectionOrder() {
- selectionModel.select("1");
- selectionModel.select("2");
- selectionModel.select("3");
+ selectToTest.select("1");
+ selectToTest.select("2");
+ selectToTest.select("3");
- assertSelectionOrder(selectionModel, "1", "2", "3");
+ assertSelectionOrder("1", "2", "3");
- selectionModel.deselect("1");
- assertSelectionOrder(selectionModel, "2", "3");
+ selectToTest.deselect("1");
+ assertSelectionOrder("2", "3");
- selectionModel.select("1");
- assertSelectionOrder(selectionModel, "2", "3", "1");
+ selectToTest.select("1");
+ assertSelectionOrder("2", "3", "1");
- selectionModel.selectItems("7", "8", "4");
- assertSelectionOrder(selectionModel, "2", "3", "1", "7", "8", "4");
+ selectToTest.select("7", "8", "4");
+ assertSelectionOrder("2", "3", "1", "7", "8", "4");
- selectionModel.deselectItems("2", "1", "4", "5");
- assertSelectionOrder(selectionModel, "3", "7", "8");
+ selectToTest.deselect("2", "1", "4", "5");
+ assertSelectionOrder("3", "7", "8");
- selectionModel.updateSelection(
+ selectToTest.updateSelection(
new LinkedHashSet<>(Arrays.asList("5", "2")),
new LinkedHashSet<>(Arrays.asList("3", "8")));
- assertSelectionOrder(selectionModel, "7", "5", "2");
+ assertSelectionOrder("7", "5", "2");
}
@Test
@@ -120,27 +117,27 @@ public class AbstractMultiSelectTest {
selectToTest.select("2");
selectToTest.deselect("2");
- selectToTest.getSelectionModel().deselectAll();
+ selectToTest.deselectAll();
- selectToTest.getSelectionModel().selectItems("2", "3", "4");
- selectToTest.getSelectionModel().deselectItems("1", "4");
+ selectToTest.select("2", "3", "4");
+ selectToTest.deselect("1", "4");
Assert.assertEquals(6, listenerCount.get());
// select partly selected
- selectToTest.getSelectionModel().selectItems("2", "3", "4");
+ selectToTest.select("2", "3", "4");
Assert.assertEquals(7, listenerCount.get());
// select completely selected
- selectToTest.getSelectionModel().selectItems("2", "3", "4");
+ selectToTest.select("2", "3", "4");
Assert.assertEquals(7, listenerCount.get());
// deselect partly not selected
- selectToTest.getSelectionModel().selectItems("1", "4");
+ selectToTest.select("1", "4");
Assert.assertEquals(8, listenerCount.get());
// deselect completely not selected
- selectToTest.getSelectionModel().selectItems("1", "4");
+ selectToTest.select("1", "4");
Assert.assertEquals(8, listenerCount.get());
}
@@ -154,88 +151,88 @@ public class AbstractMultiSelectTest {
});
rpcSelect("1");
- assertSelectionOrder(selectionModel, "1");
+ assertSelectionOrder("1");
rpcSelect("2");
- assertSelectionOrder(selectionModel, "1", "2");
- rpcDeselect("2");
- assertSelectionOrder(selectionModel, "1");
+ assertSelectionOrder("1", "2");
+ rpcDeselectItems("2");
+ assertSelectionOrder("1");
rpcSelect("3", "6");
- assertSelectionOrder(selectionModel, "1", "3", "6");
- rpcDeselect("1", "3");
- assertSelectionOrder(selectionModel, "6");
+ assertSelectionOrder("1", "3", "6");
+ rpcDeselectItems("1", "3");
+ assertSelectionOrder("6");
Assert.assertEquals(5, listenerCount.get());
// select partly selected
rpcSelect("2", "3", "4");
Assert.assertEquals(6, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "2", "3", "4");
+ assertSelectionOrder("6", "2", "3", "4");
// select completely selected
rpcSelect("2", "3", "4");
Assert.assertEquals(6, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "2", "3", "4");
+ assertSelectionOrder("6", "2", "3", "4");
// deselect partly not selected
- rpcDeselect("1", "4");
+ rpcDeselectItems("1", "4");
Assert.assertEquals(7, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "2", "3");
+ assertSelectionOrder("6", "2", "3");
// deselect completely not selected
- rpcDeselect("1", "4");
+ rpcDeselectItems("1", "4");
Assert.assertEquals(7, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "2", "3");
+ assertSelectionOrder("6", "2", "3");
// select completely selected and deselect completely not selected
rpcUpdateSelection(new String[] { "3" }, new String[] { "1", "4" });
Assert.assertEquals(7, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "2", "3");
+ assertSelectionOrder("6", "2", "3");
// select partly selected and deselect completely not selected
rpcUpdateSelection(new String[] { "4", "2" },
new String[] { "1", "8" });
Assert.assertEquals(8, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "2", "3", "4");
+ assertSelectionOrder("6", "2", "3", "4");
// select completely selected and deselect partly not selected
rpcUpdateSelection(new String[] { "4", "3" },
new String[] { "1", "2" });
Assert.assertEquals(9, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "3", "4");
+ assertSelectionOrder("6", "3", "4");
// duplicate case - ignored
rpcUpdateSelection(new String[] { "2" }, new String[] { "2" });
Assert.assertEquals(9, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "3", "4");
+ assertSelectionOrder("6", "3", "4");
// duplicate case - duplicate removed
rpcUpdateSelection(new String[] { "2" }, new String[] { "2", "3" });
Assert.assertEquals(10, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "4");
+ assertSelectionOrder("6", "4");
// duplicate case - duplicate removed
rpcUpdateSelection(new String[] { "6", "8" }, new String[] { "6" });
Assert.assertEquals(11, listenerCount.get());
- assertSelectionOrder(selectionModel, "6", "4", "8");
+ assertSelectionOrder("6", "4", "8");
}
@Test
public void getValue() {
- selectionModel.selectItems("1");
+ selectToTest.select("1");
Assert.assertEquals(Collections.singleton("1"),
selectToTest.getValue());
- selectionModel.deselectAll();
+ selectToTest.deselectAll();
LinkedHashSet<String> set = new LinkedHashSet<>();
set.add("1");
set.add("5");
- selectionModel.selectItems(set.toArray(new String[2]));
+ selectToTest.select(set.toArray(new String[2]));
Assert.assertEquals(set, selectToTest.getValue());
set.add("3");
- selectionModel.selectItems("3");
+ selectToTest.select("3");
Assert.assertEquals(set, selectToTest.getValue());
}
@@ -259,26 +256,21 @@ public class AbstractMultiSelectTest {
selectToTest.setValue(Collections.singleton("1"));
Assert.assertEquals(Collections.singleton("1"),
- selectionModel.getSelectedItems());
+ selectToTest.getSelectedItems());
Set<String> set = new LinkedHashSet<>();
set.add("4");
set.add("3");
selectToTest.setValue(set);
- Assert.assertEquals(set, selectionModel.getSelectedItems());
+ Assert.assertEquals(set, selectToTest.getSelectedItems());
}
@Test
@SuppressWarnings({ "unchecked", "rawtypes", "serial" })
public void setValue_isDelegatedToDeselectAndUpdateSelection() {
- Multi<?> model = Mockito.mock(Multi.class);
- AbstractMultiSelect<String> select = new AbstractMultiSelect<String>() {
- @Override
- public Multi<String> getSelectionModel() {
- return (Multi<String>) model;
- }
- };
+ AbstractMultiSelect<String> select = Mockito
+ .mock(AbstractMultiSelect.class);
Set set = new LinkedHashSet<>();
set.add("foo1");
@@ -287,11 +279,12 @@ public class AbstractMultiSelectTest {
selected.add("bar1");
selected.add("bar");
selected.add("bar2");
- Mockito.when(model.getSelectedItems()).thenReturn(selected);
+ Mockito.when(select.getSelectedItems()).thenReturn(selected);
+ Mockito.doCallRealMethod().when(select).setValue(Mockito.anySet());
select.setValue(set);
- Mockito.verify(model).updateSelection(set, selected);
+ Mockito.verify(select).updateSelection(set, selected);
}
@SuppressWarnings({ "unchecked", "serial" })
@@ -336,7 +329,7 @@ public class AbstractMultiSelectTest {
rpcUpdateSelection(keysToSelect, new String[] {});
}
- private void rpcDeselect(String... keysToDeselect) {
+ private void rpcDeselectItems(String... keysToDeselect) {
rpcUpdateSelection(new String[] {}, keysToDeselect);
}
@@ -353,9 +346,8 @@ public class AbstractMultiSelectTest {
.key(dataObject);
}
- private static void assertSelectionOrder(Multi<String> selectionModel,
- String... selectionOrder) {
+ private void assertSelectionOrder(String... selectionOrder) {
Assert.assertEquals(Arrays.asList(selectionOrder),
- new ArrayList<>(selectionModel.getSelectedItems()));
+ new ArrayList<>(selectToTest.getSelectedItems()));
}
}
diff --git a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java
index 6ae5c91b96..47f5fbc81d 100644
--- a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java
+++ b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
@@ -34,13 +33,11 @@ import org.junit.Test;
import org.mockito.Mockito;
import com.vaadin.data.HasValue.ValueChangeEvent;
-import com.vaadin.data.SelectionModel.Multi;
import com.vaadin.event.selection.SingleSelectionChangeEvent;
import com.vaadin.event.selection.SingleSelectionListener;
import com.vaadin.server.data.datasource.bov.Person;
import com.vaadin.shared.Registration;
import com.vaadin.shared.data.DataCommunicatorClientRpc;
-import com.vaadin.ui.AbstractSingleSelect.AbstractSingleSelection;
/**
* Test for {@link AbstractSingleSelect} and {@link AbstractSingleSelection}
@@ -49,20 +46,15 @@ import com.vaadin.ui.AbstractSingleSelect.AbstractSingleSelection;
*/
public class AbstractSingleSelectTest {
- private PersonListing.AbstractSingleSelection selectionModel;
private List<Person> selectionChanges;
private static class PersonListing extends AbstractSingleSelect<Person> {
- public PersonListing() {
- setSelectionModel(new SimpleSingleSelection());
- }
}
@Before
public void initListing() {
listing = new PersonListing();
listing.setItems(PERSON_A, PERSON_B, PERSON_C);
- selectionModel = listing.getSelectionModel();
selectionChanges = new ArrayList<>();
listing.addSelectionListener(e -> selectionChanges.add(e.getValue()));
}
@@ -77,18 +69,17 @@ public class AbstractSingleSelectTest {
@Test
public void select() {
- selectionModel.select(PERSON_B);
+ listing.select(PERSON_B);
- assertTrue(selectionModel.getSelectedItem().isPresent());
+ assertTrue(listing.getSelectedItem().isPresent());
- assertEquals(PERSON_B, selectionModel.getSelectedItem().orElse(null));
+ assertEquals(PERSON_B, listing.getSelectedItem().orElse(null));
- assertFalse(selectionModel.isSelected(PERSON_A));
- assertTrue(selectionModel.isSelected(PERSON_B));
- assertFalse(selectionModel.isSelected(PERSON_C));
+ assertFalse(listing.isSelected(PERSON_A));
+ assertTrue(listing.isSelected(PERSON_B));
+ assertFalse(listing.isSelected(PERSON_C));
- assertEquals(Collections.singleton(PERSON_B),
- selectionModel.getSelectedItems());
+ assertEquals(Optional.of(PERSON_B), listing.getSelectedItem());
assertEquals(Arrays.asList(PERSON_B), selectionChanges);
}
@@ -96,16 +87,16 @@ public class AbstractSingleSelectTest {
@Test
public void selectDeselect() {
- selectionModel.select(PERSON_B);
- selectionModel.deselect(PERSON_B);
+ listing.select(PERSON_B);
+ listing.deselect(PERSON_B);
- assertFalse(selectionModel.getSelectedItem().isPresent());
+ assertFalse(listing.getSelectedItem().isPresent());
- assertFalse(selectionModel.isSelected(PERSON_A));
- assertFalse(selectionModel.isSelected(PERSON_B));
- assertFalse(selectionModel.isSelected(PERSON_C));
+ assertFalse(listing.isSelected(PERSON_A));
+ assertFalse(listing.isSelected(PERSON_B));
+ assertFalse(listing.isSelected(PERSON_C));
- assertTrue(selectionModel.getSelectedItems().isEmpty());
+ assertFalse(listing.getSelectedItem().isPresent());
assertEquals(Arrays.asList(PERSON_B, null), selectionChanges);
}
@@ -113,17 +104,16 @@ public class AbstractSingleSelectTest {
@Test
public void reselect() {
- selectionModel.select(PERSON_B);
- selectionModel.select(PERSON_C);
+ listing.select(PERSON_B);
+ listing.select(PERSON_C);
- assertEquals(PERSON_C, selectionModel.getSelectedItem().orElse(null));
+ assertEquals(PERSON_C, listing.getSelectedItem().orElse(null));
- assertFalse(selectionModel.isSelected(PERSON_A));
- assertFalse(selectionModel.isSelected(PERSON_B));
- assertTrue(selectionModel.isSelected(PERSON_C));
+ assertFalse(listing.isSelected(PERSON_A));
+ assertFalse(listing.isSelected(PERSON_B));
+ assertTrue(listing.isSelected(PERSON_C));
- assertEquals(Collections.singleton(PERSON_C),
- selectionModel.getSelectedItems());
+ assertEquals(Optional.of(PERSON_C), listing.getSelectedItem());
assertEquals(Arrays.asList(PERSON_B, PERSON_C), selectionChanges);
}
@@ -131,17 +121,16 @@ public class AbstractSingleSelectTest {
@Test
public void deselectNoOp() {
- selectionModel.select(PERSON_C);
- selectionModel.deselect(PERSON_B);
+ listing.select(PERSON_C);
+ listing.deselect(PERSON_B);
- assertEquals(PERSON_C, selectionModel.getSelectedItem().orElse(null));
+ assertEquals(PERSON_C, listing.getSelectedItem().orElse(null));
- assertFalse(selectionModel.isSelected(PERSON_A));
- assertFalse(selectionModel.isSelected(PERSON_B));
- assertTrue(selectionModel.isSelected(PERSON_C));
+ assertFalse(listing.isSelected(PERSON_A));
+ assertFalse(listing.isSelected(PERSON_B));
+ assertTrue(listing.isSelected(PERSON_C));
- assertEquals(Collections.singleton(PERSON_C),
- selectionModel.getSelectedItems());
+ assertEquals(Optional.of(PERSON_C), listing.getSelectedItem());
assertEquals(Arrays.asList(PERSON_C), selectionChanges);
}
@@ -149,17 +138,16 @@ public class AbstractSingleSelectTest {
@Test
public void selectTwice() {
- selectionModel.select(PERSON_C);
- selectionModel.select(PERSON_C);
+ listing.select(PERSON_C);
+ listing.select(PERSON_C);
- assertEquals(PERSON_C, selectionModel.getSelectedItem().orElse(null));
+ assertEquals(PERSON_C, listing.getSelectedItem().orElse(null));
- assertFalse(selectionModel.isSelected(PERSON_A));
- assertFalse(selectionModel.isSelected(PERSON_B));
- assertTrue(selectionModel.isSelected(PERSON_C));
+ assertFalse(listing.isSelected(PERSON_A));
+ assertFalse(listing.isSelected(PERSON_B));
+ assertTrue(listing.isSelected(PERSON_C));
- assertEquals(Collections.singleton(PERSON_C),
- selectionModel.getSelectedItems());
+ assertEquals(Optional.of(PERSON_C), listing.getSelectedItem());
assertEquals(Arrays.asList(PERSON_C), selectionChanges);
}
@@ -167,28 +155,28 @@ public class AbstractSingleSelectTest {
@Test
public void deselectTwice() {
- selectionModel.select(PERSON_C);
- selectionModel.deselect(PERSON_C);
- selectionModel.deselect(PERSON_C);
+ listing.select(PERSON_C);
+ listing.deselect(PERSON_C);
+ listing.deselect(PERSON_C);
- assertFalse(selectionModel.getSelectedItem().isPresent());
+ assertFalse(listing.getSelectedItem().isPresent());
- assertFalse(selectionModel.isSelected(PERSON_A));
- assertFalse(selectionModel.isSelected(PERSON_B));
- assertFalse(selectionModel.isSelected(PERSON_C));
+ assertFalse(listing.isSelected(PERSON_A));
+ assertFalse(listing.isSelected(PERSON_B));
+ assertFalse(listing.isSelected(PERSON_C));
- assertTrue(selectionModel.getSelectedItems().isEmpty());
+ assertFalse(listing.getSelectedItem().isPresent());
assertEquals(Arrays.asList(PERSON_C, null), selectionChanges);
}
@Test
public void getValue() {
- selectionModel.setSelectedItem(PERSON_B);
+ listing.setSelectedItem(PERSON_B);
Assert.assertEquals(PERSON_B, listing.getValue());
- selectionModel.deselectAll();
+ listing.deselect(PERSON_B);
Assert.assertNull(listing.getValue());
}
@@ -211,11 +199,11 @@ public class AbstractSingleSelectTest {
public void setValue() {
listing.setValue(PERSON_C);
- Assert.assertEquals(PERSON_C, selectionModel.getSelectedItem().get());
+ Assert.assertEquals(PERSON_C, listing.getSelectedItem().get());
listing.setValue(null);
- Assert.assertFalse(selectionModel.getSelectedItem().isPresent());
+ Assert.assertFalse(listing.getSelectedItem().isPresent());
}
@Test
@@ -268,15 +256,10 @@ public class AbstractSingleSelectTest {
}
@Test
- @SuppressWarnings({ "unchecked", "rawtypes", "serial" })
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public void setValue_isDelegatedToDeselectAndUpdateSelection() {
- Multi<?> model = Mockito.mock(Multi.class);
- AbstractMultiSelect<String> select = new AbstractMultiSelect<String>() {
- @Override
- public Multi<String> getSelectionModel() {
- return (Multi<String>) model;
- }
- };
+ AbstractMultiSelect<String> select = Mockito
+ .mock(AbstractMultiSelect.class);
Set set = new LinkedHashSet<>();
set.add("foo1");
@@ -285,11 +268,12 @@ public class AbstractSingleSelectTest {
selected.add("bar1");
selected.add("bar");
selected.add("bar2");
- Mockito.when(model.getSelectedItems()).thenReturn(selected);
+ Mockito.when(select.getSelectedItems()).thenReturn(selected);
+ Mockito.doCallRealMethod().when(select).setValue(Mockito.anySet());
select.setValue(set);
- Mockito.verify(model).updateSelection(set, selected);
+ Mockito.verify(select).updateSelection(set, selected);
}
}
diff --git a/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java b/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java
index 31bc2de271..ea1cf39351 100644
--- a/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java
+++ b/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java
@@ -23,14 +23,12 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import com.vaadin.data.SelectionModel;
import com.vaadin.data.SelectionModel.Multi;
import com.vaadin.server.data.DataSource;
import com.vaadin.shared.data.selection.SelectionServerRpc;
public class RadioButtonGroupTest {
private RadioButtonGroup<String> radioButtonGroup;
- private SelectionModel.Single<String> selectionModel;
@Before
public void setUp() {
@@ -38,7 +36,6 @@ public class RadioButtonGroupTest {
// Intentional deviation from upcoming selection order
radioButtonGroup
.setDataSource(DataSource.create("Third", "Second", "First"));
- selectionModel = radioButtonGroup.getSelectionModel();
}
@Test
@@ -54,7 +51,7 @@ public class RadioButtonGroupTest {
radioButtonGroup.select("Second");
radioButtonGroup.deselect("Second");
- radioButtonGroup.getSelectionModel().deselectAll();
+ radioButtonGroup.deselect("Second");
Assert.assertEquals(3, listenerCount.get());
}