use of org.eol.globi.data.StudyImporterForSPIRE in project eol-globi-data by jhpoelen.
the class ExporterRDFTest method exportSPIRE.
@Test
public void exportSPIRE() throws IOException, StudyImporterException {
StudyImporterForSPIRE importer = new StudyImporterForSPIRE(null, nodeFactory);
importer.setFilter(recordNumber -> recordNumber < 5);
importer.setDataset(new DatasetLocal());
importStudy(importer);
List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
Taxon taxon = taxonIndex.getOrCreateTaxon(new TaxonImpl("some taxon", null));
Taxon sameAsTaxon = taxonIndex.getOrCreateTaxon(new TaxonImpl("bugus same as taxon", "EOL:123"));
Transaction tx = getGraphDb().beginTx();
try {
assertThat(taxon, is(notNullValue()));
((NodeBacked) taxon).getUnderlyingNode().createRelationshipTo(((NodeBacked) sameAsTaxon).getUnderlyingNode(), NodeUtil.asNeo4j(RelTypes.SAME_AS));
tx.success();
} finally {
tx.finish();
}
File file = File.createTempFile("spire-as-light-globi", ".nq");
try {
Writer writer = new FileWriter(file);
ExporterRDF turtleExporter = new ExporterRDF();
for (Study study : studies) {
turtleExporter.exportStudy(study, writer, true);
}
writer.flush();
writer.close();
assertTrue(file.exists());
String content = IOUtils.toString(new FileInputStream(file));
assertThat(content, not(containsString("no:match")));
assertThat(content, containsString("http://purl.obolibrary.org/obo/ENVO_"));
} finally {
FileUtils.deleteQuietly(file);
}
}
Aggregations