use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.
the class GroupItemTest method assertThatGroupItemWithRollershutterBaseItemConversionWorks.
@Test
public void assertThatGroupItemWithRollershutterBaseItemConversionWorks() {
// initially this group has State UndefType.NULL
GroupItem groupItem = new GroupItem("root", new RollershutterItem("myRollerShutter"));
State groupStateAsOnOff = groupItem.getStateAs(OnOffType.class);
// a state conversion from NULL to OnOffType should not be possible
assertNull(groupStateAsOnOff);
// init group
groupItem.setState(new PercentType(70));
groupStateAsOnOff = groupItem.getStateAs(OnOffType.class);
// any value >0 means on, so 50% means the group state should be ON
assertTrue(OnOffType.ON.equals(groupStateAsOnOff));
}
use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.
the class GroupItemTest method assertThatGroupItemWithColoritemBaseItemConversionWorks.
@Test
public void assertThatGroupItemWithColoritemBaseItemConversionWorks() {
// initially this group has State UndefType.NULL
GroupItem groupItem = new GroupItem("root", new ColorItem("myColor"));
State groupStateAsPercent = groupItem.getStateAs(PercentType.class);
// a state conversion from NULL to PercentType should not be possible
assertNull(groupStateAsPercent);
// init group
groupItem.setState(new HSBType("200,80,80"));
groupStateAsPercent = groupItem.getStateAs(PercentType.class);
assertTrue(groupStateAsPercent instanceof PercentType);
assertThat(((PercentType) groupStateAsPercent).intValue(), is(80));
}
use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.
the class ColorItemTest method testSetStateWithHSBType.
@Test
public void testSetStateWithHSBType() {
ColorItem item = new ColorItem("test");
item.setState(new HSBType(new DecimalType(75), new PercentType(75), new PercentType(75)));
assertEquals(new HSBType(new DecimalType(75), new PercentType(75), new PercentType(75)), item.getState());
}
use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.
the class ColorItemTest method testSetStateWithPercentType.
@Test
public void testSetStateWithPercentType() {
ColorItem item = new ColorItem("test");
item.setState(new PercentType(50));
assertEquals(new HSBType(new DecimalType(0), new PercentType(0), new PercentType(50)), item.getState());
}
use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.
the class DimmerItemTest method getAsPercentFromPercent.
@Test
public void getAsPercentFromPercent() {
final BigDecimal origin = new BigDecimal(25);
final DimmerItem item = createDimmerItem(new PercentType(origin));
final BigDecimal result = getState(item, PercentType.class);
assertEquals(origin.compareTo(result), 0);
}
Aggregations