2 * Copyright (c) 2010-2020 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.tplinksmarthome.internal.device;
15 import static org.junit.Assert.*;
16 import static org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants.*;
18 import java.io.IOException;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.Test;
22 import org.openhab.core.library.types.OnOffType;
23 import org.openhab.core.types.UnDefType;
26 * Test class for {@link SwitchDevice} class.
28 * @author Hilbrand Bouwkamp - Initial contribution
31 public class SwitchDeviceTest extends DeviceTestBase<SwitchDevice> {
33 public SwitchDeviceTest() throws IOException {
34 super(new SwitchDevice(), "plug_get_sysinfo_response");
38 public void testHandleCommandSwitch() throws IOException {
39 assertInput("plug_set_relay_state_on");
40 setSocketReturnAssert("plug_set_relay_state_on");
41 assertTrue("Switch channel should be handled", device.handleCommand(CHANNEL_UID_SWITCH, OnOffType.ON));
45 public void testHandleCommandLed() throws IOException {
46 assertInput("plug_set_led_on");
47 setSocketReturnAssert("plug_set_led_on");
48 assertTrue("Led channel should be handled", device.handleCommand(CHANNEL_UID_LED, OnOffType.ON));
52 public void testUpdateChannelSwitch() {
53 assertSame("Switch should be on", OnOffType.ON, device.updateChannel(CHANNEL_UID_SWITCH, deviceState));
57 public void testUpdateChannelLed() {
58 assertSame("Led should be on", OnOffType.ON, device.updateChannel(CHANNEL_UID_LED, deviceState));
62 public void testUpdateChannelOther() {
63 assertSame("Unknown channel should return UNDEF", UnDefType.UNDEF,
64 device.updateChannel(CHANNEL_UID_OTHER, deviceState));