Search in sources :

Example 31 with ValueContext

use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.

the class NullHandlingConverterWrapperTest method testConvertToModel_Error.

@Test
public void testConvertToModel_Error() {
    FormattedIntegerToStringConverter converter = new FormattedIntegerToStringConverter("#,##0");
    NullHandlingConverterWrapper<String, Integer> wrapper = new NullHandlingConverterWrapper<>(converter);
    ValueContext context = new ValueContext(Locale.GERMAN);
    Result<Integer> converterResult = converter.convertToModel("xyz", context);
    Result<Integer> wrapperResult = wrapper.convertToModel("xyz", context);
    // converter returns error -> wrapper returns error
    assertThat(converterResult.isError(), is(true));
    assertThat(wrapperResult.isError(), is(true));
}
Also used : ValueContext(com.vaadin.flow.data.binder.ValueContext) Test(org.junit.jupiter.api.Test)

Aggregations

ValueContext (com.vaadin.flow.data.binder.ValueContext)31 Test (org.junit.jupiter.api.Test)24 Locale (java.util.Locale)6 ValidationResult (com.vaadin.flow.data.binder.ValidationResult)5 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 LocalDate (java.time.LocalDate)4 LocalDateTime (java.time.LocalDateTime)4 Matchers.is (org.hamcrest.Matchers.is)4 Matchers.nullValue (org.hamcrest.Matchers.nullValue)4 Test (org.junit.Test)3 Result (com.vaadin.flow.data.binder.Result)2 VaadinSession (com.vaadin.flow.server.VaadinSession)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Key (com.vaadin.flow.component.Key)1 UI (com.vaadin.flow.component.UI)1 Button (com.vaadin.flow.component.button.Button)1 ButtonVariant (com.vaadin.flow.component.button.ButtonVariant)1 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)1