Search in sources :

Example 61 with WTextField

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());
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 62 with WTextField

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());
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 63 with WTextField

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);
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Before(org.junit.Before)

Example 64 with WTextField

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());
}
Also used : Input(com.github.bordertech.wcomponents.Input) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 65 with WTextField

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

Aggregations

WTextField (com.github.bordertech.wcomponents.WTextField)117 Test (org.junit.Test)90 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)21 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)21 WContainer (com.github.bordertech.wcomponents.WContainer)21 Equal (com.github.bordertech.wcomponents.subordinate.Equal)16 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)15 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)15 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)15 Rule (com.github.bordertech.wcomponents.subordinate.Rule)15 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)15 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)14 WTextArea (com.github.bordertech.wcomponents.WTextArea)14 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)12 WDropdown (com.github.bordertech.wcomponents.WDropdown)12 WButton (com.github.bordertech.wcomponents.WButton)11 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 WHeading (com.github.bordertech.wcomponents.WHeading)10 WLabel (com.github.bordertech.wcomponents.WLabel)10 Hide (com.github.bordertech.wcomponents.subordinate.Hide)10