2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.max.internal.message;
15 import static org.junit.jupiter.api.Assertions.*;
17 import java.util.List;
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;
26 * Tests cases for {@link MMessage}.
28 * @author Marcel Verpaalen - Initial contribution
31 public class MMessageTest {
33 public static final String RAW_DATA = "M:00,01,VgIFAQhiYWRrYW1lcgsNowIMU3R1ZGVlcmthbWVyB7bnAwlXb29ua2FtZXIL6aIEDFN6b25qYSBLYW1lcgjDSQUGWm9sZGVyCMHWCAILDaNLRVEwNTQ0MjQyEUJhZGthbWVyIFJhZGlhdG9yAQEHtudLRVEwMTQ1MTcyFVJhZGlhdG9yIFN0dWRlZXJrYW1lcgIDDhXMTEVRMDAxNTM0MBlXYWxsIFRoZXJtb3N0YXQgV29vbmthbWVyAwEL6aJLRVE5MDE1NDMyG1BsdWcgQWRhcHRlciBNdXVydmVyd2FybWluZwMFBDNvSkVRMDM4MDg3OBdFY28gU3dpdGNoIFN0dWRlZXJrYW1lcgAEDnX2S0VRMTEwNDM4MBpXaW5kb3cgU2Vuc29yIFN0dWRlZXJrYW1lcgIBCMNJS0VRMDY0ODk0ORJUaGVybW9zdGFhdCBTem9uamEEAQjB1ktFUTA2NDkzMTIRU3R1ZGVlcmthbWVyIElybWEFAQ==";
35 private final MMessage message = new MMessage(RAW_DATA);
38 public void getMessageTypeTest() {
39 MessageType messageType = ((Message) message).getType();
40 assertEquals(MessageType.M, messageType);
44 public void deviceInformationTest() {
45 List<DeviceInformation> allDevicesInformation = message.devices;
47 assertEquals(8, allDevicesInformation.size());
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());
58 public void deviceInformationTypeTest1() {
59 List<DeviceInformation> allDevicesInformation = message.devices;
60 DeviceInformation deviceInformation = allDevicesInformation.get(1);
61 assertEquals(DeviceType.HeatingThermostat, deviceInformation.getDeviceType());
65 public void deviceInformationTypeTest2() {
66 List<DeviceInformation> allDevicesInformation = message.devices;
67 DeviceInformation deviceInformation = allDevicesInformation.get(2);
68 assertEquals(DeviceType.WallMountedThermostat, deviceInformation.getDeviceType());
72 public void deviceInformationTypeTest3() {
73 List<DeviceInformation> allDevicesInformation = message.devices;
74 DeviceInformation deviceInformation = allDevicesInformation.get(4);
75 assertEquals(DeviceType.EcoSwitch, deviceInformation.getDeviceType());
79 public void deviceInformationTypeTest4() {
80 List<DeviceInformation> allDevicesInformation = message.devices;
81 DeviceInformation deviceInformation = allDevicesInformation.get(5);
82 assertEquals(DeviceType.ShutterContact, deviceInformation.getDeviceType());
86 public void roomInformationTest() {
87 List<RoomInformation> roomInformation = message.rooms;
89 assertEquals(5, roomInformation.size());
90 assertEquals("badkamer", roomInformation.get(0).getName());