use of org.eol.globi.taxon.TermMatchListener 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.TermMatchListener 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.TermMatchListener 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.TermMatchListener in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method lookupNCBIPrune.
@Test
public void lookupNCBIPrune() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService(Arrays.asList(GlobalNamesSources.NCBI));
final List<Taxon> taxa = new ArrayList<>();
service.findTermsForNames(Collections.singletonList("Klebsiella pneumoniae"), new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
taxa.add(taxon);
assertThat(nameType, is(NameType.SAME_AS));
}
});
assertThat(taxa.size(), is(1));
assertThat(taxa.get(0).getPath(), endsWith("Klebsiella | Klebsiella pneumoniae"));
}
use of org.eol.globi.taxon.TermMatchListener in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method createTaxaListFromNameListNCBI.
@Test
public void createTaxaListFromNameListNCBI() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.NCBI);
final List<Taxon> foundTaxa = new ArrayList<Taxon>();
service.findTermsForNames(Collections.singletonList("1|Prunus persica L."), new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
assertNotNull(nodeId);
foundTaxa.add(taxon);
}
});
assertThat(foundTaxa.size(), is(1));
assertThat(foundTaxa.get(0).getExternalId(), is(TaxonomyProvider.NCBI.getIdPrefix() + "3760"));
}
Aggregations