Search in sources :

Example 31 with SubordinateTarget

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

the class AbstractAction_Test method testRecursiveWithWComponentGroup.

@Test
public void testRecursiveWithWComponentGroup() {
    SubordinateTarget target1 = new MyTarget();
    SubordinateTarget target2 = new MyTarget();
    SubordinateTarget target3 = new MyTarget();
    WComponentGroup<SubordinateTarget> compGroup = new WComponentGroup<>();
    compGroup.addToGroup(target1);
    compGroup.addToGroup(target2);
    compGroup.addToGroup(target3);
    String value = "TEST_COMP";
    MyAction action = new MyAction(compGroup, value);
    // Execute Action
    setActiveContext(createUIContext());
    action.execute();
    Assert.assertEquals("Incorrect value set on target1", value, ((MyTarget) target1).getValue());
    Assert.assertEquals("Incorrect value set on target2", value, ((MyTarget) target2).getValue());
    Assert.assertEquals("Incorrect value set on target3", value, ((MyTarget) target3).getValue());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) Test(org.junit.Test)

Example 32 with SubordinateTarget

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

the class AbstractAction_Test method testTargetInGroupAccessors.

@Test
public void testTargetInGroupAccessors() {
    AbstractAction action = new MyAction(new MyTarget(), null);
    Assert.assertNull("TargetInGroup should be null by default", action.getTargetInGroup());
    // Set Target
    SubordinateTarget target = new MyTarget();
    action.setTargetInGroup(target);
    Assert.assertEquals("Incorrect TargetInGroup returned", target, action.getTargetInGroup());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Test(org.junit.Test)

Example 33 with SubordinateTarget

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

the class AbstractAction_Test method testExecute.

@Test
public void testExecute() {
    SubordinateTarget target = new MyTarget();
    String value = "TEST_VALUE";
    MyAction action = new MyAction(target, value);
    // Execute Action
    action.execute();
    Assert.assertEquals("Incorrect value set on target", value, ((MyTarget) target).getValue());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Test(org.junit.Test)

Example 34 with SubordinateTarget

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

the class AbstractSetEnable_Test method testConstructor.

@Test
public void testConstructor() {
    SubordinateTarget target = new MyTarget();
    Boolean value = Boolean.TRUE;
    // Constructor - 1
    AbstractSetEnable enable = new MyEnable(target, value);
    Assert.assertEquals("Incorrect target returned", target, enable.getTarget());
    Assert.assertEquals("Incorrect value returned", value, enable.getValue());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Test(org.junit.Test)

Example 35 with SubordinateTarget

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

the class AbstractSetEnable_Test method testExecute.

@Test
public void testExecute() {
    // Valid Disableable Target and FALSE Boolean Value
    SubordinateTarget target = new MyTarget();
    AbstractSetEnable enable = new MyEnable(target, Boolean.FALSE);
    // Should be disabled
    enable.execute();
    Assert.assertTrue("Target should be disabled", ((Disableable) target).isDisabled());
    // Should be not validate
    Assert.assertFalse("Target should not be validate", target.isValidate());
    // Valid Disableable Target and TRUE Boolean Value
    target = new MyTarget();
    enable = new MyEnable(target, Boolean.TRUE);
    ((Disableable) target).setDisabled(true);
    // Should be enabled
    enable.execute();
    Assert.assertFalse("Target should be enabled", ((Disableable) target).isDisabled());
    // Should be validate
    Assert.assertTrue("Target should be validate", target.isValidate());
    // Invalid Target (Not Disableable)
    target = new MyInvalidTarget();
    enable = new MyEnable(target, Boolean.FALSE);
    // Nothing happen to target
    enable.execute();
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Disableable(com.github.bordertech.wcomponents.Disableable) 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