]> git.basschouten.com Git - openhab-addons.git/blob
7a0330d5b482e8f9a4bc8eeac67a68d83e26d0de
[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.onewire;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.onewire.internal.SensorId;
20 import org.openhab.binding.onewire.internal.owserver.OwserverDeviceParameter;
21
22 /**
23  * Tests cases for {@link SensorId}.
24  *
25  * @author Jan N. Klug - Initial contribution
26  */
27 @NonNullByDefault
28 public class OwserverDeviceParameterTest {
29     private final SensorId sensorId = new SensorId("/1F.0123456789ab/main/00.1234567890ab");
30
31     @Test
32     public void withoutPrefixTest() {
33         OwserverDeviceParameter owserverDeviceParameter = new OwserverDeviceParameter("/humidity");
34         assertEquals("/1F.0123456789ab/main/00.1234567890ab/humidity", owserverDeviceParameter.getPath(sensorId));
35
36         owserverDeviceParameter = new OwserverDeviceParameter("humidity");
37         assertEquals("/1F.0123456789ab/main/00.1234567890ab/humidity", owserverDeviceParameter.getPath(sensorId));
38     }
39
40     @Test
41     public void withPrefixTest() {
42         OwserverDeviceParameter owserverDeviceParameter = new OwserverDeviceParameter("uncached", "/humidity");
43         assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
44                 owserverDeviceParameter.getPath(sensorId));
45
46         owserverDeviceParameter = new OwserverDeviceParameter("uncached", "/humidity");
47         assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
48                 owserverDeviceParameter.getPath(sensorId));
49
50         owserverDeviceParameter = new OwserverDeviceParameter("/uncached", "/humidity");
51         assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
52                 owserverDeviceParameter.getPath(sensorId));
53
54         owserverDeviceParameter = new OwserverDeviceParameter("/uncached/", "/humidity");
55         assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
56                 owserverDeviceParameter.getPath(sensorId));
57
58         owserverDeviceParameter = new OwserverDeviceParameter("uncached/", "/humidity");
59         assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
60                 owserverDeviceParameter.getPath(sensorId));
61     }
62 }