]> git.basschouten.com Git - openhab-addons.git/blob
3e645636577aaf16c90f4fc1c4ba91a1cb477dd8
[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 java.util.List;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.max.internal.device.DeviceInformation;
22 import org.openhab.binding.max.internal.device.DeviceType;
23 import org.openhab.binding.max.internal.device.RoomInformation;
24
25 /**
26  * Tests cases for {@link MMessage}.
27  *
28  * @author Marcel Verpaalen - Initial contribution
29  */
30 @NonNullByDefault
31 public class MMessageTest {
32
33     public static final String RAW_DATA = "M:00,01,VgIFAQhiYWRrYW1lcgsNowIMU3R1ZGVlcmthbWVyB7bnAwlXb29ua2FtZXIL6aIEDFN6b25qYSBLYW1lcgjDSQUGWm9sZGVyCMHWCAILDaNLRVEwNTQ0MjQyEUJhZGthbWVyIFJhZGlhdG9yAQEHtudLRVEwMTQ1MTcyFVJhZGlhdG9yIFN0dWRlZXJrYW1lcgIDDhXMTEVRMDAxNTM0MBlXYWxsIFRoZXJtb3N0YXQgV29vbmthbWVyAwEL6aJLRVE5MDE1NDMyG1BsdWcgQWRhcHRlciBNdXVydmVyd2FybWluZwMFBDNvSkVRMDM4MDg3OBdFY28gU3dpdGNoIFN0dWRlZXJrYW1lcgAEDnX2S0VRMTEwNDM4MBpXaW5kb3cgU2Vuc29yIFN0dWRlZXJrYW1lcgIBCMNJS0VRMDY0ODk0ORJUaGVybW9zdGFhdCBTem9uamEEAQjB1ktFUTA2NDkzMTIRU3R1ZGVlcmthbWVyIElybWEFAQ==";
34
35     private final MMessage message = new MMessage(RAW_DATA);
36
37     @Test
38     public void getMessageTypeTest() {
39         MessageType messageType = ((Message) message).getType();
40         assertEquals(MessageType.M, messageType);
41     }
42
43     @Test
44     public void deviceInformationTest() {
45         List<DeviceInformation> allDevicesInformation = message.devices;
46
47         assertEquals(8, allDevicesInformation.size());
48
49         DeviceInformation deviceInformation = allDevicesInformation.get(0);
50         assertEquals("Badkamer Radiator", deviceInformation.getName());
51         assertEquals("0B0DA3", deviceInformation.getRFAddress());
52         assertEquals(1, deviceInformation.getRoomId());
53         assertEquals("KEQ0544242", deviceInformation.getSerialNumber());
54         assertEquals(DeviceType.HeatingThermostatPlus, deviceInformation.getDeviceType());
55     }
56
57     @Test
58     public void deviceInformationTypeTest1() {
59         List<DeviceInformation> allDevicesInformation = message.devices;
60         DeviceInformation deviceInformation = allDevicesInformation.get(1);
61         assertEquals(DeviceType.HeatingThermostat, deviceInformation.getDeviceType());
62     }
63
64     @Test
65     public void deviceInformationTypeTest2() {
66         List<DeviceInformation> allDevicesInformation = message.devices;
67         DeviceInformation deviceInformation = allDevicesInformation.get(2);
68         assertEquals(DeviceType.WallMountedThermostat, deviceInformation.getDeviceType());
69     }
70
71     @Test
72     public void deviceInformationTypeTest3() {
73         List<DeviceInformation> allDevicesInformation = message.devices;
74         DeviceInformation deviceInformation = allDevicesInformation.get(4);
75         assertEquals(DeviceType.EcoSwitch, deviceInformation.getDeviceType());
76     }
77
78     @Test
79     public void deviceInformationTypeTest4() {
80         List<DeviceInformation> allDevicesInformation = message.devices;
81         DeviceInformation deviceInformation = allDevicesInformation.get(5);
82         assertEquals(DeviceType.ShutterContact, deviceInformation.getDeviceType());
83     }
84
85     @Test
86     public void roomInformationTest() {
87         List<RoomInformation> roomInformation = message.rooms;
88
89         assertEquals(5, roomInformation.size());
90         assertEquals("badkamer", roomInformation.get(0).getName());
91     }
92 }