Search in sources :

Example 86 with WTextField

use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.

the class ExpressionBuilder_Test method testAndOperatorPrecedenceBoth.

/**
 * Tests for correct operator precedence when there are ANDs on both sides of the OR: a {@literal &}{@literal &} b
 * || c {@literal &}{@literal &} d.
 */
@Test
public void testAndOperatorPrecedenceBoth() {
    builder.equals(new WTextField(), "1").and().equals(new WTextArea(), "2").or().equals(new WDropdown(), "3").and().equals(new WMultiSelect(), "4");
    Assert.assertEquals("Incorrect condition", "((WTextField=\"1\" and WTextArea=\"2\") or (WDropdown=\"3\" and WMultiSelect=\"4\"))", builder.build().toString());
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WDropdown(com.github.bordertech.wcomponents.WDropdown) WTextField(com.github.bordertech.wcomponents.WTextField) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) Test(org.junit.Test)

Example 87 with WTextField

use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.

the class ExpressionBuilder_Test method testAndandOrWithExpressions.

/**
 * Tests nesting of expression builders to change the order of operations: (a {@literal &}{@literal &} b) || (c
 * {@literal &}{@literal &} d).
 */
@Test
public void testAndandOrWithExpressions() {
    builder.equals(new WTextField(), "1").and(new ExpressionBuilder().equals(new WTextArea(), "2")).or(new ExpressionBuilder().equals(new WDropdown(), "3")).and().equals(new WMultiSelect(), "4");
    Assert.assertEquals("Incorrect condition", "((WTextField=\"1\" and WTextArea=\"2\") or (WDropdown=\"3\" and WMultiSelect=\"4\"))", builder.build().toString());
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WDropdown(com.github.bordertech.wcomponents.WDropdown) WTextField(com.github.bordertech.wcomponents.WTextField) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) Test(org.junit.Test)

Example 88 with WTextField

use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.

the class ExpressionBuilder_Test method testNesting.

/**
 * Tests nesting of expression builders to change the order of operations: (a {@literal &}{@literal &} (b || c)
 * {@literal &}{@literal &} d).
 */
@Test
public void testNesting() {
    builder.equals(new WTextField(), "1").and(new ExpressionBuilder().equals(new WTextArea(), "2").or().equals(new WDropdown(), "3")).and().equals(new WMultiSelect(), "4");
    Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" and (WTextArea=\"2\" or WDropdown=\"3\") and WMultiSelect=\"4\")", builder.build().toString());
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WDropdown(com.github.bordertech.wcomponents.WDropdown) WTextField(com.github.bordertech.wcomponents.WTextField) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) Test(org.junit.Test)

Example 89 with WTextField

use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.

the class ExpressionBuilder_Test method testBuildMatches.

@Test
public void testBuildMatches() {
    builder.matches(new WTextField(), "1");
    Assert.assertEquals("Incorrect condition", "WTextField matches \"1\"", builder.build().toString());
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 90 with WTextField

use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.

the class ExpressionBuilder_Test method testValidate.

@Test
public void testValidate() {
    Assert.assertFalse("An empty expression should not be valid", builder.validate());
    builder.equals(new WTextField(), "1");
    Assert.assertTrue("A valid expression should be valid", builder.validate());
}
Also used : 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