]> git.basschouten.com Git - openhab-addons.git/blob
d5bbe5147fbc1ccb8740dfad02199800fd94e25d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
16 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.FAN_NOVY;
17 import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubType.NOVY;
18
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;
28
29 /**
30  * Test for RFXCom-binding
31  *
32  * @author Martin van Wingerden - Initial contribution
33  */
34 @NonNullByDefault
35 public class RFXComFanNovyMessage {
36
37     @Test
38     public void testUp() throws RFXComException {
39         testCommand(CHANNEL_FAN_SPEED, UpDownType.UP, UnDefType.UNDEF, UpDownType.UP, StringType.valueOf("UP"));
40     }
41
42     @Test
43     public void testDown() throws RFXComException {
44         testCommand(CHANNEL_FAN_SPEED, UpDownType.DOWN, UnDefType.UNDEF, UpDownType.DOWN, StringType.valueOf("DOWN"));
45     }
46
47     @Test
48     public void testCommandString() throws RFXComException {
49         testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("POWER"), UnDefType.UNDEF, null,
50                 StringType.valueOf("POWER"));
51         testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("UP"), UnDefType.UNDEF, UpDownType.UP,
52                 StringType.valueOf("UP"));
53         testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("DOWN"), UnDefType.UNDEF, UpDownType.DOWN,
54                 StringType.valueOf("DOWN"));
55         testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("LIGHT"), OnOffType.ON, null,
56                 StringType.valueOf("LIGHT"));
57         testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("LEARN"), UnDefType.UNDEF, null,
58                 StringType.valueOf("LEARN"));
59         testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("RESET_FILTER"), UnDefType.UNDEF, null,
60                 StringType.valueOf("RESET_FILTER"));
61     }
62
63     private void testCommand(String channel, State inputValue, State expectedLightCommand,
64             @Nullable State expectedFanSpeed, State expectedCommandString) throws RFXComException {
65         RFXComFanMessageTest.testCommand(NOVY, channel, inputValue, null, expectedLightCommand, expectedFanSpeed,
66                 expectedCommandString, FAN_NOVY);
67     }
68 }