CrossSpeciesPhenotypeMatcher implements PhenotypeMatcher { List<PhenotypeMatch> calculateBestPhenotypeMatchesByTerm(List<PhenotypeMatch> bestForwardAndReciprocalMatches) { Map<PhenotypeTerm, Optional<PhenotypeMatch>> bestOptionalPhenotypeMatchForTerms = bestForwardAndReciprocalMatches .stream() .collect(groupingBy(PhenotypeMatch::getQueryPhenotype, maxBy(comparingDouble(PhenotypeMatch::getScore)))); return bestOptionalPhenotypeMatchForTerms.values() .stream() .filter(Optional::isPresent) .map(Optional::get) .collect(toList()); } private  CrossSpeciesPhenotypeMatcher(QueryPhenotypeMatch queryPhenotypeMatch); @Override Organism getOrganism(); @Override List<PhenotypeTerm> getQueryTerms(); @Override Map<PhenotypeTerm, Set<PhenotypeMatch>> getTermPhenotypeMatches(); @Override Set<PhenotypeMatch> getBestPhenotypeMatches(); @Override QueryPhenotypeMatch getQueryPhenotypeMatch(); @Override PhenodigmMatchRawScore matchPhenotypeIds(List<String> modelPhenotypes); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testCalculateBestPhenotypeMatchesByTermReturnsEmptyMapForEmptyInputList() { assertThat(instance.calculateBestPhenotypeMatchesByTerm(Collections.emptyList()), equalTo(Collections.emptyList())); }