Search in sources :

Example 11 with GlobalNamesService

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));
}
Also used : Taxon(org.eol.globi.domain.Taxon) ArrayList(java.util.ArrayList) NameType(org.eol.globi.domain.NameType) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) TermMatchListener(org.eol.globi.taxon.TermMatchListener) Test(org.junit.Test)

Example 12 with GlobalNamesService

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));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Example 13 with GlobalNamesService

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));
}
Also used : Taxon(org.eol.globi.domain.Taxon) ArrayList(java.util.ArrayList) NameType(org.eol.globi.domain.NameType) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) TermMatchListener(org.eol.globi.taxon.TermMatchListener) Test(org.junit.Test)

Example 14 with GlobalNamesService

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));
}
Also used : Taxon(org.eol.globi.domain.Taxon) ArrayList(java.util.ArrayList) NameType(org.eol.globi.domain.NameType) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) TermMatchListener(org.eol.globi.taxon.TermMatchListener) Test(org.junit.Test)

Example 15 with GlobalNamesService

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"));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Aggregations

GlobalNamesService (org.eol.globi.taxon.GlobalNamesService)21 Matchers.containsString (org.hamcrest.Matchers.containsString)21 Test (org.junit.Test)20 HashMap (java.util.HashMap)11 ArrayList (java.util.ArrayList)9 NameType (org.eol.globi.domain.NameType)9 Taxon (org.eol.globi.domain.Taxon)9 TermMatchListener (org.eol.globi.taxon.TermMatchListener)9