use of org.eol.globi.service.DatasetLocal in project eol-globi-data by jhpoelen.
the class StudyImporterForLifeWatchGreeceTest method readAssociations.
@Test
public void readAssociations() throws StudyImporterException {
List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
assertThat(studies.size(), is(0));
ParserFactoryLocal parserFactory = new ParserFactoryLocal();
StudyImporterForLifeWatchGreece importer = new StudyImporterForLifeWatchGreece(parserFactory, nodeFactory);
importer.setDataset(new DatasetLocal());
importStudy(importer);
studies = NodeUtil.findAllStudies(getGraphDb());
assertThat(studies.size(), is(146));
Set<String> taxa = new HashSet<String>();
int totalPredatorPreyRelationships = 0;
for (Study study : studies) {
assertThat(study.getCitation(), is(notNullValue()));
assertThat(study.getTitle(), containsString("greece"));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
for (Relationship collectedRel : specimens) {
addTaxonNameForSpecimenNode(taxa, collectedRel.getEndNode());
Specimen predatorSpecimen = new SpecimenNode(collectedRel.getEndNode());
Iterable<Relationship> prey = NodeUtil.getStomachContents(predatorSpecimen);
for (Relationship ateRel : prey) {
totalPredatorPreyRelationships++;
addTaxonNameForSpecimenNode(taxa, ateRel.getEndNode());
}
}
}
assertThat(taxa.contains("Aves"), is(true));
assertThat(totalPredatorPreyRelationships, is(793));
}
Aggregations