2 * Copyright (c) 2010-2020 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.Assert.assertArrayEquals;
16 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.RFY;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.Test;
20 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
21 import org.openhab.binding.rfxcom.internal.messages.RFXComRfyMessage.Commands;
22 import org.openhab.binding.rfxcom.internal.messages.RFXComRfyMessage.SubType;
23 import org.openhab.core.util.HexUtils;
26 * Test for RFXCom-binding
28 * @author Martin van Wingerden - Initial contribution
31 public class RFXComRfyMessageTest {
34 public void basicBoundaryCheck() throws RFXComException {
35 RFXComRfyMessage message = (RFXComRfyMessage) RFXComMessageFactory.createMessage(RFY);
37 message.subType = SubType.RFY;
38 message.command = Commands.UP;
40 RFXComTestHelper.basicBoundaryCheck(RFY, message);
43 private void testMessage(SubType subType, Commands command, String deviceId, String data) throws RFXComException {
44 RFXComRfyMessage message = (RFXComRfyMessage) RFXComMessageFactory.createMessage(RFY);
45 message.setSubType(subType);
46 message.command = command;
47 message.setDeviceId(deviceId);
49 assertArrayEquals(HexUtils.hexToBytes(data), message.decodeMessage());
53 public void testMessage1() throws RFXComException {
54 testMessage(SubType.RFY, Commands.UP_SHORT, "66051.4", "0C1A0000010203040F00000000");
58 public void testMessage2() throws RFXComException {
59 testMessage(SubType.ASA, Commands.DOWN_LONG, "66051.4", "0C1A0300010203041200000000");