]> git.basschouten.com Git - openhab-addons.git/blob
0952dab62704e45c80271ee673cf3e77ce0ecc9e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.dsmr.internal.meter;
14
15 import static org.junit.Assert.assertEquals;
16
17 import java.util.List;
18
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;
24
25 /**
26  * Test class for {@link DSMRMeter}.
27  *
28  * @author Hilbrand Bouwkamp - Initial contribution
29  */
30 @NonNullByDefault
31 public class DSMRMeterTest {
32
33     /**
34      * Test if method {@link DSMRMeter#filterMeterValues(List)} correctly filters values.
35      */
36     @Test
37     public void testFilterMeterValues() {
38         DSMRMeterDescriptor descriptor = new DSMRMeterDescriptor(DSMRMeterType.DEVICE_V5, 0);
39         DSMRMeter meter = new DSMRMeter(descriptor);
40
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());
45     }
46 }