Search in sources :

Example 1 with ComponentBinding

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

the class DialogBindingManagerTest method testBindingsInCreatedContextsDisplayMessagesFromDialog.

@Test
public void testBindingsInCreatedContextsDisplayMessagesFromDialog() {
    OkCancelDialog dialog = new OkCancelDialog("");
    // Use the NOP validation service in the binding manager
    DialogBindingManager manager = new DialogBindingManager(dialog, ValidationService.NOP_VALIDATION_SERVICE);
    BindingContext ctx = manager.startNewContext("foo");
    // Change the dialog's validation service to make sure dialog's validate method is used and
    // not the validation service the manager was created with (so that the dialog could filter
    // the messages)
    MessageList messages = new MessageList(Message.newError("code", "text"));
    dialog.setValidationService(ValidationService.of(messages));
    PropertyDispatcher propertyDispatcher = mock(PropertyDispatcher.class);
    Object pmo = mock(Object.class);
    when(propertyDispatcher.getBoundObject()).thenReturn(pmo);
    when(propertyDispatcher.getMessages(any())).thenReturn(new MessageList());
    ComponentBinding binding = spy(new ComponentBinding(new LabelComponentWrapper(new Label(), new Button()), propertyDispatcher, Handler.NOP_HANDLER, new ArrayList<>()));
    ctx.add(binding);
    ctx.updateUI();
    verify(binding).displayMessages(messages);
}
Also used : ComponentBinding(org.linkki.core.binding.ComponentBinding) Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) ArrayList(java.util.ArrayList) PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) BindingContext(org.linkki.core.binding.BindingContext) MessageList(org.linkki.core.message.MessageList) LabelComponentWrapper(org.linkki.core.ui.components.LabelComponentWrapper) Test(org.junit.Test)

Aggregations

Button (com.vaadin.ui.Button)1 Label (com.vaadin.ui.Label)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 BindingContext (org.linkki.core.binding.BindingContext)1 ComponentBinding (org.linkki.core.binding.ComponentBinding)1 PropertyDispatcher (org.linkki.core.binding.dispatcher.PropertyDispatcher)1 MessageList (org.linkki.core.message.MessageList)1 LabelComponentWrapper (org.linkki.core.ui.components.LabelComponentWrapper)1