2 * Copyright (c) 2010-2023 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.mockito.Mockito.when;
17 import java.util.ArrayList;
18 import java.util.Collection;
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;
32 * @author Fabian Wolter - Initial contribution
34 @ExtendWith(MockitoExtension.class)
35 @MockitoSettings(strictness = Strictness.LENIENT)
37 public class AbstractTestLcnModuleSubHandler {
39 protected @Mock @NonNullByDefault({}) LcnModuleHandler handler;
40 protected @Mock @NonNullByDefault({}) ModInfo info;
41 private @NonNullByDefault({}) Collection<AbstractLcnModuleSubHandler> allHandlers;
44 when(handler.isMyAddress("000", "005")).thenReturn(true);
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) {
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));
69 protected void tryParseAllHandlers(String pck) {
70 allHandlers.forEach(h -> h.tryParse(pck));