]> git.basschouten.com Git - openhab-addons.git/blob
e96a07d34ce70acd03acf81aa10f53873cf924e0
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.netatmo.internal.handler.channelhelper;
14
15 import static org.junit.jupiter.api.Assertions.*;
16 import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
17
18 import java.util.Collections;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.netatmo.internal.api.data.EventType;
24 import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
25 import org.openhab.core.library.types.StringType;
26 import org.openhab.core.types.State;
27
28 /**
29  * @author Sven Strohschein - Initial contribution
30  */
31 @NonNullByDefault
32 public class EventCameraChannelHelperTest {
33
34     private @NonNullByDefault({}) EventCameraChannelHelper helper;
35
36     @BeforeEach
37     public void before() {
38         helper = new EventCameraChannelHelper(Collections.emptySet());
39     }
40
41     @Test
42     public void testInternalGetHomeEventGroupSubEvent() {
43         State state = helper.internalGetHomeEvent(CHANNEL_EVENT_TYPE, GROUP_SUB_EVENT, new HomeEvent());
44         assertTrue(state instanceof StringType);
45         assertEquals(EventType.UNKNOWN.name(), state.toString());
46     }
47
48     @Test
49     public void testInternalGetHomeEventGroupDoorbellSubEvent() {
50         State state = helper.internalGetHomeEvent(CHANNEL_EVENT_TYPE, GROUP_DOORBELL_SUB_EVENT, new HomeEvent());
51         assertTrue(state instanceof StringType);
52         assertEquals(EventType.UNKNOWN.name(), state.toString());
53     }
54
55     @Test
56     public void testInternalGetHomeEventGroupDoorbellStatus() {
57         State state = helper.internalGetHomeEvent(CHANNEL_EVENT_TYPE, GROUP_DOORBELL_STATUS, new HomeEvent());
58         // Only sub-event groups are handled by EventCameraChannelHelper. GROUP_DOORBELL_STATUS isn't a sub-event group.
59         assertNull(state);
60     }
61 }