use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WSubordinateControl_Test method testApplyControls.
@Test
public void testApplyControls() {
WCheckBox box = new WCheckBox();
SubordinateTarget target = new WTextField();
// Create Rule
Rule rule = new Rule();
rule.setCondition(new Equal(box, Boolean.TRUE));
rule.addActionOnTrue(new Hide(target));
rule.addActionOnFalse(new Show(target));
WSubordinateControl control = new WSubordinateControl();
control.addRule(rule);
WContainer root = new WContainer();
root.add(control);
root.add(box);
root.add(target);
setActiveContext(createUIContext());
// Setup true condition - Selected
box.setSelected(true);
// Apply the controls
setFlag(box, ComponentModel.HIDE_FLAG, false);
control.applyTheControls();
Assert.assertTrue("After applyControls target should be hidden", target.isHidden());
setFlag(box, ComponentModel.HIDE_FLAG, false);
// Setup true condition - CheckBox selected in Request
MockRequest request = new MockRequest();
setupCheckBoxRequest(box, request, true);
// ApplyControls with Request
control.applyTheControls(request);
Assert.assertTrue("Request - After applyControls target should be hidden", target.isHidden());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class CompareExpression_Test method testBuild.
@Test
public void testBuild() {
SubordinateTrigger trigger = new WTextField();
String value = "test";
// Build Equal
CompareExpression expr = new CompareExpression(CompareType.EQUAL, trigger, value);
Equal equal = (Equal) expr.build();
Assert.assertEquals("Equal condition returned invalid trigger", trigger, equal.getTrigger());
Assert.assertEquals("Equal condition returned invalid value", value, equal.getValue());
// Build NotEqual
expr = new CompareExpression(CompareType.NOT_EQUAL, trigger, value);
NotEqual notEqual = (NotEqual) expr.build();
Assert.assertEquals("NotEqual condition returned invalid trigger", trigger, notEqual.getTrigger());
Assert.assertEquals("NotEqual condition returned invalid value", value, notEqual.getValue());
// Build LessThan
expr = new CompareExpression(CompareType.LESS_THAN, trigger, value);
LessThan lessThan = (LessThan) expr.build();
Assert.assertEquals("LessThan condition returned invalid trigger", trigger, lessThan.getTrigger());
Assert.assertEquals("LessThan condition returned invalid value", value, lessThan.getValue());
// Build LessThanOrEqual
expr = new CompareExpression(CompareType.LESS_THAN_OR_EQUAL, trigger, value);
LessThanOrEqual lessThanOrEqual = (LessThanOrEqual) expr.build();
Assert.assertEquals("LessThanOrEqual condition returned invalid trigger", trigger, lessThanOrEqual.getTrigger());
Assert.assertEquals("LessThanOrEqual condition returned invalid value", value, lessThanOrEqual.getValue());
// Build GreaterThan
expr = new CompareExpression(CompareType.GREATER_THAN, trigger, value);
GreaterThan greaterThan = (GreaterThan) expr.build();
Assert.assertEquals("GreaterThan condition returned invalid trigger", trigger, greaterThan.getTrigger());
Assert.assertEquals("GreaterThan condition returned invalid value", value, greaterThan.getValue());
// Build GreaterThanOrEqual
expr = new CompareExpression(CompareType.GREATER_THAN_OR_EQUAL, trigger, value);
GreaterThanOrEqual greaterThanOrEqual = (GreaterThanOrEqual) expr.build();
Assert.assertEquals("GreaterThanOrEqual condition returned invalid trigger", trigger, greaterThanOrEqual.getTrigger());
Assert.assertEquals("GreaterThanOrEqual condition returned invalid value", value, greaterThanOrEqual.getValue());
// Build Match
expr = new CompareExpression(CompareType.MATCH, trigger, value);
Match match = (Match) expr.build();
Assert.assertEquals("Match condition returned invalid trigger", trigger, match.getTrigger());
Assert.assertEquals("Match condition returned invalid value", value, match.getValue());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class CompareExpression_Test method testToString.
@Test
public void testToString() {
SubordinateTrigger trigger = new WTextField();
String value = "test";
// Equal
CompareExpression expr = new CompareExpression(CompareType.EQUAL, trigger, value);
Assert.assertEquals("Incorrect toString for equals compare", "WTextField=\"test\"", expr.toString());
// NotEqual
expr = new CompareExpression(CompareType.NOT_EQUAL, trigger, value);
Assert.assertEquals("Incorrect toString for not equals compare", "WTextField!=\"test\"", expr.toString());
// LessThan
expr = new CompareExpression(CompareType.LESS_THAN, trigger, value);
Assert.assertEquals("Incorrect toString for less than compare", "WTextField<\"test\"", expr.toString());
// LessThanOrEqual
expr = new CompareExpression(CompareType.LESS_THAN_OR_EQUAL, trigger, value);
Assert.assertEquals("Incorrect toString for less than or equal compare", "WTextField<=\"test\"", expr.toString());
// GreaterThan
expr = new CompareExpression(CompareType.GREATER_THAN, trigger, value);
Assert.assertEquals("Incorrect toString for greater than compare", "WTextField>\"test\"", expr.toString());
// GreaterThanOrEqual
expr = new CompareExpression(CompareType.GREATER_THAN_OR_EQUAL, trigger, value);
Assert.assertEquals("Incorrect toString for greater thanor equal compare", "WTextField>=\"test\"", expr.toString());
// Match
expr = new CompareExpression(CompareType.MATCH, trigger, value);
Assert.assertEquals("Incorrect toString for match compare", "WTextField matches \"test\"", expr.toString());
// Test when a label is associated with the field
expr = new CompareExpression(CompareType.EQUAL, trigger, value);
new WLabel("My test field", trigger);
Assert.assertEquals("Incorrect toString for equals compare with label", "My test field=\"test\"", expr.toString());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testBuildNotEquals.
@Test
public void testBuildNotEquals() {
builder.notEquals(new WTextField(), "1");
Assert.assertEquals("Incorrect condition", "WTextField!=\"1\"", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testBuildGreaterThan.
@Test
public void testBuildGreaterThan() {
builder.greaterThan(new WTextField(), "1");
Assert.assertEquals("Incorrect condition", "WTextField>\"1\"", builder.build().toString());
}
Aggregations