]> git.basschouten.com Git - openhab-addons.git/blob
83208b8038dba4f8604bbf9396bcf398675228cc
[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     public void withPrefixTest() {
41         OwserverDeviceParameter owserverDeviceParameter = new OwserverDeviceParameter("uncached", "/humidity");
42         assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
43                 owserverDeviceParameter.getPath(sensorId));
44
45         owserverDeviceParameter = new OwserverDeviceParameter("uncached", "/humidity");
46         assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
47                 owserverDeviceParameter.getPath(sensorId));
48
49         owserverDeviceParameter = new OwserverDeviceParameter("/uncached", "/humidity");
50         assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
51                 owserverDeviceParameter.getPath(sensorId));
52
53         owserverDeviceParameter = new OwserverDeviceParameter("/uncached/", "/humidity");
54         assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
55                 owserverDeviceParameter.getPath(sensorId));
56
57         owserverDeviceParameter = new OwserverDeviceParameter("uncached/", "/humidity");
58         assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
59                 owserverDeviceParameter.getPath(sensorId));
60     }
61 }