]> git.basschouten.com Git - openhab-addons.git/blob
7838d4d3b376d57634e7e1a4f510fb2bcb046e17
[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.verify;
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 import org.openhab.core.library.types.DecimalType;
23
24 /**
25  * Test class.
26  *
27  * @author Fabian Wolter - Initial contribution
28  */
29 @NonNullByDefault
30 public class LcnModuleS0CounterSubHandlerTest extends AbstractTestLcnModuleSubHandler {
31     @Override
32     @BeforeEach
33     public void setUp() {
34         super.setUp();
35     }
36
37     @Test
38     public void testZero() {
39         tryParseAllHandlers("=M000005.C10");
40         verify(handler).updateChannel(LcnChannelGroup.S0INPUT, "1", new DecimalType(0));
41         verify(handler).updateChannel(any(), any(), any());
42     }
43
44     @Test
45     public void testMaxValue() {
46         tryParseAllHandlers("=M000005.C14294967295");
47         verify(handler).updateChannel(LcnChannelGroup.S0INPUT, "1", new DecimalType(4294967295L));
48         verify(handler).updateChannel(any(), any(), any());
49     }
50
51     @Test
52     public void test4() {
53         tryParseAllHandlers("=M000005.C412345");
54         verify(handler).updateChannel(LcnChannelGroup.S0INPUT, "4", new DecimalType(12345));
55         verify(handler).updateChannel(any(), any(), any());
56     }
57 }