2 * Copyright (c) 2010-2020 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.meter;
15 import static org.junit.Assert.assertEquals;
17 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.Test;
21 import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
22 import org.openhab.binding.dsmr.internal.device.cosem.CosemObject;
23 import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState;
26 * Test class for {@link DSMRMeter}.
28 * @author Hilbrand Bouwkamp - Initial contribution
31 public class DSMRMeterTest {
34 * Test if method {@link DSMRMeter#filterMeterValues(List)} correctly filters values.
37 public void testFilterMeterValues() {
38 DSMRMeterDescriptor descriptor = new DSMRMeterDescriptor(DSMRMeterType.DEVICE_V5, 0);
39 DSMRMeter meter = new DSMRMeter(descriptor);
41 List<CosemObject> filterMeterValues = meter
42 .filterMeterValues(TelegramReaderUtil.readTelegram("dsmr_50", TelegramState.OK).getCosemObjects());
43 assertEquals("Filter should return all required objects", DSMRMeterType.DEVICE_V5.requiredCosemObjects.length,
44 filterMeterValues.size());