SpeciesPropertiesTrader { public SpeciesProperties get(String speciesName) { SpeciesProperties result = nameToSpecies.get(normalise(speciesName)); return result != null ? result : SpeciesProperties.UNKNOWN; }  @Inject void setSpeciesPropertiesDao(SpeciesPropertiesDao speciesPropertiesDao); @PostConstruct String refresh(); SpeciesProperties get(String speciesName); Collection<SpeciesProperties> getAll();  }
@Test public void get() { assertThat(subject.get("Homo sapiens").referenceName(), is("homo sapiens")); assertThat(subject.get("Homo sapiens").ensemblName(), is("Homo_sapiens")); assertThat(subject.get("Homo sapiens").kingdom(), is("animals")); assertThat(subject.get("Hordeum vulgare").getResourcesOfType("genome_browser"), hasSize(2)); }
@Test public void unknownSpecies() { assertThat(subject.get("foobar"), is(SpeciesProperties.UNKNOWN)); assertThat(subject.get(null), is(SpeciesProperties.UNKNOWN)); }
@Test public void speciesNamesAreNormalised() { assertThat(subject.get("homo sapiens"), not(is(SpeciesProperties.UNKNOWN))); assertThat(subject.get("homo sapiens"), is(subject.get("HoMo_SaPieNs"))); assertThat(subject.get("homo sapiens"), is(subject.get("Homo sapiens"))); assertThat(subject.get("hordeum vulgare"), not(is(SpeciesProperties.UNKNOWN))); assertThat(subject.get("hordeum vulgare"), is(subject.get("Hordeum vulgare subsp. vulgare"))); assertThat(subject.get("hordeum vulgare"), is(subject.get("Hordeum_vulgare"))); }
@Test public void appliesExceptions() { assertThat(subject.get("canis lupus").referenceName(), is("canis familiaris")); assertThat(subject.get("Canis_lupus").referenceName(), is("canis familiaris")); assertThat(subject.get("canis_lupus_familiaris").referenceName(), is("canis familiaris")); assertThat(subject.get("Canis_lupus familiaris").referenceName(), is("canis familiaris")); assertThat(subject.get("Canis Lupus Familiaris").referenceName(), is("canis familiaris")); }