Search in sources :

Example 6 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_pushToPmo.

@Test
public void testCreateDispatcherChain_pushToPmo() {
    setUpPmo();
    when(elementDescriptor.getModelPropertyName()).thenReturn("foo");
    when(elementDescriptor.getModelObjectName()).thenReturn(ModelObject.DEFAULT_NAME);
    when(elementDescriptor.getPmoPropertyName()).thenReturn("value");
    PropertyDispatcher defaultDispatcher = propertyDispatcherFactory.createDispatcherChain(pmo, elementDescriptor, PropertyBehaviorProvider.NO_BEHAVIOR_PROVIDER);
    defaultDispatcher.push(Aspect.of("", ANY_VALUE));
    assertThat(pmo.getValue(), is(ANY_VALUE));
}
Also used : PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) Test(org.junit.Test)

Example 7 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_getValueFromChangedModelObject.

@Test
public void testCreateDispatcherChain_getValueFromChangedModelObject() {
    setUpPmo();
    when(elementDescriptor.getModelPropertyName()).thenReturn(TestModelObject.PROPERTY_MODEL_PROP);
    when(elementDescriptor.getModelObjectName()).thenReturn(ModelObject.DEFAULT_NAME);
    when(elementDescriptor.getPmoPropertyName()).thenReturn("foo");
    PropertyDispatcher defaultDispatcher = propertyDispatcherFactory.createDispatcherChain(pmo, elementDescriptor, PropertyBehaviorProvider.NO_BEHAVIOR_PROVIDER);
    TestModelObject newModelObject = new TestModelObject();
    pmo.setModelObject(newModelObject);
    newModelObject.setModelProp("testNewValue");
    Object modelProp = defaultDispatcher.pull(Aspect.of(""));
    assertThat(modelProp, is("testNewValue"));
}
Also used : TestModelObject(org.linkki.core.binding.BindingContextTest.TestModelObject) PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) ModelObject(org.linkki.core.ui.section.annotations.ModelObject) TestModelObject(org.linkki.core.binding.BindingContextTest.TestModelObject) Test(org.junit.Test)

Example 8 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_setValueToChangedModelObject.

@Test
public void testCreateDispatcherChain_setValueToChangedModelObject() {
    setUpPmo();
    when(elementDescriptor.getModelPropertyName()).thenReturn(TestModelObject.PROPERTY_MODEL_PROP);
    when(elementDescriptor.getModelObjectName()).thenReturn(ModelObject.DEFAULT_NAME);
    when(elementDescriptor.getPmoPropertyName()).thenReturn("foo");
    PropertyDispatcher defaultDispatcher = propertyDispatcherFactory.createDispatcherChain(pmo, elementDescriptor, PropertyBehaviorProvider.NO_BEHAVIOR_PROVIDER);
    TestModelObject newModelObject = new TestModelObject();
    pmo.setModelObject(newModelObject);
    defaultDispatcher.push(Aspect.of("", "testNewSetValue"));
    assertThat(newModelObject.getModelProp(), is("testNewSetValue"));
}
Also used : TestModelObject(org.linkki.core.binding.BindingContextTest.TestModelObject) PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) Test(org.junit.Test)

Example 9 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class BindAnnotationDescriptorTest method testCreateBinding_CreatesLabelBindingForLabel.

@Test
public void testCreateBinding_CreatesLabelBindingForLabel() {
    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 Label()));
    assertThat(binding, is(instanceOf(ElementBinding.class)));
}
Also used : Bind(org.linkki.core.binding.annotations.Bind) BindAnnotationDescriptor(org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor) Label(com.vaadin.ui.Label) PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) ElementBinding(org.linkki.core.binding.ElementBinding) LabelComponentWrapper(org.linkki.core.ui.components.LabelComponentWrapper) Test(org.junit.Test)

Example 10 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class BindAnnotationDescriptorTest method testCreateBinding_CreatesButtonBindingForButton.

@Test
public void testCreateBinding_CreatesButtonBindingForButton() {
    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 Button()));
    assertThat(binding, is(instanceOf(ElementBinding.class)));
}
Also used : Bind(org.linkki.core.binding.annotations.Bind) Button(com.vaadin.ui.Button) BindAnnotationDescriptor(org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor) 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

PropertyDispatcher (org.linkki.core.binding.dispatcher.PropertyDispatcher)14 Test (org.junit.Test)13 TestModelObject (org.linkki.core.binding.BindingContextTest.TestModelObject)4 ReflectionPropertyDispatcher (org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher)4 LabelComponentWrapper (org.linkki.core.ui.components.LabelComponentWrapper)4 ElementBinding (org.linkki.core.binding.ElementBinding)3 Bind (org.linkki.core.binding.annotations.Bind)3 ModelObject (org.linkki.core.ui.section.annotations.ModelObject)3 BindAnnotationDescriptor (org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor)3 Button (com.vaadin.ui.Button)2 Label (com.vaadin.ui.Label)2 ButtonPmo (org.linkki.core.ButtonPmo)2 TextField (com.vaadin.ui.TextField)1 ArrayList (java.util.ArrayList)1 BindingContext (org.linkki.core.binding.BindingContext)1 ComponentBinding (org.linkki.core.binding.ComponentBinding)1 BehaviorDependentDispatcher (org.linkki.core.binding.dispatcher.BehaviorDependentDispatcher)1 ExceptionPropertyDispatcher (org.linkki.core.binding.dispatcher.ExceptionPropertyDispatcher)1 StaticValueDispatcher (org.linkki.core.binding.dispatcher.StaticValueDispatcher)1 MessageList (org.linkki.core.message.MessageList)1