]> git.basschouten.com Git - openhab-addons.git/blob
47b0c68f0c7a01c37105e43b39eb174820b53af6
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.bluetooth.radoneye;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import java.util.Map;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.bluetooth.radoneye.internal.RadoneyeDataParser;
22 import org.openhab.binding.bluetooth.radoneye.internal.RadoneyeParserException;
23
24 /**
25  * Tests {@link RadoneyeParserTest}.
26  *
27  * @author Peter Obel - Initial contribution
28  */
29 @NonNullByDefault
30 public class RadoneyeParserTest {
31
32     @Test
33     public void testEmptyData() {
34         int[] data = {};
35         assertThrows(RadoneyeParserException.class, () -> RadoneyeDataParser.parseRd200Data(data));
36     }
37
38     @Test
39     public void testWrongDataLen() throws RadoneyeParserException {
40         int[] data = { 1, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0 };
41         assertThrows(RadoneyeParserException.class, () -> RadoneyeDataParser.parseRd200Data(data));
42     }
43
44     @Test
45     public void testParsingRd200() throws RadoneyeParserException {
46         int[] data = { 80, 16, 31, -123, 43, 64, 123, 20, 94, 64, 92, -113, -118, 64, 15, 0, 12, 0, 0, 0 };
47         Map<String, Number> result = RadoneyeDataParser.parseRd200Data(data);
48
49         assertEquals(99, result.get(RadoneyeDataParser.RADON).intValue());
50     }
51 }