Search in sources :

Example 81 with State

use of org.eclipse.smarthome.core.types.State 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 82 with State

use of org.eclipse.smarthome.core.types.State 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 83 with State

use of org.eclipse.smarthome.core.types.State 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 84 with State

use of org.eclipse.smarthome.core.types.State 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)

Example 85 with State

use of org.eclipse.smarthome.core.types.State 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)

Aggregations

State (org.eclipse.smarthome.core.types.State)130 Test (org.junit.Test)59 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)23 PercentType (org.eclipse.smarthome.core.library.types.PercentType)22 Item (org.eclipse.smarthome.core.items.Item)21 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)19 Temperature (javax.measure.quantity.Temperature)18 StringType (org.eclipse.smarthome.core.library.types.StringType)18 QuantityType (org.eclipse.smarthome.core.library.types.QuantityType)17 ItemNotFoundException (org.eclipse.smarthome.core.items.ItemNotFoundException)15 HSBType (org.eclipse.smarthome.core.library.types.HSBType)15 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)15 RollershutterItem (org.eclipse.smarthome.core.library.items.RollershutterItem)13 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)13 ColorItem (org.eclipse.smarthome.core.library.items.ColorItem)12 SwitchItem (org.eclipse.smarthome.core.library.items.SwitchItem)11 DimmerItem (org.eclipse.smarthome.core.library.items.DimmerItem)10 RawType (org.eclipse.smarthome.core.library.types.RawType)10 Pressure (javax.measure.quantity.Pressure)9 GroupItem (org.eclipse.smarthome.core.items.GroupItem)8