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.boschshc.internal.devices.twinguard;
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.AbstractSmokeDetectorHandlerTest;
23 import org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants;
24 import org.openhab.core.library.types.QuantityType;
25 import org.openhab.core.library.types.StringType;
26 import org.openhab.core.library.unit.SIUnits;
27 import org.openhab.core.library.unit.Units;
28 import org.openhab.core.thing.ChannelUID;
29 import org.openhab.core.thing.ThingTypeUID;
31 import com.google.gson.JsonElement;
32 import com.google.gson.JsonParser;
35 * Unit Tests for {@link TwinguardHandler}.
37 * @author David Pace - Initial contribution
41 public class TwinguardHandlerTest extends AbstractSmokeDetectorHandlerTest<TwinguardHandler> {
44 protected TwinguardHandler createFixture() {
45 return new TwinguardHandler(getThing());
49 protected String getDeviceID() {
50 return "hdm:ZigBee:000d6f0016d1a193";
54 protected ThingTypeUID getThingTypeUID() {
55 return BoschSHCBindingConstants.THING_TYPE_TWINGUARD;
59 public void testUpdateChannelsAirQualityLevelService() {
60 JsonElement jsonObject = JsonParser.parseString(
61 "{\"temperatureRating\":\"GOOD\",\"humidityRating\":\"MEDIUM\",\"purity\":620,\"@type\":\"airQualityLevelState\",\n"
62 + " \"purityRating\":\"GOOD\",\"temperature\":23.77,\"description\":\"LITTLE_DRY\",\"humidity\":32.69,\"combinedRating\":\"MEDIUM\"}");
63 getFixture().processUpdate("AirQualityLevel", jsonObject);
65 verify(getCallback()).stateUpdated(
66 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_TEMPERATURE),
67 new QuantityType<Temperature>(23.77, SIUnits.CELSIUS));
69 verify(getCallback()).stateUpdated(
70 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_TEMPERATURE_RATING),
71 new StringType("GOOD"));
73 verify(getCallback()).stateUpdated(
74 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_HUMIDITY),
75 new QuantityType<Dimensionless>(32.69, Units.PERCENT));
77 verify(getCallback()).stateUpdated(
78 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_HUMIDITY_RATING),
79 new StringType("MEDIUM"));
81 verify(getCallback()).stateUpdated(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_PURITY),
82 new QuantityType<Dimensionless>(620, Units.PARTS_PER_MILLION));
84 verify(getCallback()).stateUpdated(
85 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_PURITY_RATING),
86 new StringType("GOOD"));
88 verify(getCallback()).stateUpdated(
89 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_AIR_DESCRIPTION),
90 new StringType("LITTLE_DRY"));
92 verify(getCallback()).stateUpdated(
93 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_COMBINED_RATING),
94 new StringType("MEDIUM"));