]> git.basschouten.com Git - openhab-addons.git/blob
199d97eb75a54bfa75a256fdeb941c64ea09ce1c
[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.loxone.internal.controls;
14
15 import java.util.Set;
16
17 import org.junit.jupiter.api.BeforeEach;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.core.library.types.DecimalType;
20 import org.openhab.core.library.types.OnOffType;
21 import org.openhab.core.library.types.StringType;
22 import org.openhab.core.types.UnDefType;
23
24 /**
25  * Test class for (@link LxControlSwitch}
26  *
27  * @author Pawel Pieczul - initial contribution
28  *
29  */
30 public class LxControlSwitchTest extends LxControlTest {
31     @BeforeEach
32     public void setup() {
33         setupControl("0f2f6b5d-0349-83b1-ffff403fb0c34b9e", "0b734138-038c-0382-ffff403fb0c34b9e",
34                 "0b734138-033e-02d4-ffff403fb0c34b9e", "Switch Button");
35     }
36
37     @Test
38     public void testControlCreation() {
39         testControlCreation(LxControlSwitch.class, 1, 0, 1, 1, 1);
40     }
41
42     @Test
43     public void testChannels() {
44         testChannel("Switch", Set.of("Lighting"));
45     }
46
47     @Test
48     public void testLoxoneStateChanges() {
49         for (Double i = 2.0; i < 100.0; i++) {
50             changeLoxoneState("active", 0.0);
51             testChannelState(OnOffType.OFF);
52             changeLoxoneState("active", 1.0);
53             testChannelState(OnOffType.ON);
54             changeLoxoneState("active", 1.0 / i);
55             testChannelState(UnDefType.UNDEF);
56         }
57     }
58
59     @Test
60     public void testCommands() {
61         for (int i = 0; i < 100; i++) {
62             executeCommand(OnOffType.ON);
63             testAction("On");
64             executeCommand(DecimalType.ZERO);
65             testAction(null);
66             executeCommand(OnOffType.OFF);
67             testAction("Off");
68             executeCommand(StringType.EMPTY);
69             testAction(null);
70         }
71     }
72 }