Search in sources :

Example 11 with Temperature

use of javax.measure.quantity.Temperature in project smarthome by eclipse.

the class QuantityTypeArithmeticGroupFunctionTest method testMaxFunctionQuantityTypeDifferentUnits.

@Test
public void testMaxFunctionQuantityTypeDifferentUnits() {
    items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("100 °C")));
    items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL));
    items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<Temperature>("113 °F")));
    items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF));
    items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<Temperature>("294.15 K")));
    function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class);
    State state = function.calculate(items);
    assertEquals(new QuantityType<Temperature>("100 °C"), state);
}
Also used : Temperature(javax.measure.quantity.Temperature) State(org.eclipse.smarthome.core.types.State) Test(org.junit.Test)

Example 12 with Temperature

use of javax.measure.quantity.Temperature in project smarthome by eclipse.

the class QuantityTypeArithmeticGroupFunctionTest method testSumFunctionQuantityTypeDifferentUnits.

@Test
public void testSumFunctionQuantityTypeDifferentUnits() {
    items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("23.54 °C")));
    items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL));
    items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<Temperature>("192.2 °F")));
    items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF));
    items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<Temperature>("395.56 K")));
    function = new QuantityTypeArithmeticGroupFunction.Sum(Temperature.class);
    State state = function.calculate(items);
    assertEquals(new QuantityType<Temperature>("234.95 °C"), state);
}
Also used : Temperature(javax.measure.quantity.Temperature) State(org.eclipse.smarthome.core.types.State) Test(org.junit.Test)

Example 13 with Temperature

use of javax.measure.quantity.Temperature 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);
}
Also used : Temperature(javax.measure.quantity.Temperature) State(org.eclipse.smarthome.core.types.State) Pressure(javax.measure.quantity.Pressure) Test(org.junit.Test)

Example 14 with Temperature

use of javax.measure.quantity.Temperature in project smarthome by eclipse.

the class QuantityTypeArithmeticGroupFunctionTest method testAvgFunctionQuantityTypeIncompatibleUnits.

@Test
public void testAvgFunctionQuantityTypeIncompatibleUnits() {
    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<Temperature>("192.2 hPa")));
    function = new QuantityTypeArithmeticGroupFunction.Avg(Temperature.class);
    State state = function.calculate(items);
    assertEquals(new QuantityType<Temperature>("23.54 °C"), state);
}
Also used : Temperature(javax.measure.quantity.Temperature) State(org.eclipse.smarthome.core.types.State) Pressure(javax.measure.quantity.Pressure) Test(org.junit.Test)

Example 15 with Temperature

use of javax.measure.quantity.Temperature 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);
}
Also used : Temperature(javax.measure.quantity.Temperature) State(org.eclipse.smarthome.core.types.State) Pressure(javax.measure.quantity.Pressure) Test(org.junit.Test)

Aggregations

Temperature (javax.measure.quantity.Temperature)19 Test (org.junit.Test)18 State (org.eclipse.smarthome.core.types.State)13 Pressure (javax.measure.quantity.Pressure)5 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)4 BigDecimal (java.math.BigDecimal)3 QuantityType (org.eclipse.smarthome.core.library.types.QuantityType)3 GroupFunctionDTO (org.eclipse.smarthome.core.items.dto.GroupFunctionDTO)2 ArithmeticGroupFunction (org.eclipse.smarthome.core.library.types.ArithmeticGroupFunction)2 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)2 LinkedList (java.util.LinkedList)1 Dimensionless (javax.measure.quantity.Dimensionless)1 Item (org.eclipse.smarthome.core.items.Item)1 DateTimeType (org.eclipse.smarthome.core.library.types.DateTimeType)1 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)1 HSBType (org.eclipse.smarthome.core.library.types.HSBType)1 PercentType (org.eclipse.smarthome.core.library.types.PercentType)1 PointType (org.eclipse.smarthome.core.library.types.PointType)1 RawType (org.eclipse.smarthome.core.library.types.RawType)1 StringListType (org.eclipse.smarthome.core.library.types.StringListType)1