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));
41 public void withPrefixTest() {
42 OwserverDeviceParameter owserverDeviceParameter = new OwserverDeviceParameter("uncached", "/humidity");
43 assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
44 owserverDeviceParameter.getPath(sensorId));
46 owserverDeviceParameter = new OwserverDeviceParameter("uncached", "/humidity");
47 assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
48 owserverDeviceParameter.getPath(sensorId));
50 owserverDeviceParameter = new OwserverDeviceParameter("/uncached", "/humidity");
51 assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
52 owserverDeviceParameter.getPath(sensorId));
54 owserverDeviceParameter = new OwserverDeviceParameter("/uncached/", "/humidity");
55 assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
56 owserverDeviceParameter.getPath(sensorId));
58 owserverDeviceParameter = new OwserverDeviceParameter("uncached/", "/humidity");
59 assertEquals("uncached/1F.0123456789ab/main/00.1234567890ab/humidity",
60 owserverDeviceParameter.getPath(sensorId));