use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class ExporterOccurrencesTest method dontExportToCSVSpecimenEmptyStomach.
@Test
public void dontExportToCSVSpecimenEmptyStomach() throws NodeFactoryException, IOException {
Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:123"));
specimen.setBasisOfRecord(new TermImpl("test:123", "aBasisOfRecord"));
resolveNames();
StringWriter row = new StringWriter();
exportOccurrences().exportStudy(myStudy, row, true);
String expected = "";
expected += getExpectedHeader();
expected += "\nglobi:occur:2\tEOL:123\t\t\t\t\t\t\t\t\t\t\t\t\taBasisOfRecord\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
assertThat(row.getBuffer().toString(), equalTo(expected));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class ExporterOccurrencesTest method exportNoHeader.
@Test
public void exportNoHeader() throws IOException, NodeFactoryException, ParseException {
createTestData(null);
resolveNames();
String expected = getExpectedData();
Study myStudy1 = nodeFactory.findStudy("myStudy");
StringWriter row = new StringWriter();
exportOccurrences().exportStudy(myStudy1, row, false);
assertThat(row.getBuffer().toString(), equalTo(expected));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class ExporterOccurrencesTest method createTestData.
private void createTestData(Double length) throws NodeFactoryException, ParseException {
Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:327955"));
specimen.setStomachVolumeInMilliLiter(666.0);
specimen.setLifeStage(new TermImpl("GLOBI:JUVENILE", "JUVENILE"));
specimen.setPhysiologicalState(new TermImpl("GLOBI:DIGESTATE", "DIGESTATE"));
specimen.setBodyPart(new TermImpl("GLOBI:BONE", "BONE"));
nodeFactory.setUnixEpochProperty(specimen, ExportTestUtil.utcTestDate());
if (null != length) {
specimen.setLengthInMm(length);
}
Location location = nodeFactory.getOrCreateLocation(new LocationImpl(12.0, -1.0, -60.0, null));
specimen.caughtIn(location);
Specimen wolf1 = eatWolf(specimen, myStudy);
wolf1.caughtIn(location);
Specimen wolf2 = eatWolf(specimen, myStudy);
wolf2.caughtIn(location);
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class ExporterMeasurementOrFactTest method noMatchNames.
@Test
public void noMatchNames() throws IOException, NodeFactoryException, ParseException {
Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
nodeFactory.createSpecimen(myStudy, new TaxonImpl(PropertyAndValueDictionary.NO_NAME, "externalId1"));
nodeFactory.createSpecimen(myStudy, new TaxonImpl("Some namus", PropertyAndValueDictionary.NO_MATCH));
Study myStudy1 = nodeFactory.findStudy("myStudy");
StringWriter row = new StringWriter();
new ExporterMeasurementOrFact().exportStudy(myStudy1, row, false);
assertThat(row.getBuffer().toString(), equalTo(""));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class GraphExporterImplTest method exportAll.
@Test
public void exportAll() throws StudyImporterException, IOException {
File tmpDir = FileUtils.getTempDirectory();
File tmpDirPath = new File(tmpDir, "test" + new Random().nextLong());
FileUtils.forceMkdir(tmpDirPath);
assertThat(tmpDirPath.list().length, is(0));
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("a study", "a source", "doi:12345L", null));
Specimen human = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens", "NCBI:123"));
human.ate(nodeFactory.createSpecimen(study, new TaxonImpl("Canis familiaris", "BLA:444")));
resolveNames();
try {
new GraphExporterImpl().export(getGraphDb(), tmpDirPath.getAbsolutePath() + "/");
assertThat(tmpDirPath.list().length, is(6));
} finally {
FileUtils.deleteQuietly(tmpDirPath);
}
}
Aggregations