]> git.basschouten.com Git - openhab-addons.git/blob
ae57ce7fc820a91542662431924c60ff30e032d1
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.LcnDefs;
22 import org.openhab.binding.lcn.internal.common.LcnException;
23 import org.openhab.core.library.types.OnOffType;
24 import org.openhab.core.library.types.StringType;
25
26 /**
27  * Test class.
28  *
29  * @author Fabian Wolter - Initial contribution
30  */
31 @NonNullByDefault
32 public class LcnModuleLedSubHandlerTest extends AbstractTestLcnModuleSubHandler {
33     private @NonNullByDefault({}) LcnModuleLedSubHandler l;
34
35     @Override
36     @BeforeEach
37     public void setUp() {
38         super.setUp();
39
40         l = new LcnModuleLedSubHandler(handler, info);
41     }
42
43     @Test
44     public void testHandleCommandLed1Off() throws LcnException {
45         l.handleCommandString(new StringType(LcnDefs.LedStatus.OFF.name()), 0);
46         verify(handler).sendPck("LA001A");
47     }
48
49     @Test
50     public void testHandleCommandLed1On() throws LcnException {
51         l.handleCommandString(new StringType(LcnDefs.LedStatus.ON.name()), 0);
52         verify(handler).sendPck("LA001E");
53     }
54
55     @Test
56     public void testHandleCommandLed1Blink() throws LcnException {
57         l.handleCommandString(new StringType(LcnDefs.LedStatus.BLINK.name()), 0);
58         verify(handler).sendPck("LA001B");
59     }
60
61     @Test
62     public void testHandleCommandLed1Flicker() throws LcnException {
63         l.handleCommandString(new StringType(LcnDefs.LedStatus.FLICKER.name()), 0);
64         verify(handler).sendPck("LA001F");
65     }
66
67     @Test
68     public void testHandleCommandLed12On() throws LcnException {
69         l.handleCommandString(new StringType(LcnDefs.LedStatus.ON.name()), 11);
70         verify(handler).sendPck("LA012E");
71     }
72
73     @Test
74     public void testHandleOnOffCommandLed1Off() throws LcnException {
75         l.handleCommandOnOff(OnOffType.OFF, LcnChannelGroup.LED, 0);
76         verify(handler).sendPck("LA001A");
77     }
78
79     @Test
80     public void testHandleOnOffCommandLed1On() throws LcnException {
81         l.handleCommandOnOff(OnOffType.ON, LcnChannelGroup.LED, 0);
82         verify(handler).sendPck("LA001E");
83     }
84 }