use of javax.measure.quantity.Dimensionless in project smarthome by eclipse.
the class GroupItemTest method assertThatNumberGroupItemWithDifferentDimensionsCalculatesCorrectState.
@Test
public void assertThatNumberGroupItemWithDifferentDimensionsCalculatesCorrectState() {
NumberItem baseItem = createNumberItem("baseItem", Temperature.class, UnDefType.NULL);
GroupFunctionDTO gfDTO = new GroupFunctionDTO();
gfDTO.name = "sum";
GroupFunction function = groupFunctionHelper.createGroupFunction(gfDTO, Collections.emptyList(), Temperature.class);
GroupItem groupItem = new GroupItem("number", baseItem, function);
groupItem.setUnitProvider(unitProvider);
groupItem.setItemStateConverter(itemStateConverter);
NumberItem celsius = createNumberItem("C", Temperature.class, new QuantityType<Temperature>("23 °C"));
groupItem.addMember(celsius);
NumberItem hectoPascal = createNumberItem("F", Pressure.class, new QuantityType<Pressure>("1010 hPa"));
groupItem.addMember(hectoPascal);
NumberItem percent = createNumberItem("K", Dimensionless.class, new QuantityType<Dimensionless>("110 %"));
groupItem.addMember(percent);
QuantityType<?> state = (QuantityType<?>) groupItem.getStateAs(QuantityType.class);
assertThat(state, is(new QuantityType<Temperature>("23 °C")));
groupItem.stateUpdated(celsius, UnDefType.NULL);
assertThat(groupItem.getState(), is(new QuantityType<Temperature>("23 °C")));
}
Aggregations