Search in sources :

Example 16 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.

the class GlobalNamesServiceTest method lookupOTT.

@Test
public void lookupOTT() throws PropertyEnricherException {
    GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.OTT);
    HashMap<String, String> props = new HashMap<>();
    props.put(PropertyAndValueDictionary.NAME, "Arius felis");
    Map<String, String> enrich = service.enrich(props);
    assertThat(enrich.get(PropertyAndValueDictionary.EXTERNAL_ID), is("OTT:139650"));
    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)

Example 17 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.

the class GlobalNamesServiceTest method lookupITISSynonymFails.

@Test
public void lookupITISSynonymFails() throws PropertyEnricherException {
    GlobalNamesService service = new GlobalNamesService();
    HashMap<String, String> props = new HashMap<String, String>();
    props.put(PropertyAndValueDictionary.NAME, "Corizidae");
    Map<String, String> enrich = service.enrich(props);
    assertThat(enrich.get(PropertyAndValueDictionary.EXTERNAL_ID), is("ITIS:108477"));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Example 18 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService 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"));
}
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 19 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.

the class GlobalNamesServiceTest method lookupITIS.

@Test
public void lookupITIS() throws PropertyEnricherException {
    GlobalNamesService service = new GlobalNamesService();
    Map<String, String> props = assertHomoSapiens(service);
    assertThat(props.get(PropertyAndValueDictionary.EXTERNAL_ID), is("ITIS:180092"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Example 20 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService 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"));
}
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)

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