FeaturedSpeciesService { public ImmutableList<String> getSpeciesNamesSortedByExperimentCount() { return featuredSpeciesDao.fetchSpeciesSortedByExperimentCount().stream() .map(speciesFactory::create) .map(Species::getReferenceName) .map(StringUtils::capitalize) .distinct() .collect(toImmutableList()); } FeaturedSpeciesService(FeaturedSpeciesDao featuredSpeciesDao, SpeciesFactory speciesFactory); ImmutableList<String> getSpeciesNamesSortedByExperimentCount();  }
@Test public void aggregatesAlternateSpellingsAndCapitalizes() { when(featuredSpeciesDaoMock.fetchSpeciesSortedByExperimentCount()) .thenReturn(ImmutableList.of( "mus musculus", "Mus musculus", "Homo sapiens", "Homo_Sapiens", "canis_lupus", "canis_familiaris", "Canis_lupus familiaris")); assertThat(subject.getSpeciesNamesSortedByExperimentCount()) .containsExactly("Mus musculus", "Homo sapiens", "Canis familiaris"); }
@Test public void emptyInEmptyOut() { when(featuredSpeciesDaoMock.fetchSpeciesSortedByExperimentCount()).thenReturn(ImmutableList.of()); assertThat(subject.getSpeciesNamesSortedByExperimentCount()) .isEmpty(); }