Search in sources :

Example 6 with Dataset

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

the class DatasetImporterForRSSTest method titleExcludePatternOnly.

@Test
public void titleExcludePatternOnly() throws StudyImporterException, IOException {
    String configJson = "{ \"url\": \"classpath:/org/eol/globi/data/rss_vertnet.xml\", " + "\"exclude\": \".*GGBN.*\", " + "\"hasDependencies\": true }";
    final Dataset dataset = datasetFor(configJson);
    assertFalse(DatasetImporterForRSS.shouldIncludeTitleInDatasetCollection("bla (Arctos) GGBN", dataset));
    assertTrue(DatasetImporterForRSS.shouldIncludeTitleInDatasetCollection("bla (Arctos)", dataset));
    assertTrue(DatasetImporterForRSS.shouldIncludeTitleInDatasetCollection("bla", dataset));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 7 with Dataset

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

the class DatasetImporterForRSSTest method readRSSVertnet.

@Test
public void readRSSVertnet() throws StudyImporterException, IOException {
    String configJson = "{ \"url\": \"classpath:/org/eol/globi/data/rss_vertnet.xml\", " + "\"include\": \".*(Arctos).*\", " + "\"exclude\": \".*GGBN.*\", " + "\"hasDependencies\": true }";
    final Dataset dataset = datasetFor(configJson);
    List<Dataset> datasets = DatasetImporterForRSS.getDatasetsForFeed(dataset);
    for (Dataset dataset1 : datasets) {
        assertThat(dataset1.getCitation(), containsString("(Arctos)"));
        assertThat(dataset1.getCitation(), not(containsString("GGBN")));
    }
    assertThat(datasets.size(), is(84));
    assertThat(datasets.get(0).getOrDefault("hasDependencies", null), is("true"));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 8 with Dataset

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

the class DatasetImporterForRSSTest method readDatasetDependencies.

@Test
public void readDatasetDependencies() throws StudyImporterException, IOException {
    String configJson = "{ \"url\": \"classpath:/org/eol/globi/data/rss_msb_para.xml\", " + "\"hasDependencies\": true }";
    final Dataset dataset = datasetFor(configJson);
    List<Dataset> datasets = DatasetImporterForRSS.getDatasets(dataset);
    assertThat(datasets.size(), is(1));
    List<Dataset> dependencies = DatasetImporterForRSS.getDependencies(dataset);
    assertThat(dependencies.size(), is(2));
    assertThat(dependencies.get(0).getArchiveURI().toString(), is("http://ipt.vertnet.org:8080/ipt/archive.do?r=msb_para"));
    assertThat(dependencies.get(0).getFormat(), is("application/dwca"));
    assertThat(dependencies.get(1).getArchiveURI().toString(), is("http://ipt.vertnet.org:8080/ipt/archive.do?r=msb_host"));
    assertThat(dependencies.get(1).getFormat(), is("foo"));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 9 with Dataset

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

the class NodeFactoryWithDatasetContextTest method getOrCreateStudyEmptyStudySource.

@Test
public void getOrCreateStudyEmptyStudySource() throws NodeFactoryException {
    NodeFactory factory = Mockito.mock(NodeFactory.class);
    Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
    NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
    factoryWithDS.getOrCreateStudy(new StudyImpl("some title"));
    ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
    verify(factory).getOrCreateStudy(argument.capture());
    assertEquals("some title", argument.getValue().getTitle());
}
Also used : Study(org.eol.globi.domain.Study) Dataset(org.globalbioticinteractions.dataset.Dataset) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Test(org.junit.Test)

Example 10 with Dataset

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

the class NodeFactoryWithDatasetContextTest method getOrCreateStudy.

@Test
public void getOrCreateStudy() throws NodeFactoryException {
    NodeFactory factory = Mockito.mock(NodeFactory.class);
    Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
    NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
    factoryWithDS.getOrCreateStudy(new StudyImpl("some title"));
    ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
    verify(factory).getOrCreateStudy(argument.capture());
    assertEquals("some title", argument.getValue().getTitle());
    String sourceCitation = CitationUtil.sourceCitationLastAccessed(dataset);
    assertThat(StringUtils.contains(sourceCitation, "<some:uri>. Accessed at <some:uri> on"), Is.is(true));
}
Also used : Study(org.eol.globi.domain.Study) Dataset(org.globalbioticinteractions.dataset.Dataset) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Test(org.junit.Test)

Aggregations

Dataset (org.globalbioticinteractions.dataset.Dataset)68 Test (org.junit.Test)46 DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)25 URI (java.net.URI)20 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)17 JsonNode (com.fasterxml.jackson.databind.JsonNode)14 Matchers.containsString (org.hamcrest.Matchers.containsString)14 IOException (java.io.IOException)11 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)10 InputStream (java.io.InputStream)9 Is.is (org.hamcrest.core.Is.is)9 StudyNode (org.eol.globi.domain.StudyNode)8 Node (org.neo4j.graphdb.Node)8 URL (java.net.URL)7 ArrayList (java.util.ArrayList)7 StringStartsWith.startsWith (org.hamcrest.core.StringStartsWith.startsWith)7 Assert.assertNotNull (org.junit.Assert.assertNotNull)7 BaseDatasetImporter (org.eol.globi.data.BaseDatasetImporter)6 DatasetImporter (org.eol.globi.data.DatasetImporter)6 DatasetNode (org.eol.globi.domain.DatasetNode)6