use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.
the class ButtonPmoBindingTest method testUpdateFromPmo_PmoSublass.
@Test
public void testUpdateFromPmo_PmoSublass() {
TestButtonPmo pmo = new TestButtonPmo();
PropertyDispatcher propertyDispatcher = new org.linkki.core.binding.dispatcher.ButtonPmoDispatcher(new ReflectionPropertyDispatcher(() -> pmo, StringUtils.EMPTY, wrappedDispatcher));
ButtonPmoBinding binding = new ButtonPmoBinding(button, propertyDispatcher, bindingContext::updateUI);
bindingContext.add(binding);
pmo.enabled = true;
pmo.visible = true;
binding.updateFromPmo();
assertThat(button.isVisible(), is(true));
assertThat(button.isEnabled(), is(true));
pmo.enabled = false;
pmo.visible = false;
binding.updateFromPmo();
assertThat(button.isVisible(), is(false));
assertThat(button.isEnabled(), is(false));
}
use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.
the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_getValueFromPmo.
@Test
public void testCreateDispatcherChain_getValueFromPmo() {
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);
pmo.setValue(ANY_VALUE);
Object pmoProp = defaultDispatcher.pull(Aspect.of(""));
assertThat(pmoProp, is(ANY_VALUE));
}
use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.
the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_getValueFromModelObject.
@Test
public void testCreateDispatcherChain_getValueFromModelObject() {
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);
modelObject.setModelProp("testValue");
Object modelProp = defaultDispatcher.pull(Aspect.of(""));
assertThat(modelProp, is("testValue"));
}
use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.
the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_push.
@Test
public void testCreateDispatcherChain_push() {
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);
defaultDispatcher.push(Aspect.of("", "testSetValue"));
assertThat(modelObject.getModelProp(), is("testSetValue"));
}
Aggregations