Search in sources :

Example 26 with NumberItem

use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.

the class ScriptEngineOSGiTest method testEqualsWithItemState.

@SuppressWarnings("null")
@Test
public void testEqualsWithItemState() throws ScriptExecutionException, ScriptParsingException {
    Item numberItem = itemRegistry.get(NUMBER_ITEM_TEMPERATURE);
    ((NumberItem) numberItem).setState(new QuantityType<>("20 °C"));
    assertTrue(runScript("NumberA.state == 20 [°C]"));
}
Also used : NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Item(org.eclipse.smarthome.core.items.Item) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 27 with NumberItem

use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.

the class ScriptEngineOSGiTest method testGreaterThanWithItemState.

@SuppressWarnings("null")
@Test
public void testGreaterThanWithItemState() throws ScriptExecutionException, ScriptParsingException {
    Item numberItem = itemRegistry.get(NUMBER_ITEM_TEMPERATURE);
    ((NumberItem) numberItem).setState(new QuantityType<>("20 °C"));
    assertTrue(runScript("NumberA.state > 20 [°F]"));
}
Also used : NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Item(org.eclipse.smarthome.core.items.Item) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 28 with NumberItem

use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.

the class ScriptEngineOSGiTest method testGreaterThan_Number_Number.

@Test
public void testGreaterThan_Number_Number() throws ScriptParsingException, ScriptExecutionException {
    Item numberItem = itemRegistry.get(NUMBER_ITEM_DECIMAL);
    ((NumberItem) numberItem).setState(new DecimalType(20));
    assertTrue(runScript("NumberB.state > new DecimalType(19)"));
}
Also used : NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Item(org.eclipse.smarthome.core.items.Item) DecimalType(org.eclipse.smarthome.core.library.types.DecimalType) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 29 with NumberItem

use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.

the class ScriptEngineOSGiTest method testGreaterEqualsWithItemState.

@SuppressWarnings("null")
@Test
public void testGreaterEqualsWithItemState() throws ScriptExecutionException, ScriptParsingException {
    Item numberItem = itemRegistry.get(NUMBER_ITEM_TEMPERATURE);
    ((NumberItem) numberItem).setState(new QuantityType<>("20 °C"));
    assertTrue(runScript("NumberA.state >= 20 [°C]"));
}
Also used : NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Item(org.eclipse.smarthome.core.items.Item) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 30 with NumberItem

use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.

the class ScriptEngineOSGiTest method testLessEqualsWithItemState.

@SuppressWarnings("null")
@Test
public void testLessEqualsWithItemState() throws ScriptExecutionException, ScriptParsingException {
    Item numberItem = itemRegistry.get(NUMBER_ITEM_TEMPERATURE);
    ((NumberItem) numberItem).setState(new QuantityType<>("19 °F"));
    assertTrue(runScript("NumberA.state <= 20 [°F]"));
}
Also used : NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Item(org.eclipse.smarthome.core.items.Item) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Aggregations

NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)34 Test (org.junit.Test)25 Item (org.eclipse.smarthome.core.items.Item)17 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)15 SwitchItem (org.eclipse.smarthome.core.library.items.SwitchItem)13 QuantityType (org.eclipse.smarthome.core.library.types.QuantityType)12 State (org.eclipse.smarthome.core.types.State)11 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)6 ArithmeticGroupFunction (org.eclipse.smarthome.core.library.types.ArithmeticGroupFunction)5 StateDescription (org.eclipse.smarthome.core.types.StateDescription)5 Temperature (javax.measure.quantity.Temperature)4 GroupItem (org.eclipse.smarthome.core.items.GroupItem)4 ItemNotFoundException (org.eclipse.smarthome.core.items.ItemNotFoundException)4 Mapping (org.eclipse.smarthome.model.sitemap.Mapping)4 StateDescriptionProvider (org.eclipse.smarthome.core.types.StateDescriptionProvider)3 Collection (java.util.Collection)2 Length (javax.measure.quantity.Length)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 UnitProvider (org.eclipse.smarthome.core.i18n.UnitProvider)2 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)2