]> git.basschouten.com Git - openhab-addons.git/blob
28de642f35383e82555b7c4efd9976f2a00587c3
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.rfxcom.internal.messages;
14
15 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
16 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.HOME_CONFORT;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.Test;
20 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
21 import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.Commands;
22 import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.SubType;
23 import org.openhab.core.util.HexUtils;
24
25 /**
26  * Test for RFXCom-binding
27  *
28  * @author Martin van Wingerden - Initial contribution
29  * @author Mike Jagdis - added message handling and real test
30  */
31 @NonNullByDefault
32 public class RFXComHomeConfortTest {
33     private void testMessage(SubType subType, Commands command, String deviceId, String data) throws RFXComException {
34         RFXComHomeConfortMessage message = (RFXComHomeConfortMessage) RFXComMessageFactoryImpl.INSTANCE
35                 .createMessage(HOME_CONFORT);
36         message.setSubType(subType);
37         message.command = command;
38         message.setDeviceId(deviceId);
39
40         assertArrayEquals(HexUtils.hexToBytes(data), message.decodeMessage());
41     }
42
43     @Test
44     public void testMessage1() throws RFXComException {
45         testMessage(SubType.TEL_010, Commands.GROUP_ON, "1118739.A.4", "0C1B0000111213410403000000");
46     }
47 }