]> git.basschouten.com Git - openhab-addons.git/blob
a18edccc47b347c28d6882beb3ad96f70f9f6f20
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.avmfritz.actions;
14
15 import static org.junit.jupiter.api.Assertions.assertThrows;
16
17 import org.junit.jupiter.api.BeforeEach;
18 import org.junit.jupiter.api.Test;
19 import org.junit.jupiter.api.extension.ExtendWith;
20 import org.mockito.Mock;
21 import org.mockito.junit.jupiter.MockitoExtension;
22 import org.openhab.binding.avmfritz.internal.handler.AVMFritzHeatingActionsHandler;
23 import org.openhab.core.thing.binding.ThingActions;
24 import org.openhab.core.thing.binding.ThingHandler;
25
26 /**
27  * Unit tests for {@link AVMFritzHeatingActions}.
28  *
29  * @author Christoph Weitkamp - Initial contribution
30  */
31 @ExtendWith(MockitoExtension.class)
32 public class AVMFritzHeatingActionsTest {
33
34     private final ThingActions thingActionsStub = new ThingActions() {
35         @Override
36         public void setThingHandler(ThingHandler handler) {
37         }
38
39         @Override
40         public ThingHandler getThingHandler() {
41             return null;
42         }
43     };
44
45     private @Mock AVMFritzHeatingActionsHandler heatingActionsHandler;
46
47     private AVMFritzHeatingActions heatingActions;
48
49     @BeforeEach
50     public void setUp() {
51         heatingActions = new AVMFritzHeatingActions();
52     }
53
54     @Test
55     public void testSetBoostModeThingActionsIsNull() {
56         assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(null, Long.valueOf(5L)));
57     }
58
59     @Test
60     public void testSetBoostModeThingActionsIsNotPushoverThingActions() {
61         assertThrows(IllegalArgumentException.class,
62                 () -> AVMFritzHeatingActions.setBoostMode(thingActionsStub, Long.valueOf(5L)));
63     }
64
65     @Test
66     public void testSetBoostModeThingHandlerIsNull() {
67         assertThrows(IllegalArgumentException.class,
68                 () -> AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L)));
69     }
70
71     @Test
72     public void testSetBoostModeDurationNull() {
73         heatingActions.setThingHandler(heatingActionsHandler);
74         assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(heatingActions, null));
75     }
76
77     @Test
78     public void testSetBoostMode() {
79         heatingActions.setThingHandler(heatingActionsHandler);
80         AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L));
81     }
82
83     @Test
84     public void testSetWindowOpenModeThingActionsIsNull() {
85         assertThrows(IllegalArgumentException.class,
86                 () -> AVMFritzHeatingActions.setWindowOpenMode(null, Long.valueOf(5L)));
87     }
88
89     @Test
90     public void testSetWindowOpenModeThingActionsIsNotPushoverThingActions() {
91         assertThrows(IllegalArgumentException.class,
92                 () -> AVMFritzHeatingActions.setWindowOpenMode(thingActionsStub, Long.valueOf(5L)));
93     }
94
95     @Test
96     public void testSetWindowOpenModeThingHandlerIsNull() {
97         assertThrows(IllegalArgumentException.class,
98                 () -> AVMFritzHeatingActions.setWindowOpenMode(heatingActions, Long.valueOf(5L)));
99     }
100
101     @Test
102     public void testSetWindowOpenModeDurationNull() {
103         heatingActions.setThingHandler(heatingActionsHandler);
104         assertThrows(IllegalArgumentException.class,
105                 () -> AVMFritzHeatingActions.setWindowOpenMode(heatingActions, null));
106     }
107
108     @Test
109     public void testSetWindowOpenMode() {
110         heatingActions.setThingHandler(heatingActionsHandler);
111         AVMFritzHeatingActions.setWindowOpenMode(heatingActions, Long.valueOf(5L));
112     }
113 }