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.mqtt.homeassistant.internal.component;
15 import static org.hamcrest.CoreMatchers.is;
16 import static org.hamcrest.MatcherAssert.assertThat;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
22 import org.openhab.binding.mqtt.generic.values.ImageValue;
23 import org.openhab.core.library.types.RawType;
26 * Tests for {@link Camera}
28 * @author Anton Kharuzhy - Initial contribution
31 public class CameraTests extends AbstractComponentTests {
32 public static final String CONFIG_TOPIC = "camera/0x0000000000000000_camera_zigbee2mqtt";
35 public void test() throws InterruptedException {
37 var component = discoverComponent(configTopicToMqtt(CONFIG_TOPIC),
42 "topic": "zigbee2mqtt/bridge/state" \
47 "zigbee2mqtt_0x0000000000000000" \
49 "manufacturer": "Cameras inc", \
52 "sw_version": "Zigbee2MQTT 1.18.2" \
55 "topic": "zigbee2mqtt/cam1/state"\
60 assertThat(component.channels.size(), is(1));
61 assertThat(component.getName(), is("cam1"));
63 assertChannel(component, Camera.CAMERA_CHANNEL_ID, "zigbee2mqtt/cam1/state", "", "cam1", ImageValue.class);
65 var imageBytes = getResourceAsByteArray("component/image.png");
66 publishMessage("zigbee2mqtt/cam1/state", imageBytes);
67 assertState(component, Camera.CAMERA_CHANNEL_ID, new RawType(imageBytes, "image/png"));
71 protected Set<String> getConfigTopics() {
72 return Set.of(CONFIG_TOPIC);