]> git.basschouten.com Git - openhab-addons.git/blob
e33be02684448249c34e7c68c60cc5aa1c8dffc3
[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.bluetooth;
14
15 import java.util.Map;
16 import java.util.Objects;
17 import java.util.concurrent.ConcurrentHashMap;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.thing.ThingUID;
22
23 /**
24  * Mock implementation of a {@link BluetoothAdapter}.
25  *
26  * @author Connor Petty - Initial contribution
27  */
28 @NonNullByDefault
29 public class MockBluetoothAdapter implements BluetoothAdapter {
30
31     private Map<BluetoothAddress, MockBluetoothDevice> devices = new ConcurrentHashMap<>();
32     private BluetoothAddress address = TestUtils.randomAddress();
33     private ThingUID uid = TestUtils.randomThingUID();
34
35     @Override
36     public ThingUID getUID() {
37         return uid;
38     }
39
40     @Override
41     public void addDiscoveryListener(BluetoothDiscoveryListener listener) {
42     }
43
44     @Override
45     public void removeDiscoveryListener(@Nullable BluetoothDiscoveryListener listener) {
46     }
47
48     @Override
49     public void scanStart() {
50     }
51
52     @Override
53     public void scanStop() {
54     }
55
56     @Override
57     public @Nullable BluetoothAddress getAddress() {
58         return address;
59     }
60
61     @Override
62     public MockBluetoothDevice getDevice(BluetoothAddress address) {
63         return Objects.requireNonNull(devices.computeIfAbsent(address, addr -> new MockBluetoothDevice(this, addr)));
64     }
65
66     @Override
67     public boolean hasHandlerForDevice(BluetoothAddress address) {
68         return false;
69     }
70
71     @Override
72     public @Nullable String getLocation() {
73         return null;
74     }
75
76     @Override
77     public @Nullable String getLabel() {
78         return null;
79     }
80 }