use of javax.measure.quantity.Pressure 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")));
}
use of javax.measure.quantity.Pressure in project smarthome by eclipse.
the class SmartHomeUnitsTest method testinHg2PascalConversion.
@Test
public void testinHg2PascalConversion() {
Quantity<Pressure> inHg = Quantities.getQuantity(BigDecimal.ONE, ImperialUnits.INCH_OF_MERCURY);
assertThat(inHg.to(SIUnits.PASCAL), is(Quantities.getQuantity(new BigDecimal("3386.388"), SIUnits.PASCAL)));
assertThat(inHg.to(HECTO(SIUnits.PASCAL)), is(Quantities.getQuantity(new BigDecimal("33.86388"), HECTO(SIUnits.PASCAL))));
}
use of javax.measure.quantity.Pressure in project smarthome by eclipse.
the class SmartHomeUnitsTest method testPascal2inHgConversion.
@Test
public void testPascal2inHgConversion() {
Quantity<Pressure> pascal = Quantities.getQuantity(new BigDecimal("3386.388"), SIUnits.PASCAL);
assertThat(pascal.to(ImperialUnits.INCH_OF_MERCURY), is(Quantities.getQuantity(new BigDecimal("1.000"), ImperialUnits.INCH_OF_MERCURY)));
}
use of javax.measure.quantity.Pressure in project smarthome by eclipse.
the class QuantityTypeArithmeticGroupFunctionTest method testMaxFunctionQuantityTypeIncompatibleUnits.
@Test
public void testMaxFunctionQuantityTypeIncompatibleUnits() {
items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("23.54 °C")));
items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL));
items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<Pressure>("192.2 hPa")));
function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class);
State state = function.calculate(items);
assertEquals(new QuantityType<Temperature>("23.54 °C"), state);
}
use of javax.measure.quantity.Pressure in project smarthome by eclipse.
the class QuantityTypeArithmeticGroupFunctionTest method testMinFunctionQuantityTypeIncompatibleUnits.
@Test
public void testMinFunctionQuantityTypeIncompatibleUnits() {
items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("23.54 °C")));
items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL));
items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<Pressure>("192.2 hPa")));
function = new QuantityTypeArithmeticGroupFunction.Min(Temperature.class);
State state = function.calculate(items);
assertEquals(new QuantityType<Temperature>("23.54 °C"), state);
}
Aggregations