use of com.vaadin.flow.data.converter.StringToDoubleConverter in project flow by vaadin.
the class BinderTest method validationShouldNotRunTwice.
@Test
public void validationShouldNotRunTwice() {
TestTextField salaryField = new TestTextField();
AtomicInteger count = new AtomicInteger(0);
item.setSalaryDouble(100d);
binder.forField(salaryField).withConverter(new StringToDoubleConverter("")).bind(Person::getSalaryDouble, Person::setSalaryDouble);
binder.setBean(item);
binder.addValueChangeListener(event -> {
count.incrementAndGet();
});
salaryField.setValue("1000");
assertTrue(binder.isValid());
assertEquals(1, count.get());
salaryField.setValue("salary");
assertFalse(binder.isValid());
assertEquals(2, count.get());
salaryField.setValue("2000");
// Without fix for #12356 count will be 5
assertEquals(3, count.get());
assertEquals(new Double(2000), item.getSalaryDouble());
}
Aggregations