summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-01-19 15:16:50 +0200
committerHenrik Paul <henrik@vaadin.com>2015-01-20 10:59:25 +0000
commitb9360a29a35a575c136da74f0f3e85a54990a121 (patch)
tree004352cb860c83d3f27e1aa9cb76fb555aaf1379 /server/tests
parentf31ea938f0b811a44c58289304795e0aa19483f1 (diff)
downloadvaadin-framework-b9360a29a35a575c136da74f0f3e85a54990a121.tar.gz
vaadin-framework-b9360a29a35a575c136da74f0f3e85a54990a121.zip
Prevent setting column sortable if container is not sortable (#16320)
Change-Id: Ic220a050f6e63de499322dbca6df0be0eda27e45
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/grid/GridContainerNotSortableTest.java95
1 files changed, 71 insertions, 24 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridContainerNotSortableTest.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridContainerNotSortableTest.java
index 38b1d09897..cdfd2328dc 100644
--- a/server/tests/src/com/vaadin/tests/server/component/grid/GridContainerNotSortableTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridContainerNotSortableTest.java
@@ -15,8 +15,11 @@
*/
package com.vaadin.tests.server.component.grid;
+import static org.junit.Assert.assertFalse;
+
import java.util.Collection;
-import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
import org.junit.Test;
@@ -24,33 +27,77 @@ import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.util.AbstractInMemoryContainer;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
public class GridContainerNotSortableTest {
+ final AbstractInMemoryContainer<Object, Object, Item> notSortableDataSource = new AbstractInMemoryContainer<Object, Object, Item>() {
+
+ private Map<Object, Property<?>> properties = new LinkedHashMap<Object, Property<?>>();
+
+ {
+ properties.put("Foo", new Property<String>() {
+
+ @Override
+ public String getValue() {
+ return "foo";
+ }
+
+ @Override
+ public void setValue(String newValue) throws ReadOnlyException {
+ throw new ReadOnlyException();
+ }
+
+ @Override
+ public Class<? extends String> getType() {
+ return String.class;
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ public void setReadOnly(boolean newStatus) {
+ throw new UnsupportedOperationException();
+ }
+ });
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return properties.keySet();
+ }
+
+ @Override
+ public Property getContainerProperty(Object itemId, Object propertyId) {
+ return properties.get(propertyId);
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ return properties.get(propertyId).getType();
+ }
+
+ @Override
+ protected Item getUnfilteredItem(Object itemId) {
+ return null;
+ }
+ };
+
@Test
public void testGridWithNotSortableContainer() {
- new Grid(new AbstractInMemoryContainer<Object, Object, Item>() {
-
- @Override
- public Collection<?> getContainerPropertyIds() {
- return Collections.EMPTY_LIST;
- }
-
- @Override
- public Property getContainerProperty(Object itemId,
- Object propertyId) {
- return null;
- }
-
- @Override
- public Class<?> getType(Object propertyId) {
- return null;
- }
-
- @Override
- protected Item getUnfilteredItem(Object itemId) {
- return null;
- }
- });
+ new Grid(notSortableDataSource);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testNotSortableGridSetColumnSortable() {
+ Grid grid = new Grid();
+ grid.setContainerDataSource(notSortableDataSource);
+ Column column = grid.getColumn("Foo");
+ assertFalse("Column should not be sortable initially.",
+ column.isSortable());
+ column.setSortable(true);
}
}