aboutsummaryrefslogtreecommitdiffstats
path: root/server/tests/src/com/vaadin/ui/TableTest.java
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-09-24 17:56:36 +0300
committerVaadin Code Review <review@vaadin.com>2014-09-26 12:40:14 +0000
commit99b1c1a7936f250885e647983d7e30fd3a7f1018 (patch)
tree51141abb0ed9c1dbca20b31702ab014a559a377e /server/tests/src/com/vaadin/ui/TableTest.java
parentd516791e28e861893fb5082472a1c0ca59f0dfd7 (diff)
downloadvaadin-framework-99b1c1a7936f250885e647983d7e30fd3a7f1018.tar.gz
vaadin-framework-99b1c1a7936f250885e647983d7e30fd3a7f1018.zip
Add clear() for fields and field group (#14755)
Change-Id: If9372ccceeaacd0826f8b1ed07f64af12bf47fc6
Diffstat (limited to 'server/tests/src/com/vaadin/ui/TableTest.java')
-rw-r--r--server/tests/src/com/vaadin/ui/TableTest.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/ui/TableTest.java b/server/tests/src/com/vaadin/ui/TableTest.java
new file mode 100644
index 0000000000..86237abbe0
--- /dev/null
+++ b/server/tests/src/com/vaadin/ui/TableTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui;
+
+import java.util.Collection;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.util.BeanItemContainerGenerator;
+
+public class TableTest {
+
+ Table table;
+
+ @Before
+ public void init() {
+ table = new Table();
+ }
+
+ @Test
+ public void initiallyEmpty() {
+ Assert.assertTrue(table.isEmpty());
+ }
+
+ @Test
+ public void emptyAfterClearSingleSelect() {
+ table.setContainerDataSource(BeanItemContainerGenerator
+ .createContainer(100));
+ Assert.assertTrue(table.isEmpty());
+ Object first = table.getContainerDataSource().getItemIds().iterator()
+ .next();
+ table.setValue(first);
+ Assert.assertEquals(first, table.getValue());
+ Assert.assertFalse(table.isEmpty());
+ table.clear();
+ Assert.assertEquals(null, table.getValue());
+ Assert.assertTrue(table.isEmpty());
+ }
+
+ @Test
+ public void emptyAfterClearMultiSelect() {
+ table.setMultiSelect(true);
+ table.setContainerDataSource(BeanItemContainerGenerator
+ .createContainer(100));
+
+ Assert.assertTrue(table.isEmpty());
+ Assert.assertArrayEquals(new Object[] {},
+ ((Collection) table.getValue()).toArray());
+
+ Object first = table.getContainerDataSource().getItemIds().iterator()
+ .next();
+ table.select(first);
+ Assert.assertArrayEquals(new Object[] { first },
+ ((Collection) table.getValue()).toArray());
+ Assert.assertFalse(table.isEmpty());
+
+ table.clear();
+ Assert.assertArrayEquals(new Object[] {},
+ ((Collection) table.getValue()).toArray());
+ Assert.assertTrue(table.isEmpty());
+ }
+
+}