Search in sources :

Example 26 with TextField

use of com.vaadin.ui.TextField in project linkki by linkki-framework.

the class UIIntegerFieldIntegrationTest method testSetValueWithPrimitiveIntInModelObject.

@Test
public void testSetValueWithPrimitiveIntInModelObject() {
    TestModelObjectWithPrimitiveInteger modelObject = new TestModelObjectWithPrimitiveInteger();
    TextField textField = createFirstComponent(modelObject);
    assertThat(textField.getMaxLength(), is(MAX_LENGTH));
    assertThat(textField.getValue(), is(formatter.format(0)));
    textField.setValue(formatter.format(1));
    assertThat(modelObject.getValue(), is(1));
    modelObject.setValue(2000);
    // updateUi(); not needed at the moment
    assertThat(textField.getValue(), is(formatter.format(2000)));
}
Also used : TextField(com.vaadin.ui.TextField) Test(org.junit.Test)

Example 27 with TextField

use of com.vaadin.ui.TextField in project linkki by linkki-framework.

the class UIIntegerFieldIntegrationTest method testSetValueWithPrimitiveIntegerInModelObjectFailsForNull.

@Test(expected = Buffered.SourceException.class)
public void testSetValueWithPrimitiveIntegerInModelObjectFailsForNull() {
    TextField textField = createFirstComponent(new TestModelObjectWithPrimitiveInteger());
    textField.setValue(null);
}
Also used : TextField(com.vaadin.ui.TextField) Test(org.junit.Test)

Example 28 with TextField

use of com.vaadin.ui.TextField in project linkki by linkki-framework.

the class UITextFieldIntegrationTest method testNullInputIfRequired.

@Test
@Override
public void testNullInputIfRequired() {
    TextField textField = getDynamicComponent();
    getDefaultPmo().setRequired(true);
    updateUi();
    assertThat(textField.isRequired(), is(true));
    textField.setValue("something");
    assertThat(getDefaultModelObject().getValue(), is("something"));
    textField.setValue(null);
    assertThat(getDefaultModelObject().getValue(), is(nullValue()));
}
Also used : TextField(com.vaadin.ui.TextField) Test(org.junit.Test)

Example 29 with TextField

use of com.vaadin.ui.TextField in project linkki by linkki-framework.

the class UiIntegerFieldTest method testSetValueWithPrimitiveIntegerInModelObject.

@Test
public void testSetValueWithPrimitiveIntegerInModelObject() {
    TextField textField = createIntegerTextField(new TestModelObjectWithPrimitiveInteger());
    // No assertions needed, we just make sure no exception is thrown
    textField.setValue("0");
}
Also used : TextField(com.vaadin.ui.TextField) Test(org.junit.Test)

Example 30 with TextField

use of com.vaadin.ui.TextField in project linkki by linkki-framework.

the class BindAnnotationDescriptorTest method testCreateBinding_CreatesFieldBindingForField.

@Test
public void testCreateBinding_CreatesFieldBindingForField() {
    BindAnnotationDescriptor descriptor = new BindAnnotationDescriptor(mock(Bind.class), new ArrayList<>());
    PropertyDispatcher dispatcher = mock(PropertyDispatcher.class);
    ElementBinding binding = descriptor.createBinding(dispatcher, Handler.NOP_HANDLER, new LabelComponentWrapper(new TextField()));
    assertThat(binding, is(instanceOf(ComponentBinding.class)));
}
Also used : Bind(org.linkki.core.binding.annotations.Bind) BindAnnotationDescriptor(org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor) TextField(com.vaadin.ui.TextField) PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) ElementBinding(org.linkki.core.binding.ElementBinding) LabelComponentWrapper(org.linkki.core.ui.components.LabelComponentWrapper) Test(org.junit.Test)

Aggregations

TextField (com.vaadin.ui.TextField)79 Test (org.junit.Test)22 Button (com.vaadin.ui.Button)15 Label (com.vaadin.ui.Label)15 HorizontalLayout (com.vaadin.ui.HorizontalLayout)12 VerticalLayout (com.vaadin.ui.VerticalLayout)10 ClickListener (com.vaadin.ui.Button.ClickListener)7 ComboBox (com.vaadin.ui.ComboBox)7 GridLayout (com.vaadin.ui.GridLayout)7 SplitTextField (au.com.vaadinutils.crud.splitFields.SplitTextField)6 InvalidValueException (com.vaadin.data.Validator.InvalidValueException)6 ClickEvent (com.vaadin.ui.Button.ClickEvent)6 PasswordField (com.vaadin.ui.PasswordField)6 CheckBox (com.vaadin.ui.CheckBox)4 Form (com.vaadin.ui.Form)4 TextArea (com.vaadin.ui.TextArea)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Property (com.vaadin.data.Property)3 Validator (com.vaadin.data.Validator)3