use of org.eclipse.smarthome.core.library.types.DecimalType 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.DecimalType 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.DecimalType in project smarthome by eclipse.
the class LocationItemTest method testDistance.
@Test
public void testDistance() {
PointType pointParis = new PointType("48.8566140,2.3522219");
PointType pointBerlin = new PointType("52.5200066,13.4049540");
LocationItem locationParis = new LocationItem("paris");
locationParis.setState(pointParis);
LocationItem locationBerlin = new LocationItem("berlin");
locationBerlin.setState(pointBerlin);
DecimalType distance = locationParis.distanceFrom(locationParis);
assertEquals(distance.intValue(), 0);
double parisBerlin = locationParis.distanceFrom(locationBerlin).doubleValue();
assertEquals(parisBerlin, 878400, 50);
}
use of org.eclipse.smarthome.core.library.types.DecimalType in project smarthome by eclipse.
the class ItemStateConverterImplTest method numberItemWithoutDimensionShouldConvertToDecimalType.
@Test
public void numberItemWithoutDimensionShouldConvertToDecimalType() {
Item item = new NumberItem("number");
State originalState = new QuantityType<>("12.34 °C");
State convertedState = itemStateConverter.convertToAcceptedState(originalState, item);
assertThat(convertedState, is(new DecimalType("12.34")));
}
use of org.eclipse.smarthome.core.library.types.DecimalType in project smarthome by eclipse.
the class GroupItemTest method assertCyclicGroupItemsCalculateStateWithSubGroupFunction.
@Test
public void assertCyclicGroupItemsCalculateStateWithSubGroupFunction() {
GroupFunction countFn = new ArithmeticGroupFunction.Count(new StringType(".*"));
GroupItem rootGroup = new GroupItem("rootGroup", new SwitchItem("baseItem"), countFn);
TestItem rootMember = new TestItem("rootMember");
rootGroup.addMember(rootMember);
GroupItem group1 = new GroupItem("group1");
GroupItem group2 = new GroupItem("group2", new SwitchItem("baseItem"), new ArithmeticGroupFunction.Sum());
rootGroup.addMember(group1);
group1.addMember(group2);
group2.addMember(group1);
group1.addMember(new TestItem("sub1"));
group2.addMember(new TestItem("sub2-1"));
group2.addMember(new TestItem("sub2-2"));
group2.addMember(new TestItem("sub2-3"));
// count: rootMember, sub1, group2
assertThat(rootGroup.getStateAs(DecimalType.class), is(new DecimalType(3)));
}
Aggregations