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());
}
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());
}
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());
}
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));
}
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);
}
Aggregations