Search in sources :

Example 1 with TestLabel

use of com.vaadin.flow.data.binder.testcomponents.TestLabel in project flow by vaadin.

the class BinderValidationStatusTest method bindingWithStatusLabel_addAfterBound.

@Test(expected = IllegalStateException.class)
public void bindingWithStatusLabel_addAfterBound() {
    TestLabel label = new TestLabel();
    BindingBuilder<Person, String> binding = binder.forField(nameField).withValidator(notEmpty);
    binding.bind(Person::getFirstName, Person::setFirstName);
    binding.withStatusLabel(label);
}
Also used : TestLabel(com.vaadin.flow.data.binder.testcomponents.TestLabel) Person(com.vaadin.flow.tests.data.bean.Person) Test(org.junit.Test)

Example 2 with TestLabel

use of com.vaadin.flow.data.binder.testcomponents.TestLabel in project flow by vaadin.

the class BinderValidationStatusTest method binderWithStatusLabel_addAfterBound.

@Test(expected = IllegalStateException.class)
public void binderWithStatusLabel_addAfterBound() {
    TestLabel label = new TestLabel();
    BindingBuilder<Person, String> binding = binder.forField(nameField).withValidator(notEmpty);
    binding.bind(Person::getFirstName, Person::setFirstName);
    binding.withStatusLabel(label);
}
Also used : TestLabel(com.vaadin.flow.data.binder.testcomponents.TestLabel) Person(com.vaadin.flow.tests.data.bean.Person) Test(org.junit.Test)

Example 3 with TestLabel

use of com.vaadin.flow.data.binder.testcomponents.TestLabel in project flow by vaadin.

the class BinderValidationStatusTest method bindingWithStatusLabel_defaultStatusHandlerIsReplaced.

@Test
public void bindingWithStatusLabel_defaultStatusHandlerIsReplaced() {
    TestLabel label = new TestLabel();
    Binding<Person, String> binding = binder.forField(nameField).withValidator(notEmpty).withStatusLabel(label).bind(Person::getFirstName, Person::setFirstName);
    Assert.assertNull(componentErrors.get(nameField));
    nameField.setValue("");
    // First validation fails => should be event with ERROR status and
    // message
    binding.validate();
    // default behavior should update component error for the nameField
    Assert.assertNull(componentErrors.get(nameField));
}
Also used : TestLabel(com.vaadin.flow.data.binder.testcomponents.TestLabel) Person(com.vaadin.flow.tests.data.bean.Person) Test(org.junit.Test)

Example 4 with TestLabel

use of com.vaadin.flow.data.binder.testcomponents.TestLabel in project flow by vaadin.

the class BinderValidationStatusTest method bindingWithStatusHandler_setAfterLabel.

@Test(expected = IllegalStateException.class)
public void bindingWithStatusHandler_setAfterLabel() {
    TestLabel label = new TestLabel();
    BindingBuilder<Person, String> binding = binder.forField(nameField);
    binding.withStatusLabel(label);
    binding.withValidationStatusHandler(NOOP);
}
Also used : TestLabel(com.vaadin.flow.data.binder.testcomponents.TestLabel) Person(com.vaadin.flow.tests.data.bean.Person) Test(org.junit.Test)

Example 5 with TestLabel

use of com.vaadin.flow.data.binder.testcomponents.TestLabel in project flow by vaadin.

the class BinderValidationStatusTest method binderWithStatusHandler_setAfterLabel.

@Test(expected = IllegalStateException.class)
public void binderWithStatusHandler_setAfterLabel() {
    TestLabel label = new TestLabel();
    BindingBuilder<Person, String> binding = binder.forField(nameField);
    binding.bind(Person::getFirstName, Person::setFirstName);
    binder.setStatusLabel(label);
    binder.setValidationStatusHandler(event -> {
    });
}
Also used : TestLabel(com.vaadin.flow.data.binder.testcomponents.TestLabel) Person(com.vaadin.flow.tests.data.bean.Person) Test(org.junit.Test)

Aggregations

TestLabel (com.vaadin.flow.data.binder.testcomponents.TestLabel)13 Test (org.junit.Test)11 Person (com.vaadin.flow.tests.data.bean.Person)9 Before (org.junit.Before)2 UI (com.vaadin.flow.component.UI)1 TestTextField (com.vaadin.flow.data.binder.testcomponents.TestTextField)1 Registration (com.vaadin.flow.shared.Registration)1 Locale (java.util.Locale)1 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)1