]> git.basschouten.com Git - openhab-addons.git/blob
95276887370ec32894ff8c06a723ff6afd8ac48d
[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.ArgumentMatchers.any;
16 import static org.mockito.Mockito.*;
17
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
23 /**
24  * Test class.
25  *
26  * @author Andre Jendrysseck - Initial contribution
27  */
28 @NonNullByDefault
29 public class LcnModuleCodeSubHandlerTest extends AbstractTestLcnModuleSubHandler {
30
31     @Override
32     @BeforeEach
33     public void setUp() {
34         super.setUp();
35     }
36
37     @Test
38     public void testHexFingerprint() {
39         tryParseAllHandlers("=M000005.ZFABCDEF");
40         verify(handler).triggerChannel(LcnChannelGroup.CODE, "fingerprint", "ABCDEF");
41         verify(handler).triggerChannel(any(), any(), any());
42     }
43
44     @Test
45     public void testDecFingerprint() {
46         tryParseAllHandlers("=M000005.ZF255001002");
47         verify(handler).triggerChannel(LcnChannelGroup.CODE, "fingerprint", "FF0102");
48         verify(handler).triggerChannel(any(), any(), any());
49     }
50
51     @Test
52     public void testTransponder() {
53         tryParseAllHandlers("=M000005.ZT255001002");
54         verify(handler).triggerChannel(LcnChannelGroup.CODE, "transponder", "FF0102");
55         verify(handler).triggerChannel(any(), any(), any());
56     }
57
58     @Test
59     public void testRemote() {
60         tryParseAllHandlers("=M000005.ZI255001002013001");
61         verify(handler).triggerChannel(LcnChannelGroup.CODE, "remotecontrolkey", "B3:HIT");
62         verify(handler).triggerChannel(LcnChannelGroup.CODE, "remotecontrolcode", "FF0102:B3:HIT");
63         verify(handler, times(2)).triggerChannel(any(), any(), any());
64     }
65
66     @Test
67     public void testRemoteBatteryLow() {
68         tryParseAllHandlers("=M000005.ZI255001002008012");
69         verify(handler).triggerChannel(LcnChannelGroup.CODE, "remotecontrolkey", "A8:MAKE");
70         verify(handler).triggerChannel(LcnChannelGroup.CODE, "remotecontrolcode", "FF0102:A8:MAKE");
71         verify(handler).triggerChannel(LcnChannelGroup.CODE, "remotecontrolbatterylow", "FF0102");
72         verify(handler, times(3)).triggerChannel(any(), any(), any());
73     }
74 }