use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method lookupMultipleSources.
@Test
public void lookupMultipleSources() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService(Arrays.asList(GlobalNamesSources.GBIF, GlobalNamesSources.ITIS));
final List<Taxon> taxa = new ArrayList<Taxon>();
service.findTermsForNames(Collections.singletonList("Homo sapiens"), new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
taxa.add(taxon);
}
});
assertThat(taxa.size(), is(2));
}
use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method lookupITISNonExisting.
@Test
public void lookupITISNonExisting() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService();
HashMap<String, String> props = new HashMap<String, String>();
props.put(PropertyAndValueDictionary.NAME, "Donald Duck");
Map<String, String> enrich = service.enrich(props);
assertThat(enrich.size(), is(0));
}
use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method createTaxaListFromNameWithSpecialCharacter.
@Test
public void createTaxaListFromNameWithSpecialCharacter() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.IF);
final List<Taxon> foundTaxa = new ArrayList<Taxon>();
service.findTermsForNames(Collections.singletonList("4594386|Epichloƫ"), new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
assertNotNull(nodeId);
foundTaxa.add(taxon);
}
});
assertThat(foundTaxa.size(), is(1));
}
use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method createTaxaListFromNoNameList.
@Test
public void createTaxaListFromNoNameList() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.ITIS);
final List<Taxon> foundTaxa = new ArrayList<Taxon>();
service.findTermsForNames(Arrays.asList("1|Donald duck", "2|Mickey mouse"), new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
assertNotNull(nodeId);
assertThat(nameType, is(NameType.NONE));
foundTaxa.add(taxon);
}
});
assertThat(foundTaxa.size(), is(2));
}
use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method lookupITISSynonymSuccess.
@Test
public void lookupITISSynonymSuccess() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService();
HashMap<String, String> props = new HashMap<String, String>();
props.put(PropertyAndValueDictionary.NAME, "Arius felis");
Map<String, String> enrich = service.enrich(props);
assertThat(enrich.get(PropertyAndValueDictionary.EXTERNAL_ID), is("ITIS:680665"));
assertThat(enrich.get(PropertyAndValueDictionary.NAME), is("Ariopsis felis"));
}
Aggregations