]> git.basschouten.com Git - openhab-addons.git/blob
72bfe7f54eefccc0bb37f1382fecf5e4f310e55c
[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
14 package org.openhab.binding.nobohub.internal.model;
15
16 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import static org.junit.jupiter.api.Assertions.assertFalse;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21
22 /**
23  * Unit tests for Component model object.
24  *
25  * @author Jørgen Austvik - Initial contribution
26  */
27 @NonNullByDefault
28 public class ComponentTest {
29     @Test
30     public void testParseH02() throws NoboDataException {
31         Component comp = Component.fromH02("H02 186170024143 0 Kontor 0 1 -1 -1");
32         comp.setTemperature(12.3);
33         assertEquals(new SerialNumber("186170024143"), comp.getSerialNumber());
34         assertEquals("Kontor", comp.getName());
35         assertEquals(1, comp.getZoneId());
36         assertEquals(-1, comp.getTemperatureSensorForZoneId());
37         assertFalse(comp.inReverse());
38         assertEquals(12.3, comp.getTemperature(), 0.1);
39     }
40
41     @Test
42     public void testGenerateU03() throws NoboDataException {
43         Component comp = Component.fromH02("H02 186170024143 0 Kontor 0 1 -1 -1");
44         assertEquals("U02 186170024143 0 Kontor 0 1 -1 -1", comp.generateCommandString("U02"));
45     }
46 }