use of com.github.bordertech.wcomponents.validation.DiagnosticImpl in project wcomponents by BorderTech.
the class WMessages_Test method testHasMessage.
@Test
public void testHasMessage() {
WMessages messages = new WMessages();
UIContext uic = new UIContextImpl();
setActiveContext(uic);
Assert.assertFalse("Should have no messages by default", messages.hasMessages());
messages.addMessage(new Message(Message.SUCCESS_MESSAGE, "x"));
Assert.assertTrue("Should be true if there are messages", messages.hasMessages());
messages = new WMessages();
messages.addMessage(new Message(Message.INFO_MESSAGE, "x"));
Assert.assertTrue("Should be true if there are messages", messages.hasMessages());
messages = new WMessages();
messages.addMessage(new Message(Message.WARNING_MESSAGE, "x"));
Assert.assertTrue("Should be true if there are messages", messages.hasMessages());
messages = new WMessages();
messages.addMessage(new Message(Message.ERROR_MESSAGE, "x"));
Assert.assertTrue("Should be true if there are messages", messages.hasMessages());
messages = new WMessages();
Diagnostic error = new DiagnosticImpl(Diagnostic.ERROR, new WTextField(), "Error");
List<Diagnostic> errors = new ArrayList<>();
errors.add(error);
messages.getValidationErrors().setErrors(errors);
Assert.assertTrue("Should be true if there are messages", messages.hasMessages());
}
Aggregations