use of org.eol.globi.service.TaxonUtil.SOURCE_TAXON_SPECIFIC_EPITHET in project eol-globi-data by jhpoelen.
the class InteractionImporterTest method importWithTaxonHierarchy.
@Test
public void importWithTaxonHierarchy() throws StudyImporterException {
final InteractionListener listener = getAssertingInteractionImporter();
final TreeMap<String, String> link = new TreeMap<>();
link.put(SOURCE_TAXON_NAME, "Donald duck");
link.put(SOURCE_TAXON_RANK, "species");
link.put(SOURCE_TAXON_PATH, "Aves | Donald | Donald duck");
link.put(SOURCE_TAXON_PATH_IDS, "AvesId | DonaldId | DonaldId duckId");
link.put(SOURCE_TAXON_PATH_NAMES, "class | genus | species");
link.put(SOURCE_TAXON_SPECIFIC_EPITHET, "duck");
link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, InteractType.ATE.getIRI());
link.put(TARGET_TAXON_NAME, "mini");
link.put(TARGET_TAXON_RANK, "species");
link.put(TARGET_TAXON_PATH_IDS, "miniId");
link.put(DATASET_CITATION, "some source ref");
link.put(REFERENCE_ID, "123");
link.put(REFERENCE_CITATION, "");
listener.on(link);
AtomicInteger foundSpecimen = new AtomicInteger(0);
RelationshipListener someListener = relationship -> {
final SpecimenNode someSpecimen = new SpecimenNode(relationship.getEndNode());
assertTrue(someSpecimen.getUnderlyingNode().hasRelationship(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.COLLECTED)));
assertTrue(someSpecimen.getUnderlyingNode().hasRelationship(NodeUtil.asNeo4j(RelTypes.ORIGINALLY_DESCRIBED_AS)));
Node taxonNode = someSpecimen.getUnderlyingNode().getSingleRelationship(NodeUtil.asNeo4j(RelTypes.ORIGINALLY_DESCRIBED_AS), Direction.OUTGOING).getEndNode();
TaxonNode taxon = new TaxonNode(taxonNode);
if (someSpecimen.getUnderlyingNode().hasRelationship(Direction.OUTGOING, NodeUtil.asNeo4j(InteractType.ATE))) {
assertThat(taxon.getPath(), is("Aves | Donald | Donald duck"));
assertThat(taxon.getPathNames(), is("class | genus | species"));
assertThat(taxon.getRank(), is("species"));
assertThat(taxon.getPathIds(), is("AvesId | DonaldId | DonaldId duckId"));
foundSpecimen.incrementAndGet();
}
};
handleRelations(someListener, RelTypes.COLLECTED);
assertThat(foundSpecimen.get(), is(1));
}
Aggregations