use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImporterFactoryImplIT method defaultTSVImporterCachedZenodo.
@Test
public void defaultTSVImporterCachedZenodo() throws StudyImporterException, DatasetRegistryException {
final DatasetRegistry datasetRegistry = new DatasetRegistryWithCache(new DatasetRegistryZenodo(inStream -> inStream), dataset -> CacheUtil.cacheFor(dataset.getNamespace(), "target/datasets", inStream -> inStream));
DatasetImporter importer = getTemplateImporter(datasetRegistry, "globalbioticinteractions/template-dataset");
DatasetImporterForTSV importerTSV = (DatasetImporterForTSV) importer;
assertThat(importerTSV.getSourceCitation(), containsString("doi.org"));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImporterForRegistryTest method filteredDatasets.
@Test
public void filteredDatasets() throws StudyImporterException {
DatasetImporterForRegistry importer = new DatasetImporterForRegistry(null, null, new DatasetRegistry() {
@Override
public Collection<String> findNamespaces() throws DatasetRegistryException {
return Collections.singletonList("some/namespace");
}
@Override
public Dataset datasetFor(String namespace) throws DatasetRegistryException {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), in -> in) {
@Override
public InputStream retrieve(URI resource) throws IOException {
if (!StringUtils.endsWith(resource.toString(), "globi.json")) {
throw new IOException();
}
return IOUtils.toInputStream("{\"some\":\"thing\"}", StandardCharsets.UTF_8);
}
};
return dataset;
}
});
importer.setDatasetFilter(x -> false);
importer.importStudy();
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImplTest method doiExpectedPrefix.
@Test
public void doiExpectedPrefix() throws IOException {
Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
dataset.setConfig(new ObjectMapper().readTree("{\"doi\": \"doi:10.2980/1195-6860(2006)13[23:TDOFUB]2.0.CO;2\" }"));
assertThat(dataset.getDOI(), is(new DOI("2980", "1195-6860(2006)13[23:TDOFUB]2.0.CO;2")));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImplTest method doiExpected.
@Test
public void doiExpected() throws IOException {
Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
dataset.setConfig(new ObjectMapper().readTree("{\"doi\": \"http://dx.doi.org/10.2980/1195-6860(2006)13[23:TDOFUB]2.0.CO;2\" }"));
assertThat(dataset.getDOI(), is(new DOI("2980", "1195-6860(2006)13[23:TDOFUB]2.0.CO;2")));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetTest method resourceURL.
@Test
public void resourceURL() throws IOException, URISyntaxException {
URL resource = getClass().getResource("archive.zip");
File archive = new File(resource.toURI());
assertThat(archive.exists(), is(true));
URI parentDir = archive.getParentFile().toURI();
Dataset dataset = new DatasetImpl("some/namespace", parentDir, inStream -> inStream);
InputStream retrieve = dataset.retrieve(resource.toURI());
assertArchiveHash(retrieve);
assertArchiveHash(dataset.retrieve(URI.create("archive.zip")));
assertArchiveHash(dataset.retrieve(URI.create("/archive.zip")));
}
Aggregations