use of org.linkki.util.validation.ValidationMarker 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.util.validation.ValidationMarker in project linkki by linkki-framework.
the class MessageListTest method testGetMessagesByMarker_withValidationMarker.
@Test
public void testGetMessagesByMarker_withValidationMarker() {
ValidationMarker marker = () -> false;
MessageList messages = new MessageList(Message.builder("msg1", ErrorLevel.INFORMATION).create(), Message.builder("msgWithMarker", ErrorLevel.WARNING).markers(marker).create());
MessageList messagesByMarker = messages.getMessagesByMarker(marker);
assertThat(messagesByMarker, is(not(sameInstance(messages))));
assertThat(messagesByMarker, hasSize(1));
assertThat(messagesByMarker.getMessage(0), is(messages.getMessage(1)));
}
use of org.linkki.util.validation.ValidationMarker in project linkki by linkki-framework.
the class MessageListTest method testGetMessagesByMarker_predicate.
@Test
public void testGetMessagesByMarker_predicate() {
MessageList messages = new MessageList(Message.builder("msgWithoutMarker", ErrorLevel.INFORMATION).create(), Message.builder("msgWithMatchingMarker", ErrorLevel.WARNING).markers(() -> true).create(), Message.builder("msgWithNonMathingMarker", ErrorLevel.ERROR).markers(() -> false).create());
MessageList messagesByMarker = messages.getMessagesByMarker(ValidationMarker::isRequiredInformationMissing);
assertThat(messagesByMarker, is(not(sameInstance(messages))));
assertThat(messagesByMarker, hasSize(1));
assertThat(messagesByMarker.getMessage(0), is(messages.getMessage(1)));
}
use of org.linkki.util.validation.ValidationMarker in project linkki by linkki-framework.
the class MessageTest method testIsMandatoryFieldMessage.
@Test
public void testIsMandatoryFieldMessage() {
ValidationMarker mandatoryMarker = () -> true;
ValidationMarker notMandatoryMarker = () -> false;
assertThat(createMessage().isMandatoryFieldMessage(), is(false));
assertThat(createMessage(notMandatoryMarker).isMandatoryFieldMessage(), is(false));
assertThat(createMessage(mandatoryMarker).isMandatoryFieldMessage(), is(true));
assertThat(createMessage(notMandatoryMarker, mandatoryMarker).isMandatoryFieldMessage(), is(true));
}
use of org.linkki.util.validation.ValidationMarker 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));
}
Aggregations