Search in sources :

Example 11 with NameType

use of org.eol.globi.domain.NameType 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 12 with NameType

use of org.eol.globi.domain.NameType 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 13 with NameType

use of org.eol.globi.domain.NameType 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

NameType (org.eol.globi.domain.NameType)13 Taxon (org.eol.globi.domain.Taxon)12 ArrayList (java.util.ArrayList)11 TermMatchListener (org.eol.globi.taxon.TermMatchListener)10 GlobalNamesService (org.eol.globi.taxon.GlobalNamesService)9 Matchers.containsString (org.hamcrest.Matchers.containsString)9 Test (org.junit.Test)9 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 StopWatch (org.apache.commons.lang.time.StopWatch)1 JsonNode (org.codehaus.jackson.JsonNode)1 TaxonImpl (org.eol.globi.domain.TaxonImpl)1 TaxonNode (org.eol.globi.domain.TaxonNode)1 Term (org.eol.globi.domain.Term)1 PropertyEnricherException (org.eol.globi.service.PropertyEnricherException)1