Search in sources :

Example 1 with WFieldWarningIndicator

use of com.github.bordertech.wcomponents.validation.WFieldWarningIndicator in project wcomponents by BorderTech.

the class WFieldWarningIndicatorRenderer_Test method testRendererCorrectlyConfigured.

/**
 * Test the Layout is correctly configured.
 */
@Test
public void testRendererCorrectlyConfigured() {
    WFieldWarningIndicator indicator = new WFieldWarningIndicator(new WTextField());
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(indicator) instanceof WFieldWarningIndicatorRenderer);
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) WFieldWarningIndicator(com.github.bordertech.wcomponents.validation.WFieldWarningIndicator) Test(org.junit.Test)

Example 2 with WFieldWarningIndicator

use of com.github.bordertech.wcomponents.validation.WFieldWarningIndicator in project wcomponents by BorderTech.

the class WFieldWarningIndicatorRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WContainer root = new WContainer();
    WPanel target = new WPanel();
    WFieldWarningIndicator indicator = new WFieldWarningIndicator(target);
    root.add(target);
    root.add(indicator);
    // Simulate Warning Message
    setActiveContext(createUIContext());
    List<Diagnostic> diags = new ArrayList<>();
    diags.add(new DiagnosticImpl(Diagnostic.WARNING, target, "Test Warning"));
    root.showWarningIndicators(diags);
    // Validate Schema
    assertSchemaMatch(root);
    // Check Attributes
    assertXpathEvaluatesTo(indicator.getId(), "//ui:fieldindicator/@id", root);
    assertXpathEvaluatesTo("warn", "//ui:fieldindicator/@type", root);
    assertXpathEvaluatesTo(target.getId(), "//ui:fieldindicator/@for", root);
    // Check Message
    assertXpathEvaluatesTo("Test Warning", "//ui:fieldindicator/ui:message", root);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) DiagnosticImpl(com.github.bordertech.wcomponents.validation.DiagnosticImpl) WPanel(com.github.bordertech.wcomponents.WPanel) ArrayList(java.util.ArrayList) Diagnostic(com.github.bordertech.wcomponents.validation.Diagnostic) WFieldWarningIndicator(com.github.bordertech.wcomponents.validation.WFieldWarningIndicator) Test(org.junit.Test)

Example 3 with WFieldWarningIndicator

use of com.github.bordertech.wcomponents.validation.WFieldWarningIndicator in project wcomponents by BorderTech.

the class WFieldWarningIndicatorRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WContainer root = new WContainer();
    WPanel target = new WPanel();
    WFieldWarningIndicator indicator = new WFieldWarningIndicator(target);
    root.add(target);
    root.add(indicator);
    setActiveContext(createUIContext());
    List<Diagnostic> diags = new ArrayList<>();
    diags.add(new DiagnosticImpl(Diagnostic.WARNING, target, getMaliciousContent()));
    root.showWarningIndicators(diags);
    assertSafeContent(root);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) DiagnosticImpl(com.github.bordertech.wcomponents.validation.DiagnosticImpl) WPanel(com.github.bordertech.wcomponents.WPanel) ArrayList(java.util.ArrayList) Diagnostic(com.github.bordertech.wcomponents.validation.Diagnostic) WFieldWarningIndicator(com.github.bordertech.wcomponents.validation.WFieldWarningIndicator) Test(org.junit.Test)

Aggregations

WFieldWarningIndicator (com.github.bordertech.wcomponents.validation.WFieldWarningIndicator)3 Test (org.junit.Test)3 WContainer (com.github.bordertech.wcomponents.WContainer)2 WPanel (com.github.bordertech.wcomponents.WPanel)2 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)2 DiagnosticImpl (com.github.bordertech.wcomponents.validation.DiagnosticImpl)2 ArrayList (java.util.ArrayList)2 WTextField (com.github.bordertech.wcomponents.WTextField)1