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.motiondetector;
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.AbstractBatteryPoweredDeviceHandlerTest;
20 import org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants;
21 import org.openhab.core.library.types.DateTimeType;
22 import org.openhab.core.thing.ChannelUID;
23 import org.openhab.core.thing.ThingTypeUID;
25 import com.google.gson.JsonElement;
26 import com.google.gson.JsonParser;
29 * Unit Tests for {@link MotionDetectorHandler}.
31 * @author David Pace - Initial contribution
35 public class MotionDetectorHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<MotionDetectorHandler> {
38 protected MotionDetectorHandler createFixture() {
39 return new MotionDetectorHandler(getThing());
43 protected String getDeviceID() {
44 return "hdm:ZigBee:000d6f0012fd2571";
48 protected ThingTypeUID getThingTypeUID() {
49 return BoschSHCBindingConstants.THING_TYPE_MOTION_DETECTOR;
53 public void testUpdateChannelsLatestMotionService() {
54 JsonElement jsonObject = JsonParser.parseString("{\n" + " \"@type\": \"latestMotionState\",\n"
55 + " \"latestMotionDetected\": \"2020-04-03T19:02:19.054Z\"\n" + " }");
56 getFixture().processUpdate("LatestMotion", jsonObject);
57 verify(getCallback()).stateUpdated(
58 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LATEST_MOTION),
59 new DateTimeType("2020-04-03T19:02:19.054Z"));