Search in sources :

Example 31 with TaxonNode

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());
}
Also used : TaxonNode(org.eol.globi.domain.TaxonNode) PropertyEnricher(org.eol.globi.service.PropertyEnricher) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl) TreeMap(java.util.TreeMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

TaxonNode (org.eol.globi.domain.TaxonNode)31 Taxon (org.eol.globi.domain.Taxon)13 Test (org.junit.Test)13 Node (org.neo4j.graphdb.Node)12 Relationship (org.neo4j.graphdb.Relationship)12 TaxonImpl (org.eol.globi.domain.TaxonImpl)11 Study (org.eol.globi.domain.Study)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Specimen (org.eol.globi.domain.Specimen)5 SpecimenNode (org.eol.globi.domain.SpecimenNode)5 Transaction (org.neo4j.graphdb.Transaction)4 HashSet (java.util.HashSet)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 PropertyEnricherException (org.eol.globi.service.PropertyEnricherException)3 StudyImpl (org.eol.globi.domain.StudyImpl)2 StudyNode (org.eol.globi.domain.StudyNode)2 PropertyEnricher (org.eol.globi.service.PropertyEnricher)2 TaxonFuzzySearchIndex (org.eol.globi.taxon.TaxonFuzzySearchIndex)2