Search in sources :

Example 41 with SubordinateTarget

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

the class HideInGroup_Test method testToString.

@Test
public void testToString() {
    SubordinateTarget target1 = new MyTarget();
    SubordinateTarget target2 = new MyTarget();
    SubordinateTarget target3 = new MyTarget();
    WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
    group.addToGroup(target1);
    group.addToGroup(target2);
    group.addToGroup(target3);
    HideInGroup action = new HideInGroup(target2, group);
    Assert.assertEquals("Incorrect toString for action", "hide MyTarget in WComponentGroup([MyTarget, MyTarget, MyTarget])", action.toString());
    new WLabel("test label", target2);
    Assert.assertEquals("Incorrect toString for action with a label", "hide test label in WComponentGroup([MyTarget, MyTarget, MyTarget])", action.toString());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 42 with SubordinateTarget

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

the class HideInGroup_Test method testHideInWComponentGroup.

@Test
public void testHideInWComponentGroup() {
    SubordinateTarget target1 = new MyTarget();
    SubordinateTarget target2 = new MyTarget();
    SubordinateTarget target3 = new MyTarget();
    WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
    group.addToGroup(target1);
    group.addToGroup(target2);
    group.addToGroup(target3);
    HideInGroup action = new HideInGroup(target2, group);
    // Check all visible and not hidden
    AssertTargetUtil.assertTargetsNotHidden(target1, target2, target3);
    AssertTargetUtil.assertTargetsVisible(target1, target2, target3);
    // Execute Action
    setActiveContext(createUIContext());
    action.execute();
    // Check only target2 is hidden
    Assert.assertFalse("Target1 should not be hidden", target1.isHidden());
    Assert.assertTrue("Target2 should be hidden", target2.isHidden());
    Assert.assertFalse("Target3 should not be hidden", target3.isHidden());
    // All Visible
    AssertTargetUtil.assertTargetsVisible(target1, target2, target3);
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) Test(org.junit.Test)

Example 43 with SubordinateTarget

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

the class Hide_Test method testConstructor.

@Test
public void testConstructor() {
    SubordinateTarget target = new MyTarget();
    Hide action = new Hide(target);
    Assert.assertEquals("Value for Hide should be false", Boolean.FALSE, action.getValue());
    Assert.assertEquals("Target for Hide should be the target", target, action.getTarget());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Test(org.junit.Test)

Example 44 with SubordinateTarget

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

the class Optional_Test method testConstructor.

@Test
public void testConstructor() {
    SubordinateTarget target = new MyTarget();
    Optional action = new Optional(target);
    Assert.assertEquals("Value for Optional should be false", Boolean.FALSE, action.getValue());
    Assert.assertEquals("Target for Optional should be the target", target, action.getTarget());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Test(org.junit.Test)

Example 45 with SubordinateTarget

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

the class Rule_Test method testToString.

@Test
public void testToString() {
    WCheckBox box = new WCheckBox();
    SubordinateTarget target = new WTextField();
    Rule rule = new Rule();
    // No condition and actions
    Assert.assertEquals("Incorrect toString for RULE with no conditions and actions", "if (null)\nthen\n   []\nelse\n   []\n", rule.toString());
    // With Conditions and actions;
    rule.setCondition(new Equal(box, Boolean.TRUE));
    rule.addActionOnTrue(new Hide(target));
    rule.addActionOnFalse(new Show(target));
    Assert.assertEquals("Incorrect toString for RULE", "if (WCheckBox=\"true\")\nthen\n   [hide WTextField]\nelse\n   [show WTextField]\n", rule.toString());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Aggregations

SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)57 Test (org.junit.Test)53 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)30 WTextField (com.github.bordertech.wcomponents.WTextField)21 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)18 Equal (com.github.bordertech.wcomponents.subordinate.Equal)17 Rule (com.github.bordertech.wcomponents.subordinate.Rule)17 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)17 WContainer (com.github.bordertech.wcomponents.WContainer)15 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)15 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)15 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)15 Hide (com.github.bordertech.wcomponents.subordinate.Hide)12 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)11 Show (com.github.bordertech.wcomponents.subordinate.Show)11 WLabel (com.github.bordertech.wcomponents.WLabel)5 Condition (com.github.bordertech.wcomponents.subordinate.Condition)5 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)3 And (com.github.bordertech.wcomponents.subordinate.And)3 Disable (com.github.bordertech.wcomponents.subordinate.Disable)3