]> git.basschouten.com Git - openhab-addons.git/blob
ddb55a8142b9f9b62d52b0bd2edba08aae942659
[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.DecimalType;
18 import org.openhab.core.types.UnDefType;
19
20 /**
21  * Test class for (@link LxControlInfoOnlyAnalog}
22  *
23  * @author Pawel Pieczul - initial contribution
24  *
25  */
26 public class LxControlInfoOnlyAnalogTest extends LxControlTest {
27     @BeforeEach
28     public void setup() {
29         setupControl("0fec5dc3-003e-8800-ffff403fb0c34b9e", "0fe3a451-0283-2afa-ffff403fb0c34b9e",
30                 "0fe665f4-0161-4773-ffff403fb0c34b9e", "Info Only Analog");
31     }
32
33     @Test
34     public void testControlCreation() {
35         testControlCreation(LxControlInfoOnlyAnalog.class, 2, 0, 1, 1, 1);
36     }
37
38     @Test
39     public void testChannels() {
40         testChannel("Number", null, null, null, null, "%.2f", true, null);
41     }
42
43     @Test
44     public void testLoxoneStateChanges() {
45         for (Double i = -1000.0; i < 1000.0; i += 33.7324323) {
46             changeLoxoneState("value", i);
47             testChannelState(new DecimalType(i));
48         }
49         changeLoxoneState("value", 0.0);
50         testChannelState(DecimalType.ZERO);
51         changeLoxoneState("value", Double.NaN);
52         testChannelState(UnDefType.UNDEF);
53         changeLoxoneState("value", Double.MAX_VALUE);
54         testChannelState(new DecimalType(Double.MAX_VALUE));
55         changeLoxoneState("value", Double.POSITIVE_INFINITY);
56         testChannelState(UnDefType.UNDEF);
57         changeLoxoneState("value", Double.MIN_VALUE);
58         testChannelState(new DecimalType(Double.MIN_VALUE));
59         changeLoxoneState("value", Double.NEGATIVE_INFINITY);
60         testChannelState(UnDefType.UNDEF);
61     }
62 }