summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-01-14 15:41:16 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-01-15 13:15:12 +0000
commit0723f355464c0a9093a8c9d43542b13a6aa9d366 (patch)
tree5a26bc116bc94a224b02ff1d52f2663a9aef742b /server
parent3365c3009b8e1d8f99176f065e38be16cb261b89 (diff)
downloadvaadin-framework-0723f355464c0a9093a8c9d43542b13a6aa9d366.tar.gz
vaadin-framework-0723f355464c0a9093a8c9d43542b13a6aa9d366.zip
Add sanity check to removeColumn in Grid server side (#16219)
Change-Id: I306442d93ccc488018065cee3b5c1a79aa8d6e34
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/Grid.java10
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java5
2 files changed, 14 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 175c326f14..18d45b3b9f 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -3116,8 +3116,16 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
*
* @param propertyId
* The property id of column to be removed
+ *
+ * @throws IllegalArgumentException
+ * if there is no column for given property id in this grid
*/
- public void removeColumn(Object propertyId) {
+ public void removeColumn(Object propertyId) throws IllegalArgumentException {
+ if (!columns.keySet().contains(propertyId)) {
+ throw new IllegalArgumentException(
+ "There is no column for given property id " + propertyId);
+ }
+
List<Column> removed = new ArrayList<Column>();
removed.add(getColumn(propertyId));
internalRemoveColumn(propertyId);
diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java
index 1204b1e396..4501fc8e39 100644
--- a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java
+++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java
@@ -228,6 +228,11 @@ public class GridColumns {
}
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testRemoveColumnThatDoesNotExist() {
+ grid.removeColumn("banana phone");
+ }
+
private GridColumnState getColumnState(Object propertyId) {
String columnId = columnIdMapper.key(propertyId);
for (GridColumnState columnState : state.columns) {