use of org.eclipse.smarthome.core.library.items.SwitchItem in project smarthome by eclipse.
the class ArithmeticGroupFunctionTest method testOrFunction_differntTypes.
@Test
public void testOrFunction_differntTypes() {
DimmerItem dimmer1 = new DimmerItem("TestDimmer1");
dimmer1.setState(new PercentType("42"));
DimmerItem dimmer2 = new DimmerItem("TestDimmer2");
dimmer2.setState(new DecimalType("0"));
SwitchItem switch1 = new SwitchItem("TestSwitch1");
switch1.setState(OnOffType.ON);
SwitchItem switch2 = new SwitchItem("TestSwitch2");
switch2.setState(OnOffType.OFF);
items.add(dimmer1);
items.add(dimmer2);
items.add(switch1);
items.add(switch2);
function = new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF);
State state = function.calculate(items);
State decimalState = function.getStateAs(items, DecimalType.class);
assertEquals(OnOffType.ON, state);
assertEquals(new DecimalType("2"), decimalState);
}
use of org.eclipse.smarthome.core.library.items.SwitchItem in project smarthome by eclipse.
the class GenericItemProvider2Test method testGroupItemIsSame.
@Test
public void testGroupItemIsSame() {
GenericItemProvider gip = new GenericItemProvider();
GroupItem g1 = new GroupItem("testGroup", new SwitchItem("test"), new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF));
GroupItem g2 = new GroupItem("testGroup", new SwitchItem("test"), new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF));
assertFalse(gip.hasItemChanged(g1, g2));
}
use of org.eclipse.smarthome.core.library.items.SwitchItem in project smarthome by eclipse.
the class GenericItemProvider2Test method testGroupItemChangesFunctionParameters.
@Test
public void testGroupItemChangesFunctionParameters() {
GenericItemProvider gip = new GenericItemProvider();
GroupItem g1 = new GroupItem("testGroup", new SwitchItem("test"), new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF));
GroupItem g2 = new GroupItem("testGroup", new SwitchItem("test"), new ArithmeticGroupFunction.Or(OnOffType.ON, UnDefType.UNDEF));
assertTrue(gip.hasItemChanged(g1, g2));
}
use of org.eclipse.smarthome.core.library.items.SwitchItem in project smarthome by eclipse.
the class GenericItemProvider2Test method testGroupItemChangesBaseItemAndFunction.
@Test
public void testGroupItemChangesBaseItemAndFunction() {
GenericItemProvider gip = new GenericItemProvider();
GroupItem g1 = new GroupItem("testGroup", new SwitchItem("test"), new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF));
GroupItem g2 = new GroupItem("testGroup", new NumberItem("number"), new ArithmeticGroupFunction.Sum());
assertTrue(gip.hasItemChanged(g1, g2));
}
use of org.eclipse.smarthome.core.library.items.SwitchItem in project smarthome by eclipse.
the class GenericItemProvider2Test method testGroupItemChangesBaseItem.
@Test
public void testGroupItemChangesBaseItem() {
GenericItemProvider gip = new GenericItemProvider();
GroupItem g1 = new GroupItem("testGroup", new SwitchItem("test"), new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF));
GroupItem g2 = new GroupItem("testGroup", new NumberItem("test"), new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF));
assertTrue(gip.hasItemChanged(g1, g2));
}
Aggregations