2 * Copyright (c) 2010-2023 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.onewire;
15 import static org.junit.jupiter.api.Assertions.*;
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;
23 * Tests cases for {@link SensorId}.
25 * @author Jan N. Klug - Initial contribution
28 public class OwserverDeviceParameterTest {
29 private final SensorId sensorId = new SensorId("/1F.0123456789ab/main/00.1234567890ab");
32 public void withoutPrefixTest() {
33 OwserverDeviceParameter owserverDeviceParameter = new OwserverDeviceParameter("/humidity");
34 assertEquals("/1F.0123456789ab/main/00.1234567890ab/humidity", owserverDeviceParameter.getPath(sensorId));
36 owserverDeviceParameter = new OwserverDeviceParameter("humidity");
37 assertEquals("/1F.0123456789ab/main/00.1234567890ab/humidity", owserverDeviceParameter.getPath(sensorId));
40 public void withPrefixTest() {
41 OwserverDeviceParameter owserverDeviceParameter = new OwserverDeviceParameter("uncached", "/humidity");
42 assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
43 owserverDeviceParameter.getPath(sensorId));
45 owserverDeviceParameter = new OwserverDeviceParameter("uncached", "/humidity");
46 assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
47 owserverDeviceParameter.getPath(sensorId));
49 owserverDeviceParameter = new OwserverDeviceParameter("/uncached", "/humidity");
50 assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
51 owserverDeviceParameter.getPath(sensorId));
53 owserverDeviceParameter = new OwserverDeviceParameter("/uncached/", "/humidity");
54 assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
55 owserverDeviceParameter.getPath(sensorId));
57 owserverDeviceParameter = new OwserverDeviceParameter("uncached/", "/humidity");
58 assertEquals("/uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
59 owserverDeviceParameter.getPath(sensorId));