use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.
the class UIIntegerFieldIntegrationTest method testSetValue_WithPrimitiveIntegerInModelObject_RevertsForNull.
@Test
void testSetValue_WithPrimitiveIntegerInModelObject_RevertsForNull() {
TextField textField = createFirstComponent(new TestModelObjectWithPrimitiveInteger());
TestUiUtil.setUserOriginatedValue(textField, formatter.format(1));
assertThat(textField.getValue(), is(formatter.format(1)));
TestUiUtil.setUserOriginatedValue(textField, "");
// field reverts to last valid value
assertThat(textField.getValue(), is(formatter.format(1)));
}
use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.
the class UIIntegerFieldIntegrationTest method testSetValue_WithObjectIntegerInModelObject.
@Test
void testSetValue_WithObjectIntegerInModelObject() {
TestModelObjectWithObjectInteger modelObject = new TestModelObjectWithObjectInteger();
TextField textField = createFirstComponent(modelObject);
assertThat(textField.getValue(), is(emptyString()));
TestUiUtil.setUserOriginatedValue(textField, formatter.format(1));
assertThat(modelObject.getValue(), is(1));
modelObject.setValue(2);
getBindingContext().modelChanged();
assertThat(textField.getValue(), is(formatter.format(2)));
TestUiUtil.setUserOriginatedValue(textField, textField.getEmptyValue());
assertThat(getDefaultModelObject().getValue(), is(nullValue()));
}
use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.
the class UIIntegerFieldTest method testSetValue_WithPrimitiveIntegerInModelObject.
@Test
void testSetValue_WithPrimitiveIntegerInModelObject() {
TextField textField = createIntegerTextField(new TestModelObjectWithPrimitiveInteger());
Assertions.assertDoesNotThrow(() -> {
TestUiUtil.setUserOriginatedValue(textField, "0");
});
}
use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.
the class UIIntegerFieldTest method testSetValue_WithObjectIntegerInModelObject.
@Test
void testSetValue_WithObjectIntegerInModelObject() {
TextField textField = createIntegerTextField(new TestModelObjectWithObjectInteger());
Assertions.assertDoesNotThrow(() -> {
TestUiUtil.setUserOriginatedValue(textField, "");
TestUiUtil.setUserOriginatedValue(textField, "0");
});
}
use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.
the class UIIntegerFieldTest method testSetValue_WithThousandSeparatorOnPrimitiveInteger_EN.
@Test
void testSetValue_WithThousandSeparatorOnPrimitiveInteger_EN() {
UI.getCurrent().setLocale(Locale.ENGLISH);
TextField textField = createIntegerTextField(new TestModelObjectWithPrimitiveInteger());
TestUiUtil.setUserOriginatedValue(textField, "98765432");
assertThat(textField.getValue(), is("98,765,432"));
}
Aggregations