Search in sources :

Example 31 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.

the class NumberItemTest method setPercentType.

@Test
public void setPercentType() {
    NumberItem item = new NumberItem("test");
    State percent = new PercentType(50);
    item.setState(percent);
    assertEquals(percent, item.getState());
}
Also used : State(org.eclipse.smarthome.core.types.State) PercentType(org.eclipse.smarthome.core.library.types.PercentType) Test(org.junit.Test)

Example 32 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType 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 33 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType 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 34 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.

the class SwitchItemTest method getAsPercentFromSwitch.

@Test
public void getAsPercentFromSwitch() {
    SwitchItem item = new SwitchItem("Test");
    item.setState(OnOffType.ON);
    assertEquals(new PercentType(100), item.getStateAs(PercentType.class));
    item.setState(OnOffType.OFF);
    assertEquals(new PercentType(0), item.getStateAs(PercentType.class));
}
Also used : PercentType(org.eclipse.smarthome.core.library.types.PercentType) Test(org.junit.Test)

Example 35 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.

the class ItemUIRegistryImplTest method getLabel_labelWithPercentType.

@Test
public void getLabel_labelWithPercentType() throws ItemNotFoundException {
    String testLabel = "Label [%d %%]";
    when(widget.getLabel()).thenReturn(testLabel);
    when(item.getState()).thenReturn(new PercentType(42));
    String label = uiRegistry.getLabel(widget);
    assertEquals("Label [42 %]", label);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PercentType(org.eclipse.smarthome.core.library.types.PercentType) Test(org.junit.Test)

Aggregations

PercentType (org.eclipse.smarthome.core.library.types.PercentType)63 Test (org.junit.Test)25 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)17 State (org.eclipse.smarthome.core.types.State)17 HSBType (org.eclipse.smarthome.core.library.types.HSBType)16 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)13 LifxMessageUtil.increaseDecreasePercentType (org.eclipse.smarthome.binding.lifx.internal.util.LifxMessageUtil.increaseDecreasePercentType)9 StringType (org.eclipse.smarthome.core.library.types.StringType)9 IncreaseDecreaseType (org.eclipse.smarthome.core.library.types.IncreaseDecreaseType)7 RefreshType (org.eclipse.smarthome.core.types.RefreshType)7 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)6 ColorItem (org.eclipse.smarthome.core.library.items.ColorItem)4 RollershutterItem (org.eclipse.smarthome.core.library.items.RollershutterItem)4 QuantityType (org.eclipse.smarthome.core.library.types.QuantityType)4 BigDecimal (java.math.BigDecimal)3 ValueSet (org.eclipse.smarthome.binding.dmx.internal.ValueSet)3 FadeAction (org.eclipse.smarthome.binding.dmx.internal.action.FadeAction)3 DimmerItem (org.eclipse.smarthome.core.library.items.DimmerItem)3 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)3 LinkedList (java.util.LinkedList)2