use of org.linkki.core.message.Message in project linkki by linkki-framework.
the class OkCancelDialogTest method displayingMessage.
private Matcher<OkCancelDialog> displayingMessage(String text) {
return new TypeSafeMatcher<OkCancelDialog>() {
@SuppressWarnings("null")
@Override
public void describeTo(Description description) {
description.appendText("an OkCancelDialog displaying a message with the text '");
description.appendText(text);
description.appendText("'");
}
@SuppressWarnings("null")
@Override
protected boolean matchesSafely(OkCancelDialog dialog) {
VerticalLayout layout = (VerticalLayout) dialog.getContent();
VerticalLayout nestedLayout = (VerticalLayout) layout.getComponent(0);
return components(nestedLayout).filter(MessageRow.class::isInstance).findFirst().map(c -> ((MessageRow) c).getText().equals(text)).orElse(false);
}
};
}
use of org.linkki.core.message.Message 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)));
}
use of org.linkki.core.message.Message 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());
}
use of org.linkki.core.message.Message 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());
}
use of org.linkki.core.message.Message in project linkki by linkki-framework.
the class OkCancelDialogTest method testValidate_FiltersMessages.
@Test
public void testValidate_FiltersMessages() {
ValidationMarker mandatoryFieldMarker = () -> true;
Message message = Message.builder("error", ErrorLevel.ERROR).markers(mandatoryFieldMarker).create();
MessageList messages = new MessageList(message);
ValidationService validationService = ValidationService.of(messages);
OkCancelDialog dialog = new OkCancelDialog("caption");
dialog.setValidationService(validationService);
// mandatory field validations are hidden initially
assertThat(dialog.getValidationDisplayState(), is(ValidationDisplayState.HIDE_MANDATORY_FIELD_VALIDATIONS));
MessageList dialogMessage = dialog.validate();
assertTrue(dialogMessage.isEmpty());
assertThat(dialog, is(not(displayingMessage())));
assertThat(dialog, is(showingEnabledOkButton()));
// mandatory field validations are shown after the first click on the OK button
getOkButton(dialog).click();
assertThat(dialog.getValidationDisplayState(), is(ValidationDisplayState.SHOW_ALL));
dialogMessage = dialog.validate();
assertThat(dialogMessage, contains(message));
assertThat(dialog, is(displayingMessage("error")));
assertThat(dialog, is(showingDisabledOkButton()));
}
Aggregations