diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-09-29 20:40:36 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-02 18:01:12 +0000 |
commit | 654846837379db9a76823f5d0e73e5e6bfa8115d (patch) | |
tree | 248f7bf34d6bdc054b6f3c84002481a4018b7b43 /server/tests | |
parent | 3cad153ba405fa60583925db7fee111ec326794f (diff) | |
download | vaadin-framework-654846837379db9a76823f5d0e73e5e6bfa8115d.tar.gz vaadin-framework-654846837379db9a76823f5d0e73e5e6bfa8115d.zip |
Allow BeanFieldGroup.setItemDataSource() method accept null (#14731).
Change-Id: I7a451f428f0aa3ea7fc322cac6b0e62d830d7987
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java index 112d36d884..965fb49479 100644 --- a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java @@ -2,12 +2,16 @@ package com.vaadin.tests.server.component.fieldgroup; import static org.junit.Assert.assertEquals; +import java.util.Collection; + import org.junit.Assert; import org.junit.Test; +import com.vaadin.data.Item; import com.vaadin.data.fieldgroup.BeanFieldGroup; import com.vaadin.data.fieldgroup.FieldGroup.CommitException; import com.vaadin.data.fieldgroup.PropertyId; +import com.vaadin.data.util.BeanItem; import com.vaadin.ui.Field; import com.vaadin.ui.TextField; @@ -133,4 +137,31 @@ public class BeanFieldGroupTest { assertEquals(bean.nestedBean.hello, helloField.getValue().toString()); } + @Test + public void setDataSource_nullBean_nullBeanIsSetInDataSource() { + BeanFieldGroup<MyBean> group = new BeanFieldGroup<MyBean>(MyBean.class); + + group.setItemDataSource((MyBean) null); + + BeanItem<MyBean> dataSource = group.getItemDataSource(); + Assert.assertNotNull("Data source is null for null bean", dataSource); + + Collection<?> itemPropertyIds = dataSource.getItemPropertyIds(); + Assert.assertEquals("Unexpected number of properties", 3, + itemPropertyIds.size()); + for (Object id : itemPropertyIds) { + Assert.assertNull("Value for property " + id + " is not null", + dataSource.getItemProperty(id).getValue()); + } + } + + @Test + public void setDataSource_nullItem_nullDataSourceIsSet() { + BeanFieldGroup<MyBean> group = new BeanFieldGroup<MyBean>(MyBean.class); + + group.setItemDataSource((Item) null); + BeanItem<MyBean> dataSource = group.getItemDataSource(); + Assert.assertNull("Group returns not null data source", dataSource); + } + } |