@Test public void getGroupedPwPairsSortedByRankWorks() { PhysicalWebCollection physicalWebCollection = new PhysicalWebCollection(); addPair(physicalWebCollection, ID1, URL1, GROUP_ID1); addPair(physicalWebCollection, ID2, URL2, null); addPair(physicalWebCollection, ID3, URL2, null); addPair(physicalWebCollection, ID4, URL3a, GROUP_ID2); addPair(physicalWebCollection, ID5, URL3b, GROUP_ID2); List<PwPair> groupedPairs = physicalWebCollection.getGroupedPwPairsSortedByRank(testComparator); assertEquals(groupedPairs.size(), 3); assertEquals(groupedPairs.get(0).getPwsResult().getGroupId(), GROUP_ID1); assertEquals(groupedPairs.get(0).getUrlDevice().getId(), ID1); assertEquals(groupedPairs.get(1).getPwsResult().getGroupId(), null); assertEquals(groupedPairs.get(1).getUrlDevice().getId(), ID2); assertEquals(groupedPairs.get(2).getPwsResult().getGroupId(), GROUP_ID2); assertEquals(groupedPairs.get(2).getUrlDevice().getId(), ID4); }
public List<PwPair> getGroupedPwPairsSortedByRank(Comparator<PwPair> comparator) { List<PwPair> allPwPairs = getPwPairs(); List<PwPair> groupedPwPairs = removeDuplicateGroupIds(allPwPairs, null, comparator); Collections.sort(groupedPwPairs, comparator); return removeDuplicateSiteUrls(groupedPwPairs); }
PhysicalWebCollection { public List<PwPair> getGroupedPwPairsSortedByRank(Comparator<PwPair> comparator) { List<PwPair> allPwPairs = getPwPairs(); List<PwPair> groupedPwPairs = removeDuplicateGroupIds(allPwPairs, null, comparator); Collections.sort(groupedPwPairs, comparator); return removeDuplicateSiteUrls(groupedPwPairs); } }
PhysicalWebCollection { public List<PwPair> getGroupedPwPairsSortedByRank(Comparator<PwPair> comparator) { List<PwPair> allPwPairs = getPwPairs(); List<PwPair> groupedPwPairs = removeDuplicateGroupIds(allPwPairs, null, comparator); Collections.sort(groupedPwPairs, comparator); return removeDuplicateSiteUrls(groupedPwPairs); } PhysicalWebCollection(); }
PhysicalWebCollection { public List<PwPair> getGroupedPwPairsSortedByRank(Comparator<PwPair> comparator) { List<PwPair> allPwPairs = getPwPairs(); List<PwPair> groupedPwPairs = removeDuplicateGroupIds(allPwPairs, null, comparator); Collections.sort(groupedPwPairs, comparator); return removeDuplicateSiteUrls(groupedPwPairs); } 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 List<PwPair> getGroupedPwPairsSortedByRank(Comparator<PwPair> comparator) { List<PwPair> allPwPairs = getPwPairs(); List<PwPair> groupedPwPairs = removeDuplicateGroupIds(allPwPairs, null, comparator); Collections.sort(groupedPwPairs, comparator); return removeDuplicateSiteUrls(groupedPwPairs); } 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();  }