ExperimentSearchService { public ImmutableSet<Experiment> searchPublicExperimentsBySpecies(String speciesSubstring) { return experimentTrader.getPublicExperiments() .stream() .filter(experiment -> containsIgnoreCase(experiment.getSpecies().getName(), speciesSubstring) || containsIgnoreCase(experiment.getSpecies().getReferenceName(), speciesSubstring) || containsIgnoreCase(experiment.getSpecies().getEnsemblName(), speciesSubstring)) .collect(toImmutableSet()); } ExperimentSearchService(ExperimentTrader experimentTrader); ImmutableSet<Experiment> searchPublicExperimentsBySpecies(String speciesSubstring); ImmutableSet<Experiment> searchPublicExperimentsByAccession(String accessionSubstring);  }
@Test void searchBySpecies() { assertThat(subject.searchPublicExperimentsBySpecies(SPECIES.getName())) .size().isBetween(1, MATCH_EXPERIMENTS_COUNT); }
@Test void searchBySpeciesMatchesAnySpeciesNamingConvention() { assertThat(subject.searchPublicExperimentsBySpecies(SPECIES.getName())) .containsExactlyElementsOf(subject.searchPublicExperimentsBySpecies(SPECIES.getReferenceName())) .containsExactlyElementsOf(subject.searchPublicExperimentsBySpecies(SPECIES.getEnsemblName())) .size().isBetween(1, MATCH_EXPERIMENTS_COUNT); }
@Test void searchBySpeciesIsCaseInsensitive() { assertThat(subject.searchPublicExperimentsBySpecies(SPECIES.getName())) .containsExactlyElementsOf( subject.searchPublicExperimentsBySpecies(SPECIES.getName().toUpperCase())) .containsExactlyElementsOf( subject.searchPublicExperimentsBySpecies(SPECIES.getName().toLowerCase())) .containsExactlyElementsOf( subject.searchPublicExperimentsBySpecies(SPECIES.getReferenceName().toUpperCase())) .containsExactlyElementsOf( subject.searchPublicExperimentsBySpecies(SPECIES.getReferenceName().toLowerCase())) .containsExactlyElementsOf( subject.searchPublicExperimentsBySpecies(SPECIES.getEnsemblName().toUpperCase())) .containsExactlyElementsOf( subject.searchPublicExperimentsBySpecies(SPECIES.getEnsemblName().toLowerCase())) .size().isBetween(1, MATCH_EXPERIMENTS_COUNT); }
@Test void returnsEmptyIfNoSpeciesMatches() { assertThat(subject.searchPublicExperimentsBySpecies(SPECIES.getReferenceName() + randomAlphabetic(1))) .isEmpty(); }