aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java')
-rw-r--r--server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java
index d5959eb459..73443155c7 100644
--- a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2016 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
@@ -30,6 +30,7 @@ import org.junit.Before;
import org.junit.Test;
import com.vaadin.data.Binder.Binding;
+import com.vaadin.data.util.converter.StringToIntegerConverter;
import com.vaadin.data.validator.NotEmptyValidator;
import com.vaadin.server.AbstractErrorMessage;
import com.vaadin.server.ErrorMessage;
@@ -38,8 +39,8 @@ import com.vaadin.tests.data.bean.Person;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
-public class BinderConverterValidatorTest extends
- BinderTestBase<Binder<Person>, Person> {
+public class BinderConverterValidatorTest
+ extends BinderTestBase<Binder<Person>, Person> {
private static class StatusBean {
private String status;
@@ -684,4 +685,24 @@ public class BinderConverterValidatorTest extends
.bind(Person::getAge, Person::setAge);
binder.bind(item);
}
+
+ @Test(expected = ValidationException.class)
+ public void save_beanValidationErrorsWithConverter()
+ throws ValidationException {
+ Binder<Person> binder = new Binder<>();
+ binder.forField(ageField)
+ .withConverter(new StringToIntegerConverter("Can't convert"))
+ .bind(Person::getAge, Person::setAge);
+
+ binder.withValidator(Validator.from(person -> false, "b"));
+
+ Person person = new Person();
+ ageField.setValue("1");
+ try {
+ binder.save(person);
+ } finally {
+ // Bean should have been updated for item validation but reverted
+ Assert.assertEquals(0, person.getAge());
+ }
+ }
}