Search in sources :

Example 1 with ElementDescriptor

use of org.linkki.core.ui.section.descriptor.ElementDescriptor in project linkki by linkki-framework.

the class FieldDescriptorTest method getLabelText_addSuffixOnlyIfNecessary.

@Test
public void getLabelText_addSuffixOnlyIfNecessary() {
    ElementDescriptor fieldDescriptor = new ElementDescriptor(adapter, "Test:", Void.class, new ArrayList<>());
    assertEquals("Test:", fieldDescriptor.getLabelText());
}
Also used : ElementDescriptor(org.linkki.core.ui.section.descriptor.ElementDescriptor) Test(org.junit.Test)

Example 2 with ElementDescriptor

use of org.linkki.core.ui.section.descriptor.ElementDescriptor in project linkki by linkki-framework.

the class FieldDescriptorTest method getPropertyName_byMethodName.

@Test
public void getPropertyName_byMethodName() {
    ElementDescriptor fieldDescriptor = new ElementDescriptor(adapter, "Test", Void.class, new ArrayList<>());
    assertEquals("Test", fieldDescriptor.getModelPropertyName());
}
Also used : ElementDescriptor(org.linkki.core.ui.section.descriptor.ElementDescriptor) Test(org.junit.Test)

Example 3 with ElementDescriptor

use of org.linkki.core.ui.section.descriptor.ElementDescriptor in project linkki by linkki-framework.

the class FieldDescriptorTest method getPropertyName_favorModelAttribute.

@Test
public void getPropertyName_favorModelAttribute() {
    when(adapter.modelAttribute()).thenReturn("xyz");
    ElementDescriptor fieldDescriptor = new ElementDescriptor(adapter, "Test", Void.class, new ArrayList<>());
    assertEquals("xyz", fieldDescriptor.getModelPropertyName());
}
Also used : ElementDescriptor(org.linkki.core.ui.section.descriptor.ElementDescriptor) Test(org.junit.Test)

Example 4 with ElementDescriptor

use of org.linkki.core.ui.section.descriptor.ElementDescriptor in project linkki by linkki-framework.

the class BindingContextTest method testBind_BoundComponentsAreMadeImmediate.

@Test
public void testBind_BoundComponentsAreMadeImmediate() {
    setUpPmo();
    TextField field = new TextField();
    BindingDefinition fieldDefintion = mock(BindingDefinition.class);
    when(fieldDefintion.required()).thenReturn(RequiredType.REQUIRED);
    when(fieldDefintion.enabled()).thenReturn(EnabledType.ENABLED);
    when(fieldDefintion.visible()).thenReturn(VisibleType.VISIBLE);
    ElementDescriptor fieldDescriptor = new ElementDescriptor(fieldDefintion, "value", Void.class, new ArrayList<>());
    // Precondition
    assertThat(field.isImmediate(), is(false));
    context.bind(pmo, fieldDescriptor, new LabelComponentWrapper(field));
    assertThat(field.isImmediate(), is(true));
}
Also used : BindingDefinition(org.linkki.core.ui.section.annotations.BindingDefinition) TextField(com.vaadin.ui.TextField) UITextField(org.linkki.core.ui.section.annotations.UITextField) ElementDescriptor(org.linkki.core.ui.section.descriptor.ElementDescriptor) LabelComponentWrapper(org.linkki.core.ui.components.LabelComponentWrapper) Test(org.junit.Test)

Example 5 with ElementDescriptor

use of org.linkki.core.ui.section.descriptor.ElementDescriptor in project linkki by linkki-framework.

the class FieldDescriptorTest method getLabelText_deriveFromLabel.

@Test
public void getLabelText_deriveFromLabel() {
    when(adapter.label()).thenReturn("blablub");
    ElementDescriptor fieldDescriptor = new ElementDescriptor(adapter, "xyz", Void.class, new ArrayList<>());
    assertEquals("blablub", fieldDescriptor.getLabelText());
}
Also used : ElementDescriptor(org.linkki.core.ui.section.descriptor.ElementDescriptor) Test(org.junit.Test)

Aggregations

ElementDescriptor (org.linkki.core.ui.section.descriptor.ElementDescriptor)7 Test (org.junit.Test)6 TextField (com.vaadin.ui.TextField)1 LabelComponentWrapper (org.linkki.core.ui.components.LabelComponentWrapper)1 BindingDefinition (org.linkki.core.ui.section.annotations.BindingDefinition)1 UITextField (org.linkki.core.ui.section.annotations.UITextField)1 PropertyElementDescriptors (org.linkki.core.ui.section.descriptor.PropertyElementDescriptors)1 UIAnnotationReader (org.linkki.core.ui.section.descriptor.UIAnnotationReader)1