]> git.basschouten.com Git - openhab-addons.git/blob
b985aa6a9f511e31bfe6e99ecb16e4c37b93128e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.math.BigDecimal;
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.core.library.types.DecimalType;
22 import org.openhab.core.library.types.OnOffType;
23 import org.openhab.core.library.types.PercentType;
24 import org.openhab.core.types.StateOption;
25
26 /**
27  * Test class for (@link LxControlRadio} - variant with no 'all off' selection
28  *
29  * @author Pawel Pieczul - initial contribution
30  *
31  */
32 public class LxControlRadioTest extends LxControlTest {
33     @BeforeEach
34     public void setup() {
35         setupControl("4255054f-0355-af47-ffff403fb0c34b9e", "11d68cf4-0080-7697-ffff403fb0c34b9e",
36                 "0fe650c2-0004-d446-ffff504f9410790f", "Sprinkler 1");
37     }
38
39     @Test
40     public void testControlCreation() {
41         testControlCreation(LxControlRadio.class, 2, 0, 1, 1, 1);
42     }
43
44     @Test
45     public void testChannels() {
46         List<StateOption> opts = new ArrayList<>();
47         for (Integer i = 1; i <= 6; i++) {
48             opts.add(new StateOption(i.toString(), "Sprinkler " + i.toString()));
49         }
50         testChannel("Number", null, BigDecimal.ZERO, new BigDecimal(16), BigDecimal.ONE, null, false, opts);
51     }
52
53     @Test
54     public void testLoxoneCommonStateChanges() {
55         testChannelState(null);
56         for (int i = 1; i <= 6; i++) {
57             changeLoxoneState("activeoutput", i * 1.0);
58             testChannelState(new DecimalType(i));
59         }
60         changeLoxoneState("activeoutput", 0.5);
61         testChannelState(null);
62
63         changeLoxoneState("activeoutput", 7.0);
64         testChannelState(null);
65         changeLoxoneState("activeoutput", 17.0);
66         testChannelState(null);
67     }
68
69     @Test
70     public void testLoxoneZeroIndexChanges() {
71         changeLoxoneState("activeoutput", 0.0);
72         testChannelState(null);
73     }
74
75     @Test
76     public void testCommonCommands() {
77         for (Integer i = 1; i <= 6; i++) {
78             executeCommand(new DecimalType(i));
79             testAction(i.toString());
80         }
81         executeCommand(new DecimalType(7));
82         testAction(null);
83         executeCommand(new DecimalType(17));
84         testAction(null);
85
86         executeCommand(PercentType.HUNDRED);
87         testAction(null);
88     }
89
90     @Test
91     public void testZeroIndexCommands() {
92         executeCommand(DecimalType.ZERO);
93         testAction(null);
94         executeCommand(OnOffType.OFF);
95         testAction(null);
96     }
97 }