use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class FormattedIntegerToStringConverterTest method testConvertToPresentation.
@Test
public void testConvertToPresentation() {
FormattedIntegerToStringConverter converter = new FormattedIntegerToStringConverter("#,##0");
ValueContext context = new ValueContext(Locale.GERMAN);
assertThat(converter.convertToPresentation(12345, context), is("12.345"));
}
use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class FormattedDecimalFieldToStringConverterTest method testConvertToModel.
@ParameterizedTest
@MethodSource("data")
public void testConvertToModel(Decimal decimalValue, String stringValue) {
ValueContext context = new ValueContext(Locale.GERMAN);
assertThat(converter.convertToModel(stringValue, context).getOrThrow(s -> new AssertionError(s)), is(decimalValue));
}
use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class LocalDateTimeToStringConverterTest method testConvertToModel_Null.
@Test
void testConvertToModel_Null() throws Exception {
LocalDateTimeToStringConverter converter = new LocalDateTimeToStringConverter();
Result<LocalDateTime> result = converter.convertToModel(null, new ValueContext(Locale.US));
Assertions.assertThat(result.isError()).isFalse();
Assertions.assertThat(result.getOrThrow(m -> new Exception(m))).isNull();
}
use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class LocalDateTimeToStringConverterTest method testConvertToModel.
@Test
void testConvertToModel() throws Exception {
LocalDateTimeToStringConverter converter = new LocalDateTimeToStringConverter();
Result<LocalDateTime> result = converter.convertToModel("01.02.3456 07:08", new ValueContext(Locale.GERMANY));
Assertions.assertThat(result.isError()).isFalse();
Assertions.assertThat(result.getOrThrow(m -> new Exception(m))).isEqualTo(LocalDateTime.of(3456, 2, 1, 7, 8));
}
use of com.vaadin.flow.data.binder.ValueContext in project linkki by linkki-framework.
the class LocalDateTimeToStringConverterTest method testConvertToModel_IncompatibleLocale.
@Test
void testConvertToModel_IncompatibleLocale() {
LocalDateTimeToStringConverter converter = new LocalDateTimeToStringConverter();
Result<LocalDateTime> result = converter.convertToModel("01.02.3456 07:08", new ValueContext(Locale.US));
Assertions.assertThat(result.isError()).isTrue();
}
Aggregations