use of org.linkki.core.binding.validation.ValidationService in project linkki by linkki-framework.
the class OkCancelDialogTest method testValidate_ShowsNoInitialMessages.
@Test
public void testValidate_ShowsNoInitialMessages() {
MessageList messages = new MessageList();
ValidationService validationService = ValidationService.of(messages);
OkCancelDialog dialog = new OkCancelDialog("caption");
dialog.setValidationService(validationService);
assertThat(dialog, is(not(displayingMessage())));
assertThat(dialog, is(showingEnabledOkButton()));
}
use of org.linkki.core.binding.validation.ValidationService 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.binding.validation.ValidationService 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()));
}
Aggregations