use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class ResolvingTaxonIndexTest method createSpeciesMatchHigherOrder.
@Test
public void createSpeciesMatchHigherOrder() throws NodeFactoryException {
PropertyEnricher enricher = new PropertyEnricher() {
@Override
public Map<String, String> enrich(Map<String, String> properties) throws PropertyEnricherException {
Taxon taxon = TaxonUtil.mapToTaxon(properties);
if ("bla bla".equals(taxon.getName())) {
taxon.setPath("a path");
taxon.setExternalId("anExternalId");
taxon.setCommonNames(EXPECTED_COMMON_NAMES);
taxon.setExternalUrl("someInfoUrl");
taxon.setThumbnailUrl("someThumbnailUrl");
}
return TaxonUtil.taxonToMap(taxon);
}
@Override
public void shutdown() {
}
};
ResolvingTaxonIndex taxonService = createTaxonService(getGraphDb());
taxonService.setEnricher(enricher);
this.taxonService = taxonService;
TaxonNode taxon = this.taxonService.getOrCreateTaxon(new TaxonImpl("bla bla bla"));
assertEquals("bla bla", taxon.getName());
assertEquals("a path", taxon.getPath());
assertEquals("anExternalId", taxon.getExternalId());
assertEquals("someInfoUrl", taxon.getExternalUrl());
assertEquals("someThumbnailUrl", taxon.getThumbnailUrl());
taxon = this.taxonService.getOrCreateTaxon(new TaxonImpl("bla bla boo"));
assertEquals("bla bla", taxon.getName());
assertEquals("a path", taxon.getPath());
assertEquals("anExternalId", taxon.getExternalId());
taxon = this.taxonService.getOrCreateTaxon(new TaxonImpl("boo bla"));
assertEquals("boo bla", taxon.getName());
assertThat(taxon.getExternalId(), is(PropertyAndValueDictionary.NO_MATCH));
assertNull(taxon.getPath());
}
Aggregations