2 * Copyright (c) 2010-2024 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.boschshc.internal.devices.wallthermostat;
15 import static org.mockito.Mockito.verify;
17 import javax.measure.quantity.Dimensionless;
18 import javax.measure.quantity.Temperature;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
22 import org.openhab.binding.boschshc.internal.devices.AbstractBatteryPoweredDeviceHandlerTest;
23 import org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants;
24 import org.openhab.core.library.types.QuantityType;
25 import org.openhab.core.library.unit.SIUnits;
26 import org.openhab.core.library.unit.Units;
27 import org.openhab.core.thing.ChannelUID;
28 import org.openhab.core.thing.ThingTypeUID;
30 import com.google.gson.JsonElement;
31 import com.google.gson.JsonParser;
34 * Unit Tests for {@link WallThermostatHandler}.
36 * @author David Pace - Initial contribution
40 class WallThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<WallThermostatHandler> {
43 protected WallThermostatHandler createFixture() {
44 return new WallThermostatHandler(getThing());
48 protected String getDeviceID() {
49 return "hdm:ZigBee:000d6f0016d1a193";
53 protected ThingTypeUID getThingTypeUID() {
54 return BoschSHCBindingConstants.THING_TYPE_WALL_THERMOSTAT;
58 void testUpdateChannelsTemperatureLevelService() {
59 JsonElement jsonObject = JsonParser.parseString("""
61 "@type": "temperatureLevelState",
65 getFixture().processUpdate("TemperatureLevel", jsonObject);
66 verify(getCallback()).stateUpdated(
67 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_TEMPERATURE),
68 new QuantityType<Temperature>(21.5, SIUnits.CELSIUS));
72 void testUpdateChannelsHumidityLevelService() {
73 JsonElement jsonObject = JsonParser
74 .parseString("{\n" + " \"@type\": \"humidityLevelState\",\n" + " \"humidity\": 42.5\n" + " }");
75 getFixture().processUpdate("HumidityLevel", jsonObject);
76 verify(getCallback()).stateUpdated(
77 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_HUMIDITY),
78 new QuantityType<Dimensionless>(42.5, Units.PERCENT));