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());
}
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());
}
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());
}
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());
}
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();
}
Aggregations