]> git.basschouten.com Git - openhab-addons.git/blob
594d52348b353f82d1cdee4f9fe49c317c1d21bf
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lcn.internal.subhandler;
14
15 import static org.mockito.Mockito.verify;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.BeforeEach;
19 import org.junit.jupiter.api.Test;
20 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
21 import org.openhab.binding.lcn.internal.common.LcnException;
22 import org.openhab.core.library.types.StopMoveType;
23 import org.openhab.core.library.types.UpDownType;
24
25 /**
26  * Test class.
27  *
28  * @author Fabian Wolter - Initial contribution
29  */
30 @NonNullByDefault
31 public class LcnModuleRollershutterOutputSubHandlerTest extends AbstractTestLcnModuleSubHandler {
32     private @NonNullByDefault({}) LcnModuleRollershutterOutputSubHandler l;
33
34     @Override
35     @BeforeEach
36     public void setUp() {
37         super.setUp();
38
39         l = new LcnModuleRollershutterOutputSubHandler(handler, info);
40     }
41
42     @Test
43     public void testUp() throws LcnException {
44         l.handleCommandUpDown(UpDownType.UP, LcnChannelGroup.ROLLERSHUTTEROUTPUT, 0, false);
45         verify(handler).sendPck("A1DI100008");
46     }
47
48     @Test
49     public void testUpInverted() throws LcnException {
50         l.handleCommandUpDown(UpDownType.UP, LcnChannelGroup.ROLLERSHUTTEROUTPUT, 0, true);
51         verify(handler).sendPck("A2DI100008");
52     }
53
54     @Test
55     public void testDown() throws LcnException {
56         l.handleCommandUpDown(UpDownType.DOWN, LcnChannelGroup.ROLLERSHUTTEROUTPUT, 0, false);
57         verify(handler).sendPck("A2DI100008");
58     }
59
60     @Test
61     public void testDownInverted() throws LcnException {
62         l.handleCommandUpDown(UpDownType.DOWN, LcnChannelGroup.ROLLERSHUTTEROUTPUT, 0, true);
63         verify(handler).sendPck("A1DI100008");
64     }
65
66     @Test
67     public void testStop() throws LcnException {
68         l.handleCommandStopMove(StopMoveType.STOP, LcnChannelGroup.ROLLERSHUTTEROUTPUT, 0);
69         verify(handler).sendPck("A1DI000000");
70         verify(handler).sendPck("A2DI000000");
71     }
72
73     @Test
74     public void testMove() throws LcnException {
75         l.handleCommandStopMove(StopMoveType.MOVE, LcnChannelGroup.ROLLERSHUTTEROUTPUT, 0);
76         verify(handler).sendPck("A2DI100008");
77     }
78 }