@Test public void testGetDiscoveredPeerByBluetoothMacAddress_PeersFound() throws Exception { String testBTAddress = "01:00:00:00:00:00:00:E0"; HashMap<PeerProperties, Timestamp> mDiscoveredPeers = new HashMap<>(); mDiscoveredPeers.put(mMockPeerProperties, new Timestamp(1000L)); when(mMockPeerProperties.getBluetoothMacAddress()).thenReturn(testBTAddress); Field mDiscoveredPeersField = mPeerModel.getClass().getDeclaredField("mDiscoveredPeers"); mDiscoveredPeersField.setAccessible(true); mDiscoveredPeersField.set(mPeerModel, mDiscoveredPeers); PeerProperties pp = mPeerModel.getDiscoveredPeerByBluetoothMacAddress(testBTAddress); assertThat("The proper peer properties instance is returned", pp, is(mMockPeerProperties)); }
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();  }