URIReferencesUtils { List<String> mergeLists(List<String> originList, List<CrawleableUri> newList) { originList = (originList == null) ? Collections.emptyList() : originList; List<String> newListStrings = (newList == null) ? Collections.emptyList() : newList.stream().map(this::convertURI).collect(Collectors.toList()); HashSet<String> ret = new HashSet<>((originList.size() >= newListStrings.size()) ? originList : newListStrings); ret.addAll(((originList.size() >= newListStrings.size()) ? newListStrings : originList)); return new ArrayList<>(ret); } URIReferencesUtils();   URIReferencesUtils(URIShortcutMode uriShortcutMode);   }
@Test public void mergeLists() { URIReferencesUtils utils = new URIReferencesUtils(URIShortcutMode.TOTAL_URI); assertTrue("Merging two null's should return an empty list", utils.mergeLists(null, null).isEmpty()); List<String> foundURI1String = foundURI1.stream().map(e -> e.getUri().toString()).collect(Collectors.toList()); List<String> foundURI2String = foundURI2.stream().map(e -> e.getUri().toString()).collect(Collectors.toList()); assertEquals("Merging nothing to something should return the same", foundURI1String, utils.mergeLists(foundURI1String, Collections.emptyList())); List<String> combinedList = new ArrayList<>(foundURI1String); combinedList.addAll(foundURI2String); assertTrue("Simple merging of 2 lists", utils.mergeLists(foundURI1String, foundURI2).containsAll(combinedList)); assertTrue("Redundant merging of 2 lists", utils.mergeLists(foundURI1String, foundURI1).containsAll(foundURI1String)); }