2 * Copyright (c) 2010-2021 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.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
16 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.FAN_LUCCI_DC;
17 import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubType.LUCCI_AIR_DC;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.junit.jupiter.api.Test;
22 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
23 import org.openhab.core.library.types.OnOffType;
24 import org.openhab.core.library.types.StringType;
25 import org.openhab.core.library.types.UpDownType;
26 import org.openhab.core.types.State;
27 import org.openhab.core.types.UnDefType;
30 * Test for RFXCom-binding
32 * @author Martin van Wingerden - Initial contribution
35 public class RFXComFanLucciAirDcMessageTest {
38 public void testFanLightOn() throws RFXComException {
39 testCommand(CHANNEL_FAN_LIGHT, OnOffType.ON, OnOffType.ON, null, StringType.valueOf("LIGHT"));
43 public void testUp() throws RFXComException {
44 testCommand(CHANNEL_FAN_SPEED, UpDownType.UP, UnDefType.UNDEF, UpDownType.UP, StringType.valueOf("UP"));
48 public void testDown() throws RFXComException {
49 testCommand(CHANNEL_FAN_SPEED, UpDownType.DOWN, UnDefType.UNDEF, UpDownType.DOWN, StringType.valueOf("DOWN"));
53 public void testCommandString() throws RFXComException {
54 testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("POWER"), UnDefType.UNDEF, null,
55 StringType.valueOf("POWER"));
56 testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("UP"), UnDefType.UNDEF, UpDownType.UP,
57 StringType.valueOf("UP"));
58 testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("DOWN"), UnDefType.UNDEF, UpDownType.DOWN,
59 StringType.valueOf("DOWN"));
60 testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("LIGHT"), OnOffType.ON, null,
61 StringType.valueOf("LIGHT"));
62 testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("REVERSE"), UnDefType.UNDEF, null,
63 StringType.valueOf("REVERSE"));
64 testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("NATURAL_FLOW"), UnDefType.UNDEF, null,
65 StringType.valueOf("NATURAL_FLOW"));
66 testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("PAIR"), UnDefType.UNDEF, null,
67 StringType.valueOf("PAIR"));
70 private void testCommand(String channel, State inputValue, State expectedLightCommand,
71 @Nullable State expectedFanSpeed, State expectedCommandString) throws RFXComException {
72 RFXComFanMessageTest.testCommand(LUCCI_AIR_DC, channel, inputValue, null, expectedLightCommand,
73 expectedFanSpeed, expectedCommandString, FAN_LUCCI_DC);