From e1d1c582b09af83fcc350b89117b1c3d38e852f2 Mon Sep 17 00:00:00 2001 From: Martin Grzeslowski Date: Fri, 17 May 2019 00:35:07 +0200 Subject: [PATCH] #15 Write test for reveal partially roller shutter --- .../supla/handler/CloudDeviceHandlerTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bundles/org.openhab.binding.supla/src/test/java/org/openhab/binding/supla/handler/CloudDeviceHandlerTest.java b/bundles/org.openhab.binding.supla/src/test/java/org/openhab/binding/supla/handler/CloudDeviceHandlerTest.java index 08323d62f8588..948fd6e3bdbec 100644 --- a/bundles/org.openhab.binding.supla/src/test/java/org/openhab/binding/supla/handler/CloudDeviceHandlerTest.java +++ b/bundles/org.openhab.binding.supla/src/test/java/org/openhab/binding/supla/handler/CloudDeviceHandlerTest.java @@ -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; @@ -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; @@ -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)); }