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.bluetooth.airthings;
15 import static org.junit.Assert.assertEquals;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.Test;
19 import org.openhab.binding.bluetooth.airthings.internal.AirthingsParserException;
20 import org.openhab.binding.bluetooth.airthings.internal.AirthingsWavePlusDataParser;
23 * Tests {@link AirthingsWavePlusParserTest}.
25 * @author Pauli Anttila - Initial contribution
28 public class AirthingsWavePlusParserTest {
30 @Test(expected = AirthingsParserException.class)
31 public void testWrongVersion() throws AirthingsParserException {
32 int[] data = { 5, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0, 0, 4, 20 };
33 new AirthingsWavePlusDataParser(data);
36 @Test(expected = AirthingsParserException.class)
37 public void testEmptyData() throws AirthingsParserException {
39 new AirthingsWavePlusDataParser(data);
42 @Test(expected = AirthingsParserException.class)
43 public void testWrongDataLen() throws AirthingsParserException {
44 int[] data = { 1, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0 };
45 new AirthingsWavePlusDataParser(data);
49 public void testParsing() throws AirthingsParserException {
50 int[] data = { 1, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0, 0, 4, 20 };
51 AirthingsWavePlusDataParser parser = new AirthingsWavePlusDataParser(data);
53 assertEquals(27.5, parser.getHumidity(), 0.01);
54 assertEquals(681, parser.getCo2());
55 assertEquals(46, parser.getTvoc());
56 assertEquals(24.23, parser.getTemperature(), 0.01);
57 assertEquals(993.5, parser.getPressure(), 0.01);
58 assertEquals(61, parser.getRadonLongTermAvg());
59 assertEquals(122, parser.getRadonShortTermAvg());