use of org.linkki.core.message.MessageList in project linkki by linkki-framework.
the class ValidationDisplayStateTest method testFilter_EmptyMessageList.
@Test
public void testFilter_EmptyMessageList() {
MessageList emptyMessageList = new MessageList();
assertThat(SHOW_ALL.filter(emptyMessageList), is(MessageMatchers.emptyMessageList()));
assertThat(HIDE_MANDATORY_FIELD_VALIDATIONS.filter(emptyMessageList), is(emptyMessageList));
}
use of org.linkki.core.message.MessageList in project linkki by linkki-framework.
the class RegistrationValidationService method getValidationMessages.
@Override
public MessageList getValidationMessages() {
MessageList messages = new MessageList();
validateName(registrationPmo.getUser(), messages);
validatePassword(registrationPmo, messages);
validateEmail(registrationPmo.getUser(), messages);
validateBirthday(registrationPmo.getUser(), messages);
return messages;
}
use of org.linkki.core.message.MessageList 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()));
}
use of org.linkki.core.message.MessageList in project linkki by linkki-framework.
the class OkCancelDialogTest method testValidate_ShowsErrorsAndWarning.
@Test
public void testValidate_ShowsErrorsAndWarning() {
MessageList messages = new MessageList();
ValidationService validationService = ValidationService.of(messages);
OkCancelDialog dialog = new OkCancelDialog("caption");
dialog.setValidationService(validationService);
// MessageList with error and warning: error is displayed, button is disabled
messages.add(Message.newWarning("warning", "warning"));
messages.add(Message.newError("error", "error"));
dialog.validate();
assertThat(dialog, is(displayingMessage("error")));
assertThat(dialog, is(showingDisabledOkButton()));
// MessageList without entries: nothing is displayed, button is enabled
messages.clear();
dialog.validate();
assertThat(dialog, is(not(displayingMessage())));
assertThat(dialog, is(showingEnabledOkButton()));
// MessageList with warning: warning is displayed, button is enabled
messages.add(Message.newWarning("warning", "warning"));
dialog.validate();
assertThat(dialog, is(displayingMessage("warning")));
assertThat(dialog, is(showingEnabledOkButton()));
}
use of org.linkki.core.message.MessageList in project linkki by linkki-framework.
the class BindingManager method afterUpdateUi.
/**
* Retrieves the current messages from the validation service and uses them to update the
* messages in all registered contexts using {@link #updateMessages(MessageList)}. The
* {@link UiUpdateObserver}s are then notified by {@link #notifyUiUpdateObservers()}.
* <p>
* Should be called by all binding contexts after they updated their UI. Will be passed as the
* after-update handler to the {@link BindingContext} constructor by the
* {@link DefaultBindingManager}.
* <p>
* All overriding methods should call {@link #notifyUiUpdateObservers()} to notify registered
* {@link UiUpdateObserver}s properly.
*/
public void afterUpdateUi() {
MessageList messages = this.validationService.getValidationMessages();
MessageList sortedMessages = messages.sortByErrorLevel();
updateMessages(sortedMessages);
notifyUiUpdateObservers();
}
Aggregations