ListMatcher { public List<Match> getMatches(String haystack){ return needleList.stream() .map(needle -> levenshteinMatch(needle, haystack)) .sorted((sm1,sm2) -> sm1.compareTo(sm2)) .collect(Collectors.toList()); } ListMatcher(Collection<String> needleList); List<Match> getMatches(String haystack);  }
@Test public void getMatchTestFullMatch() { List<Match> matches = listMatcher.getMatches(needle2); assert(matches.get(0).getNeedle().equals(needle2)); assert(matches.get(0).getDistance() == 0); assert(matches.get(1).getDistance() != 0); assert(matches.get(2).getDistance() != 0); }