@Test public void testGetDiscoveredPeerByBluetoothMacAddress_NoPeers() throws Exception { HashMap<PeerProperties, Timestamp> mDiscoveredPeers = new HashMap<>(); Field mDiscoveredPeersField = mPeerModel.getClass().getDeclaredField("mDiscoveredPeers"); mDiscoveredPeersField.setAccessible(true); mDiscoveredPeersField.set(mPeerModel, mDiscoveredPeers); PeerProperties pp = mPeerModel.getDiscoveredPeerByBluetoothMacAddress("testBTAddres"); assertThat("Is null when no peers found", pp, is(nullValue())); }
public synchronized PeerProperties getDiscoveredPeerByBluetoothMacAddress(final String bluetoothMacAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getBluetoothMacAddress() != null && peerProperties.getBluetoothMacAddress().equals(bluetoothMacAddress)) { foundPeerProperties = peerProperties; break; } } return foundPeerProperties; }
PeerModel { public synchronized PeerProperties getDiscoveredPeerByBluetoothMacAddress(final String bluetoothMacAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getBluetoothMacAddress() != null && peerProperties.getBluetoothMacAddress().equals(bluetoothMacAddress)) { foundPeerProperties = peerProperties; break; } } return foundPeerProperties; } }
PeerModel { public synchronized PeerProperties getDiscoveredPeerByBluetoothMacAddress(final String bluetoothMacAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getBluetoothMacAddress() != null && peerProperties.getBluetoothMacAddress().equals(bluetoothMacAddress)) { foundPeerProperties = peerProperties; break; } } return foundPeerProperties; } PeerModel(Listener listener, DiscoveryManagerSettings settings); }
PeerModel { public synchronized PeerProperties getDiscoveredPeerByBluetoothMacAddress(final String bluetoothMacAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getBluetoothMacAddress() != null && peerProperties.getBluetoothMacAddress().equals(bluetoothMacAddress)) { foundPeerProperties = peerProperties; break; } } return foundPeerProperties; } PeerModel(Listener listener, DiscoveryManagerSettings settings); void addListener(Listener listener); void removeListener(Listener listener); void clear(); void onPeerExpirationTimeChanged(); synchronized PeerProperties getDiscoveredPeerByBluetoothMacAddress(final String bluetoothMacAddress); synchronized PeerProperties getDiscoveredPeerByDeviceAddress(final String deviceAddress); synchronized PeerProperties removePeer(PeerProperties peerPropertiesToRemove); void addOrUpdateDiscoveredPeer(PeerProperties peerPropertiesToAddOrUpdate); synchronized void checkListForExpiredPeers(); }
PeerModel { public synchronized PeerProperties getDiscoveredPeerByBluetoothMacAddress(final String bluetoothMacAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getBluetoothMacAddress() != null && peerProperties.getBluetoothMacAddress().equals(bluetoothMacAddress)) { foundPeerProperties = peerProperties; break; } } return foundPeerProperties; } PeerModel(Listener listener, DiscoveryManagerSettings settings); void addListener(Listener listener); void removeListener(Listener listener); void clear(); void onPeerExpirationTimeChanged(); synchronized PeerProperties getDiscoveredPeerByBluetoothMacAddress(final String bluetoothMacAddress); synchronized PeerProperties getDiscoveredPeerByDeviceAddress(final String deviceAddress); synchronized PeerProperties removePeer(PeerProperties peerPropertiesToRemove); void addOrUpdateDiscoveredPeer(PeerProperties peerPropertiesToAddOrUpdate); synchronized void checkListForExpiredPeers();  }