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.util.Collections;
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;
25 * Test class for (@link LxControlSwitch}
27 * @author Pawel Pieczul - initial contribution
30 public class LxControlSwitchTest extends LxControlTest {
33 setupControl("0f2f6b5d-0349-83b1-ffff403fb0c34b9e", "0b734138-038c-0382-ffff403fb0c34b9e",
34 "0b734138-033e-02d4-ffff403fb0c34b9e", "Switch Button");
38 public void testControlCreation() {
39 testControlCreation(LxControlSwitch.class, 1, 0, 1, 1, 1);
43 public void testChannels() {
44 testChannel("Switch", Collections.singleton("Lighting"));
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);
60 public void testCommands() {
61 for (int i = 0; i < 100; i++) {
62 executeCommand(OnOffType.ON);
64 executeCommand(DecimalType.ZERO);
66 executeCommand(OnOffType.OFF);
68 executeCommand(StringType.EMPTY);