use of com.vaadin.flow.tests.data.bean.Person in project flow by vaadin.
the class BinderValidationStatusTest method binderWithStatusLabel_setAfterHandler.
@Test(expected = IllegalStateException.class)
public void binderWithStatusLabel_setAfterHandler() {
TestLabel label = new TestLabel();
BindingBuilder<Person, String> binding = binder.forField(nameField);
binding.bind(Person::getFirstName, Person::setFirstName);
binder.setValidationStatusHandler(event -> {
});
binder.setStatusLabel(label);
}
use of com.vaadin.flow.tests.data.bean.Person in project flow by vaadin.
the class BinderValidationStatusTest method bindingWithStatusLabel_labelIsUpdatedAccordingStatus.
@Test
public void bindingWithStatusLabel_labelIsUpdatedAccordingStatus() {
TestLabel label = new TestLabel();
Binding<Person, String> binding = binder.forField(nameField).withValidator(notEmpty).withStatusLabel(label).bind(Person::getFirstName, Person::setFirstName);
nameField.setValue("");
// First validation fails => should be event with ERROR status and
// message
binding.validate();
assertVisible(label, true);
Assert.assertEquals(EMPTY_ERROR_MESSAGE, label.getText());
nameField.setValue("foo");
// Second validation succeeds => should be event with OK status and
// no message
binding.validate();
assertVisible(label, false);
Assert.assertEquals("", label.getText());
}
Aggregations