2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.loxone.internal.controls;
15 import java.math.BigDecimal;
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.types.UnDefType;
23 * Test class for (@link LxControlUpDownAnalog}
25 * @author Pawel Pieczul - initial contribution
28 public class LxControlUpDownAnalogTest extends LxControlTest {
40 setupControl("131b1a96-02b9-f6e9-eeff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
41 "0fe650c2-0004-d446-ffff504f9410790f", "Up Down Analog Input");
45 public void testControlCreation() {
46 testControlCreation(LxControlUpDownAnalog.class, 1, 0, 1, 1, 2);
50 public void testChannels() {
51 testChannel("Number", null, new BigDecimal(min), new BigDecimal(max), new BigDecimal(step), format, false,
56 public void testLoxoneStateChanges() {
57 testChannelState(null);
58 for (int j = 0; j < 2; j++) {
59 changeLoxoneState("error", 0.0);
60 for (Double i = min - 50.0; i < min; i += 0.5) {
61 changeLoxoneState("value", i);
62 testChannelState(null);
64 for (Double i = min; i <= max; i += 0.5) {
65 changeLoxoneState("value", i);
66 testChannelState(new DecimalType(i));
68 for (Double i = max + 0.5; i < max + 50.0; i += 0.5) {
69 changeLoxoneState("value", i);
70 testChannelState(null);
72 changeLoxoneState("error", 1.0);
73 for (Double i = min - 50.0; i < max + 50.0; i += 0.5) {
74 changeLoxoneState("value", i);
75 testChannelState(UnDefType.UNDEF);
81 public void testCommands() {
82 for (Double i = min - 50.0; i < min; i += 0.5) {
83 executeCommand(new DecimalType(i));
86 for (Double i = min; i <= max; i += 0.5) {
87 executeCommand(new DecimalType(i));
88 testAction(i.toString());
90 for (Double i = max + 0.5; i < max + 50.0; i += 0.5) {
91 executeCommand(new DecimalType(i));