use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class LocalDateTimeToStringConverterTest method testConvertToPresentation_Null.
@Test
void testConvertToPresentation_Null() {
LocalDateTimeToStringConverter converter = new LocalDateTimeToStringConverter();
String string = converter.convertToPresentation(null, new ValueContext(Locale.GERMANY));
Assertions.assertThat(string).isNull();
}
use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class LocalDateToStringConverterTest method testConvertToPresentation_Null.
@Test
void testConvertToPresentation_Null() {
LocalDateToStringConverter converter = new LocalDateToStringConverter();
String string = converter.convertToPresentation(null, new ValueContext(Locale.GERMANY));
Assertions.assertThat(string).isNull();
}
use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class NullHandlingConverterWrapperTest method testConvertToModel_NonnullValue.
@Test
public void testConvertToModel_NonnullValue() {
FormattedIntegerToStringConverter converter = new FormattedIntegerToStringConverter("#,##0");
NullHandlingConverterWrapper<String, Integer> wrapper = new NullHandlingConverterWrapper<>(converter);
ValueContext context = new ValueContext(Locale.GERMAN);
Result<Integer> converterResult = converter.convertToModel("123", context);
Result<Integer> wrapperResult = wrapper.convertToModel("123", context);
// converter returns value -> wrapper returns same value
assertThat(converterResult.isError(), is(false));
assertThat(getValue(converterResult), is(123));
assertThat(wrapperResult.isError(), is(false));
assertThat(getValue(wrapperResult), is(123));
}
use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class NullHandlingConverterWrapperTest method testConvertToModel_NullValue.
@Test
public void testConvertToModel_NullValue() {
FormattedIntegerToStringConverter converter = new FormattedIntegerToStringConverter("#,##0");
NullHandlingConverterWrapper<String, Integer> wrapper = new NullHandlingConverterWrapper<>(converter);
ValueContext context = new ValueContext(Locale.GERMAN);
Result<Integer> converterResult = converter.convertToModel("", context);
Result<Integer> wrapperResult = wrapper.convertToModel("", context);
// converter returns null -> wrapper returns error
assertThat(converterResult.isError(), is(false));
assertThat(getValue(converterResult), is(nullValue()));
assertThat(wrapperResult.isError(), is(true));
}
use of com.vaadin.flow.data.binder.ValueContext in project flow by vaadin.
the class NotEmptyValidatorTest method nullValueIsDisallowed.
@Test
public void nullValueIsDisallowed() {
NotEmptyValidator<String> validator = new NotEmptyValidator<>("foo");
ValidationResult result = validator.apply(null, new ValueContext());
Assert.assertTrue(result.isError());
Assert.assertEquals("foo", result.getErrorMessage());
}
Aggregations