2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lcn.internal.subhandler;
15 import static org.mockito.ArgumentMatchers.any;
16 import static org.mockito.Mockito.verify;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
22 import org.openhab.binding.lcn.internal.common.LcnException;
23 import org.openhab.core.library.types.PercentType;
24 import org.openhab.core.library.types.StopMoveType;
25 import org.openhab.core.library.types.UpDownType;
30 * @author Fabian Wolter - Initial contribution
33 public class AbstractLcnModuleRollershutterRelaySubHandlerTest extends AbstractTestLcnModuleSubHandler {
34 private @NonNullByDefault({}) AbstractLcnModuleRollershutterRelaySubHandler l;
41 l = new AbstractLcnModuleRollershutterRelaySubHandler(handler, info) {
46 public void testUp1() throws LcnException {
47 l.handleCommandUpDown(UpDownType.UP, LcnChannelGroup.ROLLERSHUTTERRELAY, 0, false);
48 verify(handler).sendPck("R810------");
52 public void testUpInverted() throws LcnException {
53 l.handleCommandUpDown(UpDownType.UP, LcnChannelGroup.ROLLERSHUTTERRELAY, 0, true);
54 verify(handler).sendPck("R811------");
58 public void testUp4() throws LcnException {
59 l.handleCommandUpDown(UpDownType.UP, LcnChannelGroup.ROLLERSHUTTERRELAY, 3, false);
60 verify(handler).sendPck("R8------10");
64 public void testDown1() throws LcnException {
65 l.handleCommandUpDown(UpDownType.DOWN, LcnChannelGroup.ROLLERSHUTTERRELAY, 0, false);
66 verify(handler).sendPck("R811------");
70 public void testDownInverted() throws LcnException {
71 l.handleCommandUpDown(UpDownType.DOWN, LcnChannelGroup.ROLLERSHUTTERRELAY, 0, true);
72 verify(handler).sendPck("R810------");
76 public void testDown4() throws LcnException {
77 l.handleCommandUpDown(UpDownType.DOWN, LcnChannelGroup.ROLLERSHUTTERRELAY, 3, false);
78 verify(handler).sendPck("R8------11");
82 public void testStop1() throws LcnException {
83 l.handleCommandStopMove(StopMoveType.STOP, LcnChannelGroup.ROLLERSHUTTERRELAY, 0);
84 verify(handler).sendPck("R80-------");
88 public void testStop4() throws LcnException {
89 l.handleCommandStopMove(StopMoveType.STOP, LcnChannelGroup.ROLLERSHUTTERRELAY, 3);
90 verify(handler).sendPck("R8------0-");
94 public void testMove1() throws LcnException {
95 l.handleCommandStopMove(StopMoveType.MOVE, LcnChannelGroup.ROLLERSHUTTERRELAY, 0);
96 verify(handler).sendPck("R81-------");
100 public void testMove4() throws LcnException {
101 l.handleCommandStopMove(StopMoveType.MOVE, LcnChannelGroup.ROLLERSHUTTERRELAY, 3);
102 verify(handler).sendPck("R8------1-");
106 public void testShutter1Percent0Position() {
107 tryParseAllHandlers(":M000005P1000");
108 verify(handler).updateChannel(LcnChannelGroup.ROLLERSHUTTERRELAY, "1", new PercentType(0));
109 verify(handler).updateChannel(any(), any(), any());
113 public void testShutter4Percent100Position() {
114 tryParseAllHandlers(":M000005P4100");
115 verify(handler).updateChannel(LcnChannelGroup.ROLLERSHUTTERRELAY, "4", new PercentType(100));
116 verify(handler).updateChannel(any(), any(), any());
120 public void testShutter1Percent0Angle() {
121 tryParseAllHandlers(":M000005W1000");
122 verify(handler).updateChannel(LcnChannelGroup.ROLLERSHUTTERRELAYSLAT, "1", new PercentType(0));
123 verify(handler).updateChannel(any(), any(), any());
127 public void testShutter4Percent100Angle() {
128 tryParseAllHandlers(":M000005W4100");
129 verify(handler).updateChannel(LcnChannelGroup.ROLLERSHUTTERRELAYSLAT, "4", new PercentType(100));
130 verify(handler).updateChannel(any(), any(), any());