@Test public void getDeviceTest() { BluetoothDevice bluetoothDevice = Mockito.mock(BluetoothDevice.class); Mockito.when(bluetoothDevice.getAddress()).thenReturn("00:11:22:33:44:55"); assertNotNull(deviceManager.getDevice(bluetoothDevice)); assertNotNull(deviceManager.getDevice(bluetoothDevice)); }
public synchronized Device getDevice(BluetoothDevice device) { NeatleLogger.d("Getting connection object for " + device.getAddress()); Device dev = devices.get(device.getAddress()); if (dev == null) { BluetoothManager mng = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); dev = new Device(context, device, mng.getAdapter()); devices.put(device.getAddress(), dev); } return dev; }
DeviceManager { public synchronized Device getDevice(BluetoothDevice device) { NeatleLogger.d("Getting connection object for " + device.getAddress()); Device dev = devices.get(device.getAddress()); if (dev == null) { BluetoothManager mng = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); dev = new Device(context, device, mng.getAdapter()); devices.put(device.getAddress(), dev); } return dev; } }
DeviceManager { public synchronized Device getDevice(BluetoothDevice device) { NeatleLogger.d("Getting connection object for " + device.getAddress()); Device dev = devices.get(device.getAddress()); if (dev == null) { BluetoothManager mng = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); dev = new Device(context, device, mng.getAdapter()); devices.put(device.getAddress(), dev); } return dev; } private  DeviceManager(Context context); }
DeviceManager { public synchronized Device getDevice(BluetoothDevice device) { NeatleLogger.d("Getting connection object for " + device.getAddress()); Device dev = devices.get(device.getAddress()); if (dev == null) { BluetoothManager mng = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); dev = new Device(context, device, mng.getAdapter()); devices.put(device.getAddress(), dev); } return dev; } private  DeviceManager(Context context); synchronized static DeviceManager getInstance(Context context); synchronized Device getDevice(BluetoothDevice device); @RestrictTo(RestrictTo.Scope.TESTS) void putDevice(Device device, String address); @RestrictTo(RestrictTo.Scope.TESTS) void clearDevices(); }
DeviceManager { public synchronized Device getDevice(BluetoothDevice device) { NeatleLogger.d("Getting connection object for " + device.getAddress()); Device dev = devices.get(device.getAddress()); if (dev == null) { BluetoothManager mng = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); dev = new Device(context, device, mng.getAdapter()); devices.put(device.getAddress(), dev); } return dev; } private  DeviceManager(Context context); synchronized static DeviceManager getInstance(Context context); synchronized Device getDevice(BluetoothDevice device); @RestrictTo(RestrictTo.Scope.TESTS) void putDevice(Device device, String address); @RestrictTo(RestrictTo.Scope.TESTS) void clearDevices();  }