]> git.basschouten.com Git - openhab-addons.git/blob
99f35a39339a216d4cd9dc1c28194acc68559b2d
[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 org.junit.jupiter.api.BeforeEach;
16 import org.junit.jupiter.api.Test;
17 import org.openhab.core.library.types.OnOffType;
18
19 /**
20  * Test class for (@link LxControlUpDownDigital}
21  *
22  * @author Pawel Pieczul - initial contribution
23  *
24  */
25 public class LxControlUpDownDigitalTest extends LxControlTest {
26     String upChannel;
27     String downChannel;
28
29     @BeforeEach
30     public void setup() {
31         upChannel = " / Up";
32         downChannel = " / Down";
33         setupControl("0fd08ca6-01a6-d72a-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
34                 "0b734138-033e-02d4-ffff403fb0c34b9e", "First Floor Scene");
35     }
36
37     @Test
38     public void testControlCreation() {
39         testControlCreation(LxControlUpDownDigital.class, 1, 0, 2, 2, 0);
40     }
41
42     @Test
43     public void testChannels() {
44         testChannel("Switch", upChannel);
45         testChannel("Switch", downChannel);
46     }
47
48     @Test
49     public void testCommands() {
50         testChannelState(upChannel, OnOffType.OFF);
51         testChannelState(downChannel, OnOffType.OFF);
52
53         executeCommand(upChannel, OnOffType.ON);
54         testAction("UpOn");
55         testChannelState(upChannel, OnOffType.ON);
56         testChannelState(downChannel, OnOffType.OFF);
57         executeCommand(upChannel, OnOffType.OFF);
58         testAction("UpOff");
59         testChannelState(upChannel, OnOffType.OFF);
60         testChannelState(downChannel, OnOffType.OFF);
61
62         executeCommand(downChannel, OnOffType.ON);
63         testAction("DownOn");
64         testChannelState(upChannel, OnOffType.OFF);
65         testChannelState(downChannel, OnOffType.ON);
66         executeCommand(downChannel, OnOffType.OFF);
67         testAction("DownOff");
68         testChannelState(upChannel, OnOffType.OFF);
69         testChannelState(downChannel, OnOffType.OFF);
70
71         executeCommand(upChannel, OnOffType.ON);
72         testAction("UpOn");
73         testChannelState(upChannel, OnOffType.ON);
74         testChannelState(downChannel, OnOffType.OFF);
75         executeCommand(downChannel, OnOffType.ON);
76         testAction("DownOn");
77         testChannelState(upChannel, OnOffType.OFF);
78         testChannelState(downChannel, OnOffType.ON);
79
80         executeCommand(upChannel, OnOffType.ON);
81         testAction("UpOn");
82         testChannelState(upChannel, OnOffType.ON);
83         testChannelState(downChannel, OnOffType.OFF);
84
85         executeCommand(upChannel, OnOffType.OFF);
86         testAction("UpOff");
87         testChannelState(upChannel, OnOffType.OFF);
88         testChannelState(downChannel, OnOffType.OFF);
89
90         executeCommand(upChannel, OnOffType.OFF);
91         testAction(null);
92         testChannelState(upChannel, OnOffType.OFF);
93         testChannelState(downChannel, OnOffType.OFF);
94
95         executeCommand(downChannel, OnOffType.OFF);
96         testAction(null);
97         testChannelState(upChannel, OnOffType.OFF);
98         testChannelState(downChannel, OnOffType.OFF);
99     }
100 }