This repository has been archived by the owner on May 7, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set correct percent value for Rollershutter item
When setting DecimalType state for a Rollershutter item, the state should be converted to PercentType. Otherwise the group functions will present an error of factor 100. Fixes #1845 Signed-off-by: Hans Hazelius <hans@hazelius.se>
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...re.test/src/test/java/org/eclipse/smarthome/core/library/items/RollershutterItemTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.eclipse.smarthome.core.library.items; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.eclipse.smarthome.core.library.types.DecimalType; | ||
import org.eclipse.smarthome.core.library.types.PercentType; | ||
import org.eclipse.smarthome.core.library.types.UpDownType; | ||
import org.eclipse.smarthome.core.types.State; | ||
import org.junit.Test; | ||
|
||
public class RollershutterItemTest { | ||
|
||
@Test | ||
public void setState_stateDown_returnPercent100() { | ||
RollershutterItem sut = new RollershutterItem("Test"); | ||
State state = UpDownType.DOWN; | ||
sut.setState(state); | ||
assertEquals(PercentType.HUNDRED, sut.getState()); | ||
} | ||
|
||
@Test | ||
public void setState_stateUp_returnPercent0() { | ||
RollershutterItem sut = new RollershutterItem("Test"); | ||
State state = UpDownType.UP; | ||
sut.setState(state); | ||
assertEquals(PercentType.ZERO, sut.getState()); | ||
} | ||
|
||
@Test | ||
public void setState_statePercent50_returnPercent50() { | ||
RollershutterItem sut = new RollershutterItem("Test"); | ||
State state = new PercentType(50); | ||
sut.setState(state); | ||
assertEquals(state, sut.getState()); | ||
} | ||
|
||
@Test | ||
public void setState_stateDecimal050_returnPercent50() { | ||
RollershutterItem sut = new RollershutterItem("Test"); | ||
State state = new DecimalType(0.50); | ||
sut.setState(state); | ||
assertEquals(new PercentType(50), sut.getState()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters