@Test public void getTopRankedPwPairByGroupIdWorks() { PhysicalWebCollection physicalWebCollection = new PhysicalWebCollection(); addPair(physicalWebCollection, ID1, URL1, GROUP_ID1); addPair(physicalWebCollection, ID2, URL2, GROUP_ID1); addPair(physicalWebCollection, ID1, URL1, GROUP_ID2); assertNull(physicalWebCollection.getTopRankedPwPairByGroupId("notagroup", testComparator)); PwPair pwPair = physicalWebCollection.getTopRankedPwPairByGroupId(GROUP_ID1, testComparator); assertNotNull(pwPair); assertEquals(ID2, pwPair.getUrlDevice().getId()); }
public PwPair getTopRankedPwPairByGroupId(String groupId, Comparator<PwPair> comparator) { for (PwPair pwPair : getGroupedPwPairsSortedByRank(comparator)) { if (pwPair.getPwsResult().getGroupId().equals(groupId)) { return pwPair; } } return null; }
PhysicalWebCollection { public PwPair getTopRankedPwPairByGroupId(String groupId, Comparator<PwPair> comparator) { for (PwPair pwPair : getGroupedPwPairsSortedByRank(comparator)) { if (pwPair.getPwsResult().getGroupId().equals(groupId)) { return pwPair; } } return null; } }
PhysicalWebCollection { public PwPair getTopRankedPwPairByGroupId(String groupId, Comparator<PwPair> comparator) { for (PwPair pwPair : getGroupedPwPairsSortedByRank(comparator)) { if (pwPair.getPwsResult().getGroupId().equals(groupId)) { return pwPair; } } return null; } PhysicalWebCollection(); }
PhysicalWebCollection { public PwPair getTopRankedPwPairByGroupId(String groupId, Comparator<PwPair> comparator) { for (PwPair pwPair : getGroupedPwPairsSortedByRank(comparator)) { if (pwPair.getPwsResult().getGroupId().equals(groupId)) { return pwPair; } } return null; } PhysicalWebCollection(); boolean addUrlDevice(UrlDevice urlDevice); void removeUrlDevice(UrlDevice urlDevice); void addMetadata(PwsResult pwsResult); void addIcon(String url, byte[] icon); void clear(); byte[] getIcon(String url); UrlDevice getUrlDeviceById(String id); PwsResult getMetadataByBroadcastUrl(String broadcastUrl); List<UrlDevice> getUrlDevices(); JSONObject jsonSerialize(); static PhysicalWebCollection jsonDeserialize(JSONObject jsonObject); List<PwPair> getPwPairsSortedByRank(Comparator<PwPair> comparator); List<PwPair> getGroupedPwPairsSortedByRank(Comparator<PwPair> comparator); List<PwPair> getPwPairs(); PwPair getTopRankedPwPairByGroupId(String groupId, Comparator<PwPair> comparator); void setPwsEndpoint(String pwsEndpoint, int pwsApiVersion); void setPwsEndpoint(String pwsEndpoint, int pwsApiVersion, String pwsApiKey); void fetchPwsResults(final PwsResultCallback pwsResultCallback,
                              final PwsResultIconCallback pwsResultIconCallback); void cancelAllRequests(); }
PhysicalWebCollection { public PwPair getTopRankedPwPairByGroupId(String groupId, Comparator<PwPair> comparator) { for (PwPair pwPair : getGroupedPwPairsSortedByRank(comparator)) { if (pwPair.getPwsResult().getGroupId().equals(groupId)) { return pwPair; } } return null; } PhysicalWebCollection(); boolean addUrlDevice(UrlDevice urlDevice); void removeUrlDevice(UrlDevice urlDevice); void addMetadata(PwsResult pwsResult); void addIcon(String url, byte[] icon); void clear(); byte[] getIcon(String url); UrlDevice getUrlDeviceById(String id); PwsResult getMetadataByBroadcastUrl(String broadcastUrl); List<UrlDevice> getUrlDevices(); JSONObject jsonSerialize(); static PhysicalWebCollection jsonDeserialize(JSONObject jsonObject); List<PwPair> getPwPairsSortedByRank(Comparator<PwPair> comparator); List<PwPair> getGroupedPwPairsSortedByRank(Comparator<PwPair> comparator); List<PwPair> getPwPairs(); PwPair getTopRankedPwPairByGroupId(String groupId, Comparator<PwPair> comparator); void setPwsEndpoint(String pwsEndpoint, int pwsApiVersion); void setPwsEndpoint(String pwsEndpoint, int pwsApiVersion, String pwsApiKey); void fetchPwsResults(final PwsResultCallback pwsResultCallback,
                              final PwsResultIconCallback pwsResultIconCallback); void cancelAllRequests();  }