Search in sources :

Example 6 with MessageList

use of org.linkki.core.message.MessageList in project linkki by linkki-framework.

the class BindingManagerTest method testAfterUpdateUi_sortsMessagesByErrorLevel.

@Test
public void testAfterUpdateUi_sortsMessagesByErrorLevel() {
    Message e1 = Message.newError("e1", "E1");
    Message e2 = Message.newError("e2", "E2");
    Message e3 = Message.newError("e3", "E3");
    Message w1 = Message.newWarning("w1", "W1");
    Message w2 = Message.newWarning("w2", "W2");
    Message i1 = Message.newInfo("i1", "I1");
    Message i2 = Message.newInfo("i2", "I2");
    MessageList unsortedMessageList = new MessageList(i2, e1, w1, e3, i1, e2, w2);
    MessageList sortedMessageList = new MessageList(e1, e3, e2, w1, w2, i2, i1);
    validationService = () -> unsortedMessageList;
    TestBindingManager bindingManager = new TestBindingManager(validationService);
    TestBindingContext context = bindingManager.startNewContext("foo");
    bindingManager.afterUpdateUi();
    assertThat(context.messages, is(equalTo(sortedMessageList)));
}
Also used : Message(org.linkki.core.message.Message) MessageList(org.linkki.core.message.MessageList) Test(org.junit.Test)

Example 7 with MessageList

use of org.linkki.core.message.MessageList in project linkki by linkki-framework.

the class AbstractPropertyDispatcherDecoratorTest method testMessages.

@Test
public void testMessages() {
    MessageList messageList = new MessageList();
    decorator.getMessages(messageList);
    verify(wrappedDispatcher).getMessages(messageList);
}
Also used : MessageList(org.linkki.core.message.MessageList) Test(org.junit.Test)

Example 8 with MessageList

use of org.linkki.core.message.MessageList in project linkki by linkki-framework.

the class ReflectionPropertyDispatcherTest method testGetMessages_ShouldReturnMessagesFromPmo.

@Test
public void testGetMessages_ShouldReturnMessagesFromPmo() {
    MessageList messageList = new MessageList();
    Message msg1 = Message.builder(ABC, ErrorLevel.ERROR).invalidObjectWithProperties(testPmo, XYZ).create();
    Message msg2 = Message.builder(ABC, ErrorLevel.ERROR).invalidObjectWithProperties(testPmo, ABC).create();
    Message msg3 = Message.builder(ABC, ErrorLevel.ERROR).invalidObjectWithProperties(testModelObject, XYZ).create();
    messageList.add(msg1);
    messageList.add(msg2);
    messageList.add(msg3);
    assertThat(setupPmoDispatcher(XYZ).getMessages(messageList), hasSize(2));
    assertThat(setupPmoDispatcher(ABC).getMessages(messageList), hasSize(1));
    assertThat(setupPmoDispatcher("invalidProperty").getMessages(messageList), emptyMessageList());
}
Also used : Message(org.linkki.core.message.Message) MessageMatchers.emptyMessageList(org.linkki.core.matcher.MessageMatchers.emptyMessageList) MessageList(org.linkki.core.message.MessageList) Test(org.junit.Test)

Example 9 with MessageList

use of org.linkki.core.message.MessageList in project linkki by linkki-framework.

the class ReflectionPropertyDispatcherTest method testGetMessages_ShouldReturnMessagesFromModelObject.

@Test
public void testGetMessages_ShouldReturnMessagesFromModelObject() {
    MessageList messageList = new MessageList();
    Message msg1 = Message.builder(ABC, ErrorLevel.ERROR).invalidObjectWithProperties(testModelObject, XYZ).create();
    Message msg2 = Message.builder(ABC, ErrorLevel.ERROR).invalidObjectWithProperties(testModelObject, ABC).create();
    messageList.add(msg1);
    messageList.add(msg2);
    assertThat(setupPmoDispatcher(XYZ).getMessages(messageList), hasSize(1));
    assertThat(setupPmoDispatcher(ABC).getMessages(messageList), hasSize(1));
    assertThat(setupPmoDispatcher("invalidProperty").getMessages(messageList), emptyMessageList());
}
Also used : Message(org.linkki.core.message.Message) MessageMatchers.emptyMessageList(org.linkki.core.matcher.MessageMatchers.emptyMessageList) MessageList(org.linkki.core.message.MessageList) Test(org.junit.Test)

Example 10 with MessageList

use of org.linkki.core.message.MessageList in project linkki by linkki-framework.

the class ReflectionPropertyDispatcherTest method testGetMessages_empty.

@Test
public void testGetMessages_empty() {
    MessageList messageList = new MessageList();
    assertThat(setupPmoDispatcher(XYZ).getMessages(messageList), emptyMessageList());
    assertThat(setupPmoDispatcher("invalidProperty").getMessages(messageList), emptyMessageList());
}
Also used : MessageMatchers.emptyMessageList(org.linkki.core.matcher.MessageMatchers.emptyMessageList) MessageList(org.linkki.core.message.MessageList) Test(org.junit.Test)

Aggregations

MessageList (org.linkki.core.message.MessageList)23 Test (org.junit.Test)16 Message (org.linkki.core.message.Message)6 MessageMatchers.emptyMessageList (org.linkki.core.matcher.MessageMatchers.emptyMessageList)4 ValidationService (org.linkki.core.binding.validation.ValidationService)3 ArrayList (java.util.ArrayList)2 PropertyDispatcher (org.linkki.core.binding.dispatcher.PropertyDispatcher)2 LabelComponentWrapper (org.linkki.core.ui.components.LabelComponentWrapper)2 ValidationMarker (org.linkki.util.validation.ValidationMarker)2 Button (com.vaadin.ui.Button)1 Label (com.vaadin.ui.Label)1 Before (org.junit.Before)1 BindingContext (org.linkki.core.binding.BindingContext)1 ComponentBinding (org.linkki.core.binding.ComponentBinding)1 ModelObject (org.linkki.core.ui.section.annotations.ModelObject)1