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.rfxcom.internal.messages;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
20 import org.openhab.binding.rfxcom.internal.messages.RFXComBlinds1Message.Commands;
21 import org.openhab.binding.rfxcom.internal.messages.RFXComBlinds1Message.SubType;
22 import org.openhab.core.util.HexUtils;
25 * Test for RFXCom-binding
27 * @author Martin van Wingerden - Initial contribution
30 public class RFXComBlinds1MessageTest {
31 private void testMessage(String hexMsg, SubType subType, int seqNbr, String deviceId, int signalLevel,
32 RFXComBlinds1Message.Commands command) throws RFXComException {
33 final RFXComBlinds1Message msg = (RFXComBlinds1Message) RFXComMessageFactoryImpl.INSTANCE
34 .createMessage(HexUtils.hexToBytes(hexMsg));
35 assertEquals(subType, msg.subType, "SubType");
36 assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
37 assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
38 assertEquals(command, msg.command, "Command");
39 assertEquals(signalLevel, msg.signalLevel, "Signal Level");
41 byte[] decoded = msg.decodeMessage();
43 assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
47 public void testSomeMessages() throws RFXComException {
48 testMessage("0919040600A21B010280", SubType.T4, 6, "41499.1", 8, Commands.STOP);
50 testMessage("091905021A6280010000", SubType.T5, 2, "1729152.1", 0, Commands.OPEN);