2 * Copyright (c) 2010-2020 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.bluetooth;
16 import java.util.concurrent.ConcurrentHashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.core.thing.ThingUID;
23 * Mock implementation of a {@link BluetoothAdapter}.
25 * @author Connor Petty - Initial contribution
28 public class MockBluetoothAdapter implements BluetoothAdapter {
30 private Map<BluetoothAddress, MockBluetoothDevice> devices = new ConcurrentHashMap<>();
31 private BluetoothAddress address = TestUtils.randomAddress();
32 private ThingUID uid = TestUtils.randomThingUID();
35 public ThingUID getUID() {
40 public void addDiscoveryListener(BluetoothDiscoveryListener listener) {
44 public void removeDiscoveryListener(@Nullable BluetoothDiscoveryListener listener) {
48 public void scanStart() {
52 public void scanStop() {
56 public @Nullable BluetoothAddress getAddress() {
61 public MockBluetoothDevice getDevice(BluetoothAddress address) {
62 return devices.computeIfAbsent(address, addr -> new MockBluetoothDevice(this, addr));
66 public boolean hasHandlerForDevice(BluetoothAddress address) {
71 public @Nullable String getLocation() {
76 public @Nullable String getLabel() {