use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class Rule_Test method testAccessors.
@Test
public void testAccessors() {
Condition cond = new Equal(new WCheckBox(), null);
Action onTrue1 = new Hide(new WTextField());
Action onTrue2 = new Hide(new WTextField());
Action onFalse1 = new Hide(new WTextField());
Action onFalse2 = new Hide(new WTextField());
Rule rule = new Rule();
// Condition
Assert.assertNull("Condition should be null", rule.getCondition());
rule.setCondition(cond);
Assert.assertEquals("Incorrect condition returned", cond, rule.getCondition());
// OnTrue Actions
Assert.assertTrue("onTrue actions should be empty", rule.getOnTrue().isEmpty());
rule.addActionOnTrue(onTrue1);
Assert.assertEquals("onTrue actions list should have 1 item", 1, rule.getOnTrue().size());
Assert.assertEquals("Item 1 in onTrue actions list is incorrect", onTrue1, rule.getOnTrue().get(0));
rule.addActionOnTrue(onTrue2);
Assert.assertEquals("onTrue actions list should have 2 items", 2, rule.getOnTrue().size());
Assert.assertEquals("Item 1 in onTrue actions list is incorrect", onTrue1, rule.getOnTrue().get(0));
Assert.assertEquals("Item 2 in onTrue actions list is incorrect", onTrue2, rule.getOnTrue().get(1));
try {
rule.addActionOnTrue(null);
Assert.fail("Should not be able to add a null action.");
} catch (IllegalArgumentException e) {
Assert.assertNotNull("Invalid exception message for adding null action", e.getMessage());
}
// OnFalse Actions
Assert.assertTrue("onFalse actions should be empty", rule.getOnFalse().isEmpty());
rule.addActionOnFalse(onFalse1);
Assert.assertEquals("onFalse actions list should have 1 item", 1, rule.getOnFalse().size());
Assert.assertEquals("Item 1 in onFalse actions list is incorrect", onFalse1, rule.getOnFalse().get(0));
rule.addActionOnFalse(onFalse2);
Assert.assertEquals("onFalse actions list should have 2 item", 2, rule.getOnFalse().size());
Assert.assertEquals("Item 1 in onFalse actions list is incorrect", onFalse1, rule.getOnFalse().get(0));
Assert.assertEquals("Item 2 in onFalse actions list is incorrect", onFalse2, rule.getOnFalse().get(1));
try {
rule.addActionOnFalse(null);
Assert.fail("Should not be able to add a null action.");
} catch (IllegalArgumentException e) {
Assert.assertNotNull("Invalid exception message for adding null action", e.getMessage());
}
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class CompareExpression_Test method testConstructor.
@Test
public void testConstructor() {
SubordinateTrigger trigger = new WTextField();
String value = "test";
CompareExpression expr = new CompareExpression(CompareType.MATCH, trigger, value);
Assert.assertEquals("Incorrect type", CompareType.MATCH, expr.getType());
Assert.assertEquals("Incorrect trigger", trigger, expr.getTrigger());
Assert.assertEquals("Incorrect value", value, expr.getValue());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class CompareExpression_Test method testEvaluate.
@Test
public void testEvaluate() {
// Setup a true "equals" condition
CompareExpression expr = new CompareExpression(CompareType.EQUAL, new WTextField(), null);
Assert.assertTrue("Evaluate for true compare should be true", expr.evaluate());
// Setup a false "equals" condition
expr = new CompareExpression(CompareType.EQUAL, new WTextField(), "not true");
Assert.assertFalse("Evaluate for false compare should be false", expr.evaluate());
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testBuildLessThanOrEquals.
@Test
public void testBuildLessThanOrEquals() {
builder.lessThanOrEquals(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 testThreeArgOrCondition.
@Test
public void testThreeArgOrCondition() {
builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2").or().equals(new WDropdown(), "3");
Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or WTextArea=\"2\" or WDropdown=\"3\")", builder.build().toString());
}
Aggregations