2 * Copyright (c) 2010-2020 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.avmfritz.actions;
15 import static org.junit.jupiter.api.Assertions.assertThrows;
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;
27 * Unit tests for {@link AVMFritzHeatingActions}.
29 * @author Christoph Weitkamp - Initial contribution
31 @ExtendWith(MockitoExtension.class)
32 public class AVMFritzHeatingActionsTest {
34 private final ThingActions thingActionsStub = new ThingActions() {
36 public void setThingHandler(ThingHandler handler) {
40 public ThingHandler getThingHandler() {
45 private @Mock AVMFritzHeatingActionsHandler heatingActionsHandler;
47 private AVMFritzHeatingActions heatingActions;
51 heatingActions = new AVMFritzHeatingActions();
55 public void testSetBoostModeThingActionsIsNull() {
56 assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(null, Long.valueOf(5L)));
60 public void testSetBoostModeThingActionsIsNotPushoverThingActions() {
61 assertThrows(IllegalArgumentException.class,
62 () -> AVMFritzHeatingActions.setBoostMode(thingActionsStub, Long.valueOf(5L)));
66 public void testSetBoostModeThingHandlerIsNull() {
67 assertThrows(IllegalArgumentException.class,
68 () -> AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L)));
72 public void testSetBoostModeDurationNull() {
73 heatingActions.setThingHandler(heatingActionsHandler);
74 assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(heatingActions, null));
78 public void testSetBoostMode() {
79 heatingActions.setThingHandler(heatingActionsHandler);
80 AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L));
84 public void testSetWindowOpenModeThingActionsIsNull() {
85 assertThrows(IllegalArgumentException.class,
86 () -> AVMFritzHeatingActions.setWindowOpenMode(null, Long.valueOf(5L)));
90 public void testSetWindowOpenModeThingActionsIsNotPushoverThingActions() {
91 assertThrows(IllegalArgumentException.class,
92 () -> AVMFritzHeatingActions.setWindowOpenMode(thingActionsStub, Long.valueOf(5L)));
96 public void testSetWindowOpenModeThingHandlerIsNull() {
97 assertThrows(IllegalArgumentException.class,
98 () -> AVMFritzHeatingActions.setWindowOpenMode(heatingActions, Long.valueOf(5L)));
102 public void testSetWindowOpenModeDurationNull() {
103 heatingActions.setThingHandler(heatingActionsHandler);
104 assertThrows(IllegalArgumentException.class,
105 () -> AVMFritzHeatingActions.setWindowOpenMode(heatingActions, null));
109 public void testSetWindowOpenMode() {
110 heatingActions.setThingHandler(heatingActionsHandler);
111 AVMFritzHeatingActions.setWindowOpenMode(heatingActions, Long.valueOf(5L));