use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class TableInteractionListenerProxyTest method interactionListenerTest.
@Test
public void interactionListenerTest() throws IOException, StudyImporterException {
final List<Map<String, String>> links = new ArrayList<Map<String, String>>();
JsonNode config = new ObjectMapper().readTree("{ \"dcterms:bibliographicCitation\":\"some citation\", \"url\":\"https://example.org/someResource\" }");
DatasetImpl dataset = new DatasetImpl(null, URI.create("http://someurl"), inStream -> inStream);
dataset.setConfig(config);
final TableInteractionListenerProxy listener = new TableInteractionListenerProxy(dataset, new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
links.add(interaction);
}
});
listener.on(new HashMap<>());
assertThat(links.size(), is(1));
assertThat(links.get(0).get(DatasetImporterForTSV.DATASET_CITATION), startsWith("some citation. Accessed at <https://example.org/someResource> on "));
assertThat(links.get(0).get(DatasetImporterForTSV.REFERENCE_CITATION), startsWith("some citation. Accessed at <https://example.org/someResource> on "));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class TableInteractionListenerProxyTest method interactionListener2Test.
@Test
public void interactionListener2Test() throws IOException, StudyImporterException {
final List<Map<String, String>> links = new ArrayList<Map<String, String>>();
JsonNode config = new ObjectMapper().readTree("{ \"dcterms:bibliographicCitation\":\"some citation\", \"url\":\"https://example.org/someResource\" }");
DatasetImpl dataset = new DatasetImpl(null, URI.create("http://someurl"), inStream -> inStream);
dataset.setConfig(config);
final TableInteractionListenerProxy listener = new TableInteractionListenerProxy(dataset, new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
links.add(interaction);
}
});
listener.on(new HashMap<String, String>() {
{
put(DatasetImporterForTSV.REFERENCE_CITATION, "some ref");
}
});
assertThat(links.size(), is(1));
assertThat(links.get(0).get(DatasetImporterForTSV.DATASET_CITATION), startsWith("some citation. Accessed at <https://example.org/someResource> on "));
assertThat(links.get(0).get(DatasetImporterForTSV.REFERENCE_CITATION), startsWith("some ref"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetTest method unknownResourceURL.
@Test(expected = IOException.class)
public void unknownResourceURL() 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);
assertThat(dataset.retrieve(URI.create("archivezz.zip")), is(notNullValue()));
}
Aggregations