use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class DiagnosticImpl_Test method testGetSeverity.
@Test
public void testGetSeverity() {
final int severity = Diagnostic.INFO;
DiagnosticImpl diag = new DiagnosticImpl(severity, new WTextField(), "dummy");
Assert.assertEquals("Incorrect severity", severity, diag.getSeverity());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WFieldWarningIndicator_Test method testConstructor.
@Test
public void testConstructor() {
WTextField component = new WTextField();
WFieldWarningIndicator indicator = new WFieldWarningIndicator(component);
Assert.assertEquals("Incorrect indicator type", AbstractWFieldIndicator.FieldIndicatorType.WARN, indicator.getFieldIndicatorType());
Assert.assertEquals("Incorrect releated field", component, indicator.getTargetComponent());
Assert.assertEquals("Incorrect related field id", component.getId(), indicator.getRelatedFieldId());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WValidationErrors_Test method setUp.
@Before
public void setUp() {
wValidationErrors = new WValidationErrors();
Diagnostic error = new DiagnosticImpl(Diagnostic.ERROR, new WTextField(), "Error");
errors = new ArrayList<>();
errors.add(error);
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class AbstractFieldValidator_Test method testInputFieldAccessors.
@Test
public void testInputFieldAccessors() {
MyAbstractFieldValidator validator = new MyAbstractFieldValidator();
Input input = new WTextField();
validator.setInputField(input);
Assert.assertSame("Incorrect input field returned", input, validator.getInputField());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class Validation_Test method testMandatory.
@Test
public void testMandatory() {
List<Diagnostic> diags = new ArrayList<>();
WTextField textField = new WTextField();
Assert.assertFalse("Text field should not be mandatory by default", textField.isMandatory());
// No validation logic yet, but that should still be ok.
textField.validate(diags);
Assert.assertEquals("Diags should be empty when there are no validators", 0, diags.size());
// Add a mandatory validation
textField.setMandatory(true);
Assert.assertTrue("Text field should be mandatory", textField.isMandatory());
textField.validate(diags);
Assert.assertEquals("Diags should contain mandatory validation error", 1, diags.size());
// Add some text to the text field
textField.setText("Blah");
diags.clear();
textField.validate(diags);
Assert.assertEquals("Diags should be empty when mandatory field is filled in", 0, diags.size());
}
Aggregations