summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-09-26 13:41:12 +0300
committerAnna Koskinen <anna@vaadin.com>2014-11-05 17:53:48 +0200
commitf6b9f60a004645326ccab4ed5b65a6c7e7ef0d32 (patch)
tree9acee34fd5b1fb19edaa4378a7fba4600ab548c3 /server/tests
parentaaabbe3d58128245a5ae3156d924ea97e6f1fcab (diff)
downloadvaadin-framework-f6b9f60a004645326ccab4ed5b65a6c7e7ef0d32.tar.gz
vaadin-framework-f6b9f60a004645326ccab4ed5b65a6c7e7ef0d32.zip
Add null check to FieldGroup.bind. (#14729)
Change-Id: I56ee44f34307d76c8c98ca3346feed8e7ee2f72e
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java b/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java
new file mode 100644
index 0000000000..eb8f21c839
--- /dev/null
+++ b/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java
@@ -0,0 +1,40 @@
+package com.vaadin.data.fieldgroup;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.ui.Field;
+
+public class FieldGroupTests {
+
+ private FieldGroup sut;
+ private Field field;
+
+ @Before
+ public void setup() {
+ sut = new FieldGroup();
+ field = mock(Field.class);
+ }
+
+ @Test
+ public void fieldIsBound() {
+ sut.bind(field, "foobar");
+
+ assertThat(sut.getField("foobar"), is(field));
+ }
+
+ @Test(expected = FieldGroup.BindException.class)
+ public void cannotBindToAlreadyBoundProperty() {
+ sut.bind(field, "foobar");
+ sut.bind(mock(Field.class), "foobar");
+ }
+
+ @Test(expected = FieldGroup.BindException.class)
+ public void cannotBindNullField() {
+ sut.bind(null, "foobar");
+ }
+}