use of com.github.bordertech.wcomponents.validation.WValidationErrors in project wcomponents by BorderTech.
the class WValidationErrorsRenderer_Test method testDoPaintBasic.
@Test
public void testDoPaintBasic() throws IOException, SAXException, XpathException {
WValidationErrors errors = new WValidationErrors();
WTextArea text1 = new WTextArea();
text1.setText("text1");
WContainer root = new WContainer();
root.add(errors);
root.add(text1);
root.setLocked(true);
// Validate Schema with no errors
assertSchemaMatch(root);
// Simulate Error Message
setActiveContext(createUIContext());
List<Diagnostic> diags = new ArrayList<>();
diags.add(new DiagnosticImpl(Diagnostic.ERROR, text1, "Test Error1"));
root.showErrorIndicators(diags);
errors.setErrors(diags);
assertSchemaMatch(root);
assertXpathEvaluatesTo(text1.getId(), "//ui:validationerrors/ui:error/@for", root);
assertXpathEvaluatesTo("Test Error1", "//ui:validationerrors/ui:error", root);
String title = "WValidationErrorsTitle";
errors.setTitleText(title);
assertSchemaMatch(root);
assertXpathEvaluatesTo(title, "//ui:validationerrors/@title", root);
// Check for error message with no associated component
setActiveContext(createUIContext());
diags.clear();
diags.add(new DiagnosticImpl(Diagnostic.ERROR, null, "Test Error1"));
errors.setErrors(diags);
assertSchemaMatch(root);
assertXpathNotExists("//ui:validationerrors/ui:error/@for", root);
assertXpathEvaluatesTo("Test Error1", "//ui:validationerrors/ui:error", root);
}
Aggregations