Search in sources :

Example 16 with Temperature

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

the class QuantityTypeArithmeticGroupFunctionTest method testSumFunctionQuantityTypeIncompatibleUnits.

@Test
public void testSumFunctionQuantityTypeIncompatibleUnits() {
    // we need an ordered set to guarantee the Unit of the first entry
    items = new LinkedHashSet<Item>();
    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.Sum(Temperature.class);
    State state = function.calculate(items);
    assertEquals(new QuantityType<Temperature>("23.54 °C"), state);
}
Also used : NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Item(org.eclipse.smarthome.core.items.Item) Temperature(javax.measure.quantity.Temperature) State(org.eclipse.smarthome.core.types.State) Pressure(javax.measure.quantity.Pressure) Test(org.junit.Test)

Example 17 with Temperature

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

the class QuantityTypeArithmeticGroupFunctionTest method testMaxFunctionQuantityType.

@Test
public void testMaxFunctionQuantityType() {
    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>("200 °C")));
    items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF));
    items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<Temperature>("300 °C")));
    function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class);
    State state = function.calculate(items);
    assertEquals(new QuantityType<Temperature>("300 °C"), state);
}
Also used : Temperature(javax.measure.quantity.Temperature) State(org.eclipse.smarthome.core.types.State) Test(org.junit.Test)

Example 18 with Temperature

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

the class QuantityTypeArithmeticGroupFunctionTest method testSumFunctionQuantityType.

@Test
public void testSumFunctionQuantityType() {
    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>("89 °C")));
    items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF));
    items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<Temperature>("122.41 °C")));
    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 19 with Temperature

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

the class QuantityTypeArithmeticGroupFunctionTest method testMinFunctionQuantityType.

@Test
public void testMinFunctionQuantityType() {
    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>("200 °C")));
    items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF));
    items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<Temperature>("300 °C")));
    function = new QuantityTypeArithmeticGroupFunction.Min(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)

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