@Test public void testGetDiscoveredPeerByDeviceAddress_PeerFound() throws Exception { String testDeviceAddress = "testDeviceAddress"; HashMap<PeerProperties, Timestamp> mDiscoveredPeers = new HashMap<>(); mDiscoveredPeers.put(mMockPeerProperties, new Timestamp(1000L)); when(mMockPeerProperties.getDeviceAddress()).thenReturn(testDeviceAddress); Field mDiscoveredPeersField = mPeerModel.getClass().getDeclaredField("mDiscoveredPeers"); mDiscoveredPeersField.setAccessible(true); mDiscoveredPeersField.set(mPeerModel, mDiscoveredPeers); PeerProperties pp = mPeerModel.getDiscoveredPeerByDeviceAddress(testDeviceAddress); assertThat("The proper peer properties instance is returned", pp, is(mMockPeerProperties)); }
public synchronized PeerProperties getDiscoveredPeerByDeviceAddress(final String deviceAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getDeviceAddress() != null && peerProperties.getDeviceAddress().equalsIgnoreCase(deviceAddress)) { foundPeerProperties = peerProperties; break; } } return foundPeerProperties; }
PeerModel { public synchronized PeerProperties getDiscoveredPeerByDeviceAddress(final String deviceAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getDeviceAddress() != null && peerProperties.getDeviceAddress().equalsIgnoreCase(deviceAddress)) { foundPeerProperties = peerProperties; break; } } return foundPeerProperties; } }
PeerModel { public synchronized PeerProperties getDiscoveredPeerByDeviceAddress(final String deviceAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getDeviceAddress() != null && peerProperties.getDeviceAddress().equalsIgnoreCase(deviceAddress)) { foundPeerProperties = peerProperties; break; } } return foundPeerProperties; } PeerModel(Listener listener, DiscoveryManagerSettings settings); }
PeerModel { public synchronized PeerProperties getDiscoveredPeerByDeviceAddress(final String deviceAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getDeviceAddress() != null && peerProperties.getDeviceAddress().equalsIgnoreCase(deviceAddress)) { 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 getDiscoveredPeerByDeviceAddress(final String deviceAddress) { PeerProperties foundPeerProperties = null; for (PeerProperties peerProperties : mDiscoveredPeers.keySet()) { if (peerProperties != null && peerProperties.getDeviceAddress() != null && peerProperties.getDeviceAddress().equalsIgnoreCase(deviceAddress)) { 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();  }