Search in sources :

Example 71 with State

use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.

the class RollershutterItemTest method setState_statePercent50_returnPercent50.

@Test
public void setState_statePercent50_returnPercent50() {
    RollershutterItem sut = new RollershutterItem("Test");
    State state = new PercentType(50);
    sut.setState(state);
    assertEquals(state, sut.getState());
}
Also used : State(org.eclipse.smarthome.core.types.State) PercentType(org.eclipse.smarthome.core.library.types.PercentType) Test(org.junit.Test)

Example 72 with State

use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.

the class RollershutterItemTest method setState_stateHSB50_returnPercent50.

@Test
public void setState_stateHSB50_returnPercent50() {
    // HSB supported because it is a sub-type of PercentType
    RollershutterItem sut = new RollershutterItem("Test");
    State state = new HSBType("5,23,42");
    sut.setState(state);
    assertEquals(new PercentType(42), sut.getState());
}
Also used : State(org.eclipse.smarthome.core.types.State) PercentType(org.eclipse.smarthome.core.library.types.PercentType) HSBType(org.eclipse.smarthome.core.library.types.HSBType) Test(org.junit.Test)

Example 73 with State

use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.

the class RollershutterItemTest method setState_stateDown_returnPercent100.

@Test
public void setState_stateDown_returnPercent100() {
    RollershutterItem sut = new RollershutterItem("Test");
    State state = UpDownType.DOWN;
    sut.setState(state);
    assertEquals(PercentType.HUNDRED, sut.getState());
}
Also used : State(org.eclipse.smarthome.core.types.State) Test(org.junit.Test)

Example 74 with State

use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.

the class ArithmeticGroupFunctionTest method testOrFunction_differntTypes.

@Test
public void testOrFunction_differntTypes() {
    DimmerItem dimmer1 = new DimmerItem("TestDimmer1");
    dimmer1.setState(new PercentType("42"));
    DimmerItem dimmer2 = new DimmerItem("TestDimmer2");
    dimmer2.setState(new DecimalType("0"));
    SwitchItem switch1 = new SwitchItem("TestSwitch1");
    switch1.setState(OnOffType.ON);
    SwitchItem switch2 = new SwitchItem("TestSwitch2");
    switch2.setState(OnOffType.OFF);
    items.add(dimmer1);
    items.add(dimmer2);
    items.add(switch1);
    items.add(switch2);
    function = new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF);
    State state = function.calculate(items);
    State decimalState = function.getStateAs(items, DecimalType.class);
    assertEquals(OnOffType.ON, state);
    assertEquals(new DecimalType("2"), decimalState);
}
Also used : State(org.eclipse.smarthome.core.types.State) DimmerItem(org.eclipse.smarthome.core.library.items.DimmerItem) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Test(org.junit.Test)

Example 75 with State

use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.

the class ArithmeticGroupFunctionTest method testSumFunction.

@Test
public void testSumFunction() {
    items.add(new TestItem("TestItem1", new DecimalType("23.54")));
    items.add(new TestItem("TestItem2", UnDefType.NULL));
    items.add(new TestItem("TestItem3", new DecimalType("89")));
    items.add(new TestItem("TestItem4", UnDefType.UNDEF));
    items.add(new TestItem("TestItem5", new DecimalType("122.41")));
    function = new ArithmeticGroupFunction.Sum();
    State state = function.calculate(items);
    assertEquals(new DecimalType("234.95"), state);
}
Also used : State(org.eclipse.smarthome.core.types.State) 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