Search in sources :

Example 11 with DiagnosticImpl

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());
}
Also used : DiagnosticImpl(com.github.bordertech.wcomponents.validation.DiagnosticImpl) ArrayList(java.util.ArrayList) Diagnostic(com.github.bordertech.wcomponents.validation.Diagnostic) Test(org.junit.Test)

Aggregations

DiagnosticImpl (com.github.bordertech.wcomponents.validation.DiagnosticImpl)11 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)9 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 WContainer (com.github.bordertech.wcomponents.WContainer)6 WPanel (com.github.bordertech.wcomponents.WPanel)4 WValidationErrors (com.github.bordertech.wcomponents.validation.WValidationErrors)3 WFieldErrorIndicator (com.github.bordertech.wcomponents.validation.WFieldErrorIndicator)2 WFieldWarningIndicator (com.github.bordertech.wcomponents.validation.WFieldWarningIndicator)2 DefaultWComponent (com.github.bordertech.wcomponents.DefaultWComponent)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WField (com.github.bordertech.wcomponents.WField)1 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)1 WTextArea (com.github.bordertech.wcomponents.WTextArea)1 WTextField (com.github.bordertech.wcomponents.WTextField)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 GroupedDiagnositcs (com.github.bordertech.wcomponents.validation.WValidationErrors.GroupedDiagnositcs)1 Serializable (java.io.Serializable)1