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