use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class TreeUtil_Test method initTree.
@Before
public void initTree() {
root = new WApplication();
containerChild = new WContainer();
simpleChild = new WTextField();
repeatedComponent = new WText();
repeaterChild = new WRepeater(repeatedComponent);
grandChild = new WTextArea();
cardManager = new WCardManager();
card1 = new WText();
card2 = new WText();
root.add(containerChild);
root.add(simpleChild);
root.add(repeaterChild);
root.add(cardManager);
containerChild.add(grandChild);
cardManager.add(card1);
cardManager.add(card2);
root.setLocked(true);
setActiveContext(new UIContextImpl());
repeaterChild.setData(Arrays.asList(new String[] { "1", "2", "3" }));
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class DiagnosticImpl_Test method testGetContext.
@Test
public void testGetContext() {
final UIContext uic = new UIContextImpl();
DiagnosticImpl diag = new DiagnosticImpl(Diagnostic.INFO, uic, new WTextField(), "dummy");
Assert.assertSame("Incorrect UI context", uic, diag.getContext());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WFieldErrorIndicator_Test method testIsDefaultState.
@Test
public void testIsDefaultState() {
WPanel root = new WPanel();
WTextField component = new WTextField();
WFieldErrorIndicator indicator = new WFieldErrorIndicator(component);
root.add(indicator);
root.add(component);
root.setLocked(true);
setActiveContext(createUIContext());
Assert.assertTrue("Should be in default state by default", indicator.isDefaultState());
List<Diagnostic> diags = new ArrayList<>();
root.validate(diags);
root.showErrorIndicators(diags);
Assert.assertTrue("Should be in default if there are no errors", indicator.isDefaultState());
// Add an error by making the field mandatory
root.reset();
component.setMandatory(true);
root.validate(diags);
root.showErrorIndicators(diags);
Assert.assertFalse("Should not be in default if there are errors", indicator.isDefaultState());
root.reset();
Assert.assertTrue("Should be in default after reset", indicator.isDefaultState());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WFieldErrorIndicator_Test method testConstructor.
@Test
public void testConstructor() {
WTextField component = new WTextField();
WFieldErrorIndicator indicator = new WFieldErrorIndicator(component);
Assert.assertEquals("Incorrect indicator type", AbstractWFieldIndicator.FieldIndicatorType.ERROR, indicator.getFieldIndicatorType());
Assert.assertEquals("Incorrect releated field", component, indicator.getTargetComponent());
Assert.assertEquals("Incorrect releated field id", component.getId(), indicator.getRelatedFieldId());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WValidationErrors_Test method testGetGroupedErrors.
@Test
public void testGetGroupedErrors() {
wValidationErrors.setLocked(true);
UIContext uic = createUIContext();
setActiveContext(uic);
errors.clear();
List<GroupedDiagnositcs> groupedErrors = wValidationErrors.getGroupedErrors();
Assert.assertTrue("Should not have any groups by default", groupedErrors.isEmpty());
WComponent component1 = new WTextField();
WComponent component2 = new WTextField();
Diagnostic component1Error1 = new DiagnosticImpl(Diagnostic.ERROR, component1, "Error 1");
Diagnostic component2Error1 = new DiagnosticImpl(Diagnostic.ERROR, component2, "Error 2");
Diagnostic component2Error2 = new DiagnosticImpl(Diagnostic.ERROR, component2, "Error 3");
errors.add(component1Error1);
errors.add(component2Error1);
errors.add(component2Error2);
wValidationErrors.setErrors(errors);
groupedErrors = wValidationErrors.getGroupedErrors();
Assert.assertEquals("Incorrect number of groups", 2, groupedErrors.size());
GroupedDiagnositcs group1 = groupedErrors.get(0);
GroupedDiagnositcs group2 = groupedErrors.get(1);
Assert.assertEquals("Incorrect number of errors for group 1", 1, group1.getDiagnostics().size());
Assert.assertSame("Incorrect diagnostic in group 1", component1Error1, group1.getDiagnostics().get(0));
Assert.assertEquals("Incorrect number of errors for group 2", 2, group2.getDiagnostics().size());
Assert.assertSame("Incorrect diagnostic in group 2", component2Error1, group2.getDiagnostics().get(0));
Assert.assertSame("Incorrect diagnostic in group 2", component2Error2, group2.getDiagnostics().get(1));
}
Aggregations