use of org.globalbioticinteractions.dataset.DatasetRegistry in project eol-globi-data by jhpoelen.
the class DatasetImporterFactoryImplIT method jsonldImporterCached.
@Test
public void jsonldImporterCached() throws StudyImporterException, DatasetRegistryException {
final DatasetRegistry datasetRegistry = new DatasetRegistryWithCache(new DatasetRegistryGitHubArchive(inStream -> inStream), dataset -> CacheUtil.cacheFor(dataset.getNamespace(), "target/datasets", inStream -> inStream));
Dataset dataset = new DatasetFactory(datasetRegistry).datasetFor("globalbioticinteractions/jsonld-template-dataset");
DatasetImporter importer = new StudyImporterFactoryImpl(null).createImporter(dataset);
assertThat(importer, is(notNullValue()));
assertThat(importer, is(instanceOf(DatasetImporterForJSONLD.class)));
}
use of org.globalbioticinteractions.dataset.DatasetRegistry in project eol-globi-data by jhpoelen.
the class DatasetImporterFactoryImplIT method createHafner.
@Test
public void createHafner() throws StudyImporterException, DatasetRegistryException, IOException {
final DatasetRegistry datasetRegistryGitHubRemote = new DatasetRegistryGitHubRemote(inStream -> inStream);
Dataset dataset = new DatasetFactory(datasetRegistryGitHubRemote).datasetFor("globalbioticinteractions/hafner");
DatasetImporter importer = new StudyImporterFactoryImpl(null).createImporter(dataset);
assertThat(importer, is(notNullValue()));
DatasetImporterForHafner haftnerImporter = (DatasetImporterForHafner) importer;
assertThat(haftnerImporter.getDataset().retrieve(URI.create("hafner/gopher_lice_int.csv")), is(notNullValue()));
}
use of org.globalbioticinteractions.dataset.DatasetRegistry 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.DatasetRegistry in project eol-globi-data by jhpoelen.
the class DatasetImporterFactoryImplIT method defaultTSVImporterNotCached.
@Test
public void defaultTSVImporterNotCached() throws StudyImporterException, DatasetRegistryException, IOException {
final DatasetRegistry datasetRegistry = new DatasetRegistryGitHubRemote(inStream -> inStream);
DatasetImporter importer = getTemplateImporter(datasetRegistry, "globalbioticinteractions/template-dataset");
assertThat(((DatasetImporterForTSV) importer).getBaseUrl(), startsWith("https://raw.githubusercontent.com/globalbioticinteractions/template-dataset/"));
InputStream actual = ((DatasetImporterForTSV) importer).getDataset().retrieve(URI.create("globi.json"));
assertThat(actual, is(notNullValue()));
}
use of org.globalbioticinteractions.dataset.DatasetRegistry 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();
}
Aggregations