Skip to content

Commit

Permalink
openhab#15 Write test for reveal partially roller shutter
Browse files Browse the repository at this point in the history
  • Loading branch information
magx2 committed May 17, 2019
1 parent 6d54914 commit e1d1c58
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.eclipse.smarthome.config.core.Configuration;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.OpenClosedType;
import org.eclipse.smarthome.core.library.types.PercentType;
import org.eclipse.smarthome.core.library.types.UpDownType;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.ChannelUID;
Expand Down Expand Up @@ -59,6 +60,7 @@
import static pl.grzeslowski.jsupla.api.generated.model.ChannelFunctionActionEnum.CLOSE;
import static pl.grzeslowski.jsupla.api.generated.model.ChannelFunctionActionEnum.OPEN;
import static pl.grzeslowski.jsupla.api.generated.model.ChannelFunctionActionEnum.REVEAL;
import static pl.grzeslowski.jsupla.api.generated.model.ChannelFunctionActionEnum.REVEAL_PARTIALLY;
import static pl.grzeslowski.jsupla.api.generated.model.ChannelFunctionActionEnum.SHUT;
import static pl.grzeslowski.jsupla.api.generated.model.ChannelFunctionActionEnum.TURN_OFF;
import static pl.grzeslowski.jsupla.api.generated.model.ChannelFunctionActionEnum.TURN_ON;
Expand Down Expand Up @@ -325,6 +327,24 @@ void rollerShutterDown() throws Exception {
assertThat(value.getAction()).isEqualTo(SHUT);
}

@Test
@DisplayName("should send request to Supla Cloud to reveal partially roller shutter")
void revealPartiallyRollerShutter() throws Exception {

// given
final ChannelUID rollerShutterChannelUID = findRollerShutterChannelUID();
final int percentage = 33;

// when
handler.handlePercentCommand(rollerShutterChannelUID, new PercentType(percentage));

// then
verify(channelsCloudApi).executeAction(channelExecuteActionRequestCaptor.capture(), eq(rollerShutterChannelId));
ChannelExecuteActionRequest value = channelExecuteActionRequestCaptor.getValue();
assertThat(value.getAction()).isEqualTo(REVEAL_PARTIALLY);
assertThat(value.getPercentage()).isEqualTo(percentage);
}

ChannelUID buildChannelUID(int id) {
return new ChannelUID(thingUID, valueOf(id));
}
Expand Down

0 comments on commit e1d1c58

Please sign in to comment.