diff options
author | Artur Signell <artur.signell@itmill.com> | 2011-12-08 13:04:33 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2011-12-08 13:04:33 +0000 |
commit | e968734dfa87136d7a488156789edf77cac1d7f6 (patch) | |
tree | 8207ac2e178dbf06ce388aa14ac966442fbfdde2 /tests/server-side/com/vaadin/data/util | |
parent | 946ea244388af573fb8cb7b7d0523046b7ceb863 (diff) | |
download | vaadin-framework-e968734dfa87136d7a488156789edf77cac1d7f6.tar.gz vaadin-framework-e968734dfa87136d7a488156789edf77cac1d7f6.zip |
#6603 Added IllegalArgumentException to javadoc and added test
svn changeset:22320/svn branch:6.7
Diffstat (limited to 'tests/server-side/com/vaadin/data/util')
-rw-r--r-- | tests/server-side/com/vaadin/data/util/BeanContainerTest.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/server-side/com/vaadin/data/util/BeanContainerTest.java b/tests/server-side/com/vaadin/data/util/BeanContainerTest.java index 5a753e19d0..d9fa8d896e 100644 --- a/tests/server-side/com/vaadin/data/util/BeanContainerTest.java +++ b/tests/server-side/com/vaadin/data/util/BeanContainerTest.java @@ -1,7 +1,9 @@ package com.vaadin.data.util; +import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -10,7 +12,6 @@ import junit.framework.Assert; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.util.AbstractBeanContainer.BeanIdResolver; -import com.vaadin.data.util.BeanContainer; public class BeanContainerTest extends AbstractBeanContainerTest { @@ -324,6 +325,37 @@ public class BeanContainerTest extends AbstractBeanContainerTest { assertEquals(0, container.size()); } + public void testAddAllWithNullItemId() { + BeanContainer<String, Person> container = new BeanContainer<String, Person>( + Person.class); + // resolver that returns null as item id + container + .setBeanIdResolver(new BeanIdResolver<String, AbstractBeanContainerTest.Person>() { + + public String getIdForBean(Person bean) { + return bean.getName(); + } + }); + + List<Person> persons = new ArrayList<Person>(); + persons.add(new Person("John")); + persons.add(new Person("Marc")); + persons.add(new Person(null)); + persons.add(new Person("foo")); + + try { + container.addAll(persons); + fail(); + } catch (IllegalArgumentException e) { + // should get exception + } + + container.removeAllItems(); + persons.remove(2); + container.addAll(persons); + assertEquals(3, container.size()); + } + public void testAddBeanWithNullResolver() { BeanContainer<String, Person> container = new BeanContainer<String, Person>( Person.class); |