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 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 void testUpdateChannelsAirQualityLevelService() {
60 JsonElement jsonObject = JsonParser.parseString(
62 {"temperatureRating":"GOOD","humidityRating":"MEDIUM","purity":620,"@type":"airQualityLevelState",
63 "purityRating":"GOOD","temperature":23.77,"description":"LITTLE_DRY","humidity":32.69,"combinedRating":"MEDIUM"}\
65 getFixture().processUpdate("AirQualityLevel", jsonObject);
67 verify(getCallback()).stateUpdated(
68 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_TEMPERATURE),
69 new QuantityType<Temperature>(23.77, SIUnits.CELSIUS));
71 verify(getCallback()).stateUpdated(
72 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_TEMPERATURE_RATING),
73 new StringType("GOOD"));
75 verify(getCallback()).stateUpdated(
76 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_HUMIDITY),
77 new QuantityType<Dimensionless>(32.69, Units.PERCENT));
79 verify(getCallback()).stateUpdated(
80 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_HUMIDITY_RATING),
81 new StringType("MEDIUM"));
83 verify(getCallback()).stateUpdated(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_PURITY),
84 new QuantityType<Dimensionless>(620, Units.PARTS_PER_MILLION));
86 verify(getCallback()).stateUpdated(
87 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_PURITY_RATING),
88 new StringType("GOOD"));
90 verify(getCallback()).stateUpdated(
91 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_AIR_DESCRIPTION),
92 new StringType("LITTLE_DRY"));
94 verify(getCallback()).stateUpdated(
95 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_COMBINED_RATING),
96 new StringType("MEDIUM"));