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.dsmr.internal.device.p1telegram;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import java.util.Arrays;
18 import java.util.List;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.params.ParameterizedTest;
22 import org.junit.jupiter.params.provider.MethodSource;
23 import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
24 import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState;
27 * Test class for {@link P1TelegramParser}.
29 * @author Hilbrand Bouwkamp - Initial contribution
32 public class P1TelegramParserTest {
35 public static final List<Object[]> data() {
36 return Arrays.asList(new Object[][] {
41 { "dsmr_50_austria", 18, 0},
43 { "flu5_extra", 31, 0},
44 { "flu5_invalid_gasmeter", 19, 1},
45 { "Iskra_AM550", 41, 0},
46 { "Landis_Gyr_E350", 10, 0},
47 { "Landis_Gyr_ZCF110", 25, 0},
48 { "Sagemcom_XS210", 41, 0},
50 { "smarty_with_units", 23, 0},
57 public void testParsing(final String telegramName, final int numberOfCosemObjects, final int unknownObjects) {
58 final P1Telegram telegram = TelegramReaderUtil.readTelegram(telegramName, TelegramState.OK);
59 assertEquals(unknownObjects, telegram.getUnknownCosemObjects().size(),
60 "Should not have other than " + unknownObjects + " unknown cosem objects");
61 assertEquals(numberOfCosemObjects,
62 telegram.getCosemObjects().stream().mapToInt(co -> co.getCosemValues().size()).sum(),
63 "Expected number of objects");