Search in sources :

Example 21 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class DatasetImporterForZenodoMetadataIT method importStudy.

@Test
public void importStudy() throws IOException, StudyImporterException {
    List<Map<String, String>> links = new ArrayList<>();
    final DatasetImporterForZenodoMetadata importer = new DatasetImporterForZenodoMetadata(null, null);
    importer.setInteractionListener(new InteractionListener() {

        @Override
        public void on(Map<String, String> interaction) throws StudyImporterException {
            links.add(interaction);
        }
    });
    final DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:archive"), in -> in) {

        @Override
        public String getOrDefault(String key, String defaultValue) {
            return "https://sandbox.zenodo.org/api/records/?custom=%5Bobo%3ARO_0002453%5D%3A%5B%3A%5D";
        }
    };
    importer.setDataset(dataset);
    importer.importStudy();
    assertThat(links.size() > 0, Is.is(true));
}
Also used : InteractionListener(org.eol.globi.process.InteractionListener) ArrayList(java.util.ArrayList) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Map(java.util.Map) Test(org.junit.Test)

Example 22 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class ReferenceUtilTest method sourceCitationDatasetLocalResourceNonURI.

@Test
public void sourceCitationDatasetLocalResourceNonURI() throws IOException {
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example"), inStream -> inStream);
    JsonNode config = new ObjectMapper().readTree("{ \"url\": \"foo bar\" }");
    dataset.setConfig(config);
    String citation = CitationUtil.sourceCitationLastAccessed(dataset);
    assertThat(citation, startsWith("<http://example>. Accessed at <http://example> on"));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 23 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class ReferenceUtilTest method generateSourceCitation.

@Test
public void generateSourceCitation() throws IOException, StudyImporterException {
    final InputStream inputStream = getClass().getResourceAsStream("/org/eol/globi/data/test-meta-globi.json");
    DatasetImpl dataset = new DatasetImpl(null, URI.create("http://base"), inStream -> inStream);
    dataset.setConfig(new ObjectMapper().readTree(inputStream));
    String citation = CitationUtil.sourceCitationLastAccessed(dataset);
    assertThat(citation, startsWith("Seltzer, Carrie; Wysocki, William; Palacios, Melissa; Eickhoff, Anna; Pilla, Hannah; Aungst, Jordan; Mercer, Aaron; Quicho, Jamie; Voss, Neil; Xu, Man; J. Ndangalasi, Henry; C. Lovett, Jon; J. Cordeiro, Norbert (2015): Plant-animal interactions from Africa. figshare. https://dx.doi.org/10.6084/m9.figshare.1526128. Accessed at <https://ndownloader.figshare.com/files/2231424>"));
}
Also used : InputStream(java.io.InputStream) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 24 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class ReferenceUtilTest method sourceCitationDatasetNoConfig.

@Test
public void sourceCitationDatasetNoConfig() {
    String citation = CitationUtil.sourceCitationLastAccessed(new DatasetImpl("some/namespace", URI.create("http://example"), inStream -> inStream));
    assertThat(citation, startsWith("<http://example>. Accessed at <http://example> on"));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) CitationUtil(org.globalbioticinteractions.dataset.CitationUtil) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) IOException(java.io.IOException) HashMap(java.util.HashMap) StringEndsWith.endsWith(org.hamcrest.core.StringEndsWith.endsWith) Is(org.hamcrest.core.Is) JsonNode(com.fasterxml.jackson.databind.JsonNode) URI(java.net.URI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) StringStartsWith.startsWith(org.hamcrest.core.StringStartsWith.startsWith) InputStream(java.io.InputStream) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Test(org.junit.Test)

Example 25 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class ReferenceUtilTest method sourceCitationDataset.

@Test
public void sourceCitationDataset() throws IOException {
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example"), inStream -> inStream);
    JsonNode config = new ObjectMapper().readTree("{ \"resources\": { \"archive\": \"archive.zip\" } }");
    dataset.setConfig(config);
    String citation = CitationUtil.sourceCitationLastAccessed(dataset);
    assertThat(citation, startsWith("<http://example>. Accessed at <http://example> on"));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)83 Test (org.junit.Test)73 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)50 URI (java.net.URI)32 JsonNode (com.fasterxml.jackson.databind.JsonNode)31 Dataset (org.globalbioticinteractions.dataset.Dataset)25 ArrayList (java.util.ArrayList)22 IOException (java.io.IOException)21 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)21 InteractionListener (org.eol.globi.process.InteractionListener)19 URL (java.net.URL)18 Map (java.util.Map)17 StudyNode (org.eol.globi.domain.StudyNode)17 HashMap (java.util.HashMap)16 Is.is (org.hamcrest.core.Is.is)16 List (java.util.List)15 StudyImpl (org.eol.globi.domain.StudyImpl)15 StringUtils (org.apache.commons.lang3.StringUtils)14 CoreMatchers.nullValue (org.hamcrest.CoreMatchers.nullValue)14 Is (org.hamcrest.core.Is)14