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.windowcontact;
15 import static org.mockito.Mockito.verify;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants;
20 import org.openhab.core.library.types.DecimalType;
21 import org.openhab.core.library.types.OnOffType;
22 import org.openhab.core.thing.ChannelUID;
23 import org.openhab.core.thing.ThingTypeUID;
24 import org.openhab.core.types.UnDefType;
26 import com.google.gson.JsonElement;
27 import com.google.gson.JsonParser;
30 * Unit tests for {@link WindowContact2Handler}.
32 * @author David Pace - Initial contribution
36 class WindowContact2HandlerTest extends WindowContactHandlerTest {
39 protected WindowContactHandler createFixture() {
40 return new WindowContact2Handler(getThing());
44 protected ThingTypeUID getThingTypeUID() {
45 return BoschSHCBindingConstants.THING_TYPE_WINDOW_CONTACT_2;
49 void testUpdateChannelsBypassService() {
52 "@type": "bypassState",
53 "state": "BYPASS_INACTIVE",
62 JsonElement jsonObject = JsonParser.parseString(json);
63 getFixture().processUpdate("Bypass", jsonObject);
64 verify(getCallback()).stateUpdated(
65 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_BYPASS_STATE), OnOffType.OFF);
69 "@type": "bypassState",
70 "state": "BYPASS_ACTIVE",
79 jsonObject = JsonParser.parseString(json);
80 getFixture().processUpdate("Bypass", jsonObject);
81 verify(getCallback()).stateUpdated(
82 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_BYPASS_STATE), OnOffType.ON);
86 "@type": "bypassState",
96 jsonObject = JsonParser.parseString(json);
97 getFixture().processUpdate("Bypass", jsonObject);
98 verify(getCallback()).stateUpdated(
99 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_BYPASS_STATE), UnDefType.UNDEF);
103 void testUpdateChannelsCommunicationQualityService() {
106 "@type": "communicationQualityState",
110 JsonElement jsonObject = JsonParser.parseString(json);
112 getFixture().processUpdate("CommunicationQuality", jsonObject);
113 verify(getCallback()).stateUpdated(
114 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_SIGNAL_STRENGTH),
119 "@type": "communicationQualityState",
123 jsonObject = JsonParser.parseString(json);
125 getFixture().processUpdate("CommunicationQuality", jsonObject);
126 verify(getCallback()).stateUpdated(
127 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_SIGNAL_STRENGTH),