]> git.basschouten.com Git - openhab-addons.git/blob
ca861c84d10c13c71484a5664e819c1773e71193
[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.max.internal.message;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.max.internal.device.DeviceConfiguration;
22 import org.openhab.binding.max.internal.device.DeviceType;
23
24 /**
25  * Tests cases for {@link DeviceConfiguration}.
26  *
27  * @author Andreas Heil - Initial contribution
28  * @author Marcel Verpaalen - OH2 Version and updates
29  */
30 @NonNullByDefault
31 public class ConfigurationTest {
32
33     public static final String RAW_DATA = "C:0b0da3,0gsNowIBEABLRVEwNTQ0MjQyLCQ9CQcYAzAM/wBIYViRSP1ZFE0gTSBNIEUgRSBFIEUgRSBFIEhhWJFQ/VkVUSBRIFEgRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIEhQWFpI/lkUTSBNIE0gRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIA==";
34
35     private final CMessage message = new CMessage(RAW_DATA);
36     private @Nullable DeviceConfiguration configuration;
37
38     @BeforeEach
39     public void before() {
40         configuration = DeviceConfiguration.create(message);
41     }
42
43     @Test
44     public void createTest() {
45         assertNotNull(configuration);
46     }
47
48     @Test
49     public void getRfAddressTest() {
50         final DeviceConfiguration configuration = this.configuration;
51         if (configuration != null) {
52             String rfAddress = configuration.getRFAddress();
53             assertEquals("0b0da3", rfAddress);
54         } else {
55             fail("Configuration missing");
56         }
57     }
58
59     @Test
60     public void getDeviceTypeTest() {
61         final DeviceConfiguration configuration = this.configuration;
62         if (configuration != null) {
63             DeviceType deviceType = configuration.getDeviceType();
64             assertEquals(DeviceType.HeatingThermostatPlus, deviceType);
65         } else {
66             fail("Configuration missing");
67         }
68     }
69
70     @Test
71     public void getSerialNumberTest() {
72         final DeviceConfiguration configuration = this.configuration;
73         if (configuration != null) {
74             String serialNumber = configuration.getSerialNumber();
75             assertEquals("KEQ0544242", serialNumber);
76         } else {
77             fail("Configuration missing");
78         }
79     }
80 }