]> git.basschouten.com Git - openhab-addons.git/blob
4e4d739ae64ead4620e321c70521933a1b22339a
[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.lcn.internal.subhandler;
14
15 import static org.mockito.Mockito.when;
16
17 import java.util.ArrayList;
18 import java.util.Collection;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.extension.ExtendWith;
22 import org.mockito.Mock;
23 import org.mockito.junit.jupiter.MockitoExtension;
24 import org.mockito.junit.jupiter.MockitoSettings;
25 import org.mockito.quality.Strictness;
26 import org.openhab.binding.lcn.internal.LcnModuleHandler;
27 import org.openhab.binding.lcn.internal.connection.ModInfo;
28
29 /**
30  * Test class.
31  *
32  * @author Fabian Wolter - Initial contribution
33  */
34 @ExtendWith(MockitoExtension.class)
35 @MockitoSettings(strictness = Strictness.LENIENT)
36 @NonNullByDefault
37 public class AbstractTestLcnModuleSubHandler {
38
39     protected @Mock @NonNullByDefault({}) LcnModuleHandler handler;
40     protected @Mock @NonNullByDefault({}) ModInfo info;
41     private @NonNullByDefault({}) Collection<AbstractLcnModuleSubHandler> allHandlers;
42
43     public void setUp() {
44         when(handler.isMyAddress("000", "005")).thenReturn(true);
45
46         allHandlers = new ArrayList<>();
47         allHandlers.add(new LcnModuleBinarySensorSubHandler(handler, info));
48         allHandlers.add(new LcnModuleCodeSubHandler(handler, info));
49         allHandlers.add(new LcnModuleHostCommandSubHandler(handler, info));
50         allHandlers.add(new LcnModuleKeyLockTableSubHandler(handler, info));
51         allHandlers.add(new LcnModuleLedSubHandler(handler, info));
52         allHandlers.add(new LcnModuleLogicSubHandler(handler, info));
53         allHandlers.add(new LcnModuleMetaAckSubHandler(handler, info));
54         allHandlers.add(new LcnModuleMetaFirmwareSubHandler(handler, info));
55         allHandlers.add(new LcnModuleOperatingHoursCounterSubHandler(handler, info));
56         allHandlers.add(new LcnModuleOutputSubHandler(handler, info));
57         allHandlers.add(new LcnModuleRelaySubHandler(handler, info));
58         allHandlers.add(new LcnModuleRollershutterOutputSubHandler(handler, info));
59         allHandlers.add(new AbstractLcnModuleRollershutterRelaySubHandler(handler, info) {
60         });
61         allHandlers.add(new LcnModuleRvarLockSubHandler(handler, info));
62         allHandlers.add(new LcnModuleRvarModeSubHandler(handler, info));
63         allHandlers.add(new LcnModuleRvarSetpointSubHandler(handler, info));
64         allHandlers.add(new LcnModuleS0CounterSubHandler(handler, info));
65         allHandlers.add(new LcnModuleThresholdSubHandler(handler, info));
66         allHandlers.add(new LcnModuleVariableSubHandler(handler, info));
67     }
68
69     protected void tryParseAllHandlers(String pck) {
70         allHandlers.forEach(h -> h.tryParse(pck));
71     }
72 }