RollershutterItem extends GenericItem { @Override public void setState(State state) { if (isAcceptedState(acceptedDataTypes, state)) { State convertedState = state.as(PercentType.class); if (convertedState != null) { applyState(convertedState); } else { applyState(state); } } else { logSetTypeError(state); } } RollershutterItem(String name); @Override List<Class<? extends State>> getAcceptedDataTypes(); @Override List<Class<? extends Command>> getAcceptedCommandTypes(); void send(UpDownType command); void send(StopMoveType command); void send(PercentType command); @Override void setState(State state);  }
@Test public void setStateStateDownReturnPercent100() { RollershutterItem sut = new RollershutterItem("Test"); State state = UpDownType.DOWN; sut.setState(state); assertEquals(PercentType.HUNDRED, sut.getState()); }
@Test public void setStateStateUpReturnPercent0() { RollershutterItem sut = new RollershutterItem("Test"); State state = UpDownType.UP; sut.setState(state); assertEquals(PercentType.ZERO, sut.getState()); }
@Test public void setStateStatePercent50ReturnPercent50() { RollershutterItem sut = new RollershutterItem("Test"); State state = new PercentType(50); sut.setState(state); assertEquals(state, sut.getState()); }
@Test public void setStateStateHSB50ReturnPercent50() { RollershutterItem sut = new RollershutterItem("Test"); State state = new HSBType("5,23,42"); sut.setState(state); assertEquals(new PercentType(42), sut.getState()); }