Search in sources :

Example 21 with MessageList

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

the class ComponentBindingTest method setUp.

@Before
public void setUp() {
    propertyDispatcherValue = mock(PropertyDispatcher.class);
    when(propertyDispatcherValue.getProperty()).thenReturn("value");
    propertyDispatcherEnumValue = mock(PropertyDispatcher.class);
    when(propertyDispatcherEnumValue.getProperty()).thenReturn("enumValue");
    doReturn(TestEnum.class).when(propertyDispatcherEnumValue).getValueClass();
    messageList = new MessageList();
    when(propertyDispatcherValue.getMessages(any(MessageList.class))).thenReturn(messageList);
    when(propertyDispatcherEnumValue.getMessages(any(MessageList.class))).thenReturn(messageList);
    selectBinding = new ComponentBinding(new LabelComponentWrapper(label, selectField), propertyDispatcherEnumValue, Handler.NOP_HANDLER, new ArrayList<>());
}
Also used : ArrayList(java.util.ArrayList) PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) MessageList(org.linkki.core.message.MessageList) LabelComponentWrapper(org.linkki.core.ui.components.LabelComponentWrapper) Before(org.junit.Before)

Example 22 with MessageList

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

the class ReflectionPropertyDispatcherTest method testGetMessages_IgnoreIrrelevantMessages.

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

Example 23 with MessageList

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

the class ValidationDisplayStateTest method testFilter.

@Test
public void testFilter() {
    ValidationMarker mandatoryFieldMarker = () -> true;
    ValidationMarker nonMandatoryFieldMarker = () -> false;
    Message m1 = Message.builder("m1", ErrorLevel.ERROR).markers(mandatoryFieldMarker).create();
    Message m2 = Message.builder("m2", ErrorLevel.ERROR).markers(nonMandatoryFieldMarker).create();
    Message m3 = Message.builder("m3", ErrorLevel.ERROR).create();
    MessageList messages = new MessageList(m1, m2, m3);
    assertThat(SHOW_ALL.filter(messages), contains(m1, m2, m3));
    assertThat(HIDE_MANDATORY_FIELD_VALIDATIONS.filter(messages), contains(m2, m3));
}
Also used : Message(org.linkki.core.message.Message) ValidationMarker(org.linkki.util.validation.ValidationMarker) 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