2 * Copyright (c) 2010-2024 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.solax.internal.local;
15 import static org.junit.jupiter.api.Assertions.*;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.solax.internal.connectivity.rawdata.local.LocalConnectRawDataBean;
22 import org.openhab.binding.solax.internal.model.InverterType;
23 import org.openhab.binding.solax.internal.model.local.LocalInverterData;
24 import org.openhab.binding.solax.internal.model.local.parsers.RawDataParser;
27 * The {@link AbstractParserTest} Abstract class defining the common logic for testing local connections to the various
28 * inverters and their parsers
30 * @author Konstantin Polihronov - Initial contribution
33 public abstract class AbstractParserTest {
35 public void testParser() {
36 LocalConnectRawDataBean bean = LocalConnectRawDataBean.fromJson(getRawData());
37 int type = bean.getType();
38 InverterType inverterType = InverterType.fromIndex(type);
39 assertEquals(getInverterType(), inverterType, "Inverter type not recognized properly");
41 RawDataParser parser = inverterType.getParser();
42 assertNotNull(parser);
44 Set<String> supportedChannels = parser.getSupportedChannels();
45 assertFalse(supportedChannels.isEmpty());
47 LocalInverterData data = parser.getData(bean);
48 assertParserSpecific(data);
51 protected abstract InverterType getInverterType();
53 protected abstract String getRawData();
55 protected abstract void assertParserSpecific(LocalInverterData data);