2 * Copyright (c) 2010-2022 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.lcn.internal.subhandler;
15 import static org.junit.jupiter.api.Assertions.assertThrows;
16 import static org.mockito.Mockito.verify;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
22 import org.openhab.binding.lcn.internal.common.LcnException;
23 import org.openhab.binding.lcn.internal.common.PckGenerator;
24 import org.openhab.core.library.types.PercentType;
29 * @author Fabian Wolter - Initial contribution
32 public class LcnModuleRollershutterRelayPositionSubHandlerTest extends AbstractTestLcnModuleSubHandler {
33 private @NonNullByDefault({}) AbstractLcnModuleRollershutterRelaySubHandler l;
40 l = new LcnModuleRollershutterRelayPositionSubHandler(handler, info);
44 public void testMotor1percent0() throws LcnException {
45 l.handleCommandPercent(PercentType.ZERO, LcnChannelGroup.ROLLERSHUTTERRELAY, 0);
46 verify(handler).sendPck("JH000001");
50 public void testMotor1percent100() throws LcnException {
51 l.handleCommandPercent(PercentType.HUNDRED, LcnChannelGroup.ROLLERSHUTTERRELAY, 0);
52 verify(handler).sendPck("JH100001");
56 public void testMotor1percent50() throws LcnException {
57 l.handleCommandPercent(new PercentType(50), LcnChannelGroup.ROLLERSHUTTERRELAY, 0);
58 verify(handler).sendPck("JH050001");
62 public void testMotor4percent50() throws LcnException {
63 l.handleCommandPercent(new PercentType(50), LcnChannelGroup.ROLLERSHUTTERRELAY, 3);
64 verify(handler).sendPck("JH050008");
68 public void testInvalidMotor() throws LcnException {
69 assertThrows(LcnException.class, () -> {
70 l.handleCommandPercent(new PercentType(50), LcnChannelGroup.ROLLERSHUTTERRELAY, 4);
75 public void testInvalidPercent() throws LcnException {
76 assertThrows(LcnException.class, () -> {
77 PckGenerator.controlShutterPosition(0, 101);