use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method lookupWoRMS.
@Test
public void lookupWoRMS() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.WORMS);
HashMap<String, String> props1 = new HashMap<String, String>();
props1.put(PropertyAndValueDictionary.NAME, "Ariopsis felis");
Map<String, String> enrich = service.enrich(props1);
assertThat(enrich.get(PropertyAndValueDictionary.NAME), is("Ariopsis felis"));
assertThat(enrich.get(PropertyAndValueDictionary.PATH), containsString("Siluriformes | Ariidae | Ariopsis"));
assertThat(enrich.get(PropertyAndValueDictionary.PATH_IDS), is(""));
assertThat(enrich.get(PropertyAndValueDictionary.PATH_NAMES), containsString("order | family | genus"));
assertThat(enrich.get(PropertyAndValueDictionary.RANK), is("Species"));
assertThat(enrich.get(PropertyAndValueDictionary.EXTERNAL_ID), is("WORMS:158709"));
assertThat(enrich.get(PropertyAndValueDictionary.COMMON_NAMES), not(containsString("hardhead catfish @en")));
assertThat(enrich.get(PropertyAndValueDictionary.COMMON_NAMES), not(containsString("bagre boca chica @en")));
}
use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method assertAtLeastFortyFound.
public void assertAtLeastFortyFound(String response, final List<Taxon> foundTaxa, List<GlobalNamesSources> sources) {
String[] idsNames = response.split("\\|");
GlobalNamesService service = new GlobalNamesService(sources);
List<String> names = new ArrayList<String>();
for (int i = 0; i < idsNames.length; i += 2) {
names.add(idsNames[i] + "|" + idsNames[i + 1]);
}
try {
service.findTermsForNames(names, new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
assertNotNull(nodeId);
foundTaxa.add(taxon);
}
});
} catch (PropertyEnricherException ex) {
fail("failed to lookup name with id: [" + names + "]");
}
}
use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method createTaxaListFromLongNameList4.
@Test
public void createTaxaListFromLongNameList4() throws PropertyEnricherException {
List<String> names = namesListWithMaximumOf(100);
final List<Taxon> foundTaxa = new ArrayList<Taxon>();
GlobalNamesService service = new GlobalNamesService(Arrays.asList(GlobalNamesSources.values()));
try {
service.findTermsForNames(names, new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
assertNotNull(nodeId);
foundTaxa.add(taxon);
}
});
} catch (PropertyEnricherException ex) {
fail("failed to lookup name with id: [" + names + "]");
}
assertThat(foundTaxa.size() > 2, is(true));
}
use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method lookupSimilar.
@Test
public void lookupSimilar() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService(Arrays.asList(GlobalNamesSources.GBIF, GlobalNamesSources.ITIS));
final List<Taxon> taxa = new ArrayList<Taxon>();
service.findTermsForNames(Collections.singletonList("Zyziphus mauritiana"), new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
taxa.add(taxon);
assertThat(nameType, is(NameType.SIMILAR_TO));
}
});
assertThat(taxa.size() > 1, is(true));
}
use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.
the class GlobalNamesServiceTest method createTaxaListFromNameList.
@Test
public void createTaxaListFromNameList() throws PropertyEnricherException {
GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.ITIS);
final List<Taxon> foundTaxa = new ArrayList<Taxon>();
service.findTermsForNames(Arrays.asList("1|Homo sapiens", "2|Ariopsis felis"), new TermMatchListener() {
@Override
public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType nameType) {
assertNotNull(nodeId);
foundTaxa.add(taxon);
}
});
assertThat(foundTaxa.size(), is(2));
}
Aggregations