Search in sources :

Example 41 with Dataset

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

the class DatasetImporterForRSSTest method readRSS.

@Test
public void readRSS() throws StudyImporterException, IOException {
    final Dataset dataset = getDatasetGroup();
    List<Dataset> datasets = DatasetImporterForRSS.getDatasetsForFeed(dataset);
    assertThat(datasets.size(), is(3));
    assertThat(datasets.get(0).getOrDefault("hasDependencies", null), is("false"));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) Test(org.junit.Test)

Example 42 with Dataset

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

the class DatasetImporterForRSSTest method readFieldMuseum.

@Test
public void readFieldMuseum() throws StudyImporterException, IOException {
    String configJson = "{ \"url\": \"classpath:/org/eol/globi/data/rss_fieldmuseum.xml\" }";
    final Dataset dataset = datasetFor(configJson);
    List<Dataset> datasets = DatasetImporterForRSS.getDatasetsForFeed(dataset);
    assertThat(datasets.size(), is(14));
    assertThat(datasets.get(0).getOrDefault("hasDependencies", null), is("false"));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 43 with Dataset

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

the class DatasetImporterForRSSTest method titleIncludePatternOnly.

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

Example 44 with Dataset

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

the class DatasetImporterForRSSTest method embeddedDatasetWithConfig.

@Test
public void embeddedDatasetWithConfig() throws IOException {
    Dataset embeddedDataset = embeddedDatasetFor(getDatasetGroupWithProperty(), URI.create("http://example.com/archive.zip"));
    assertThat(embeddedDataset.getCitation(), is("some other citation"));
    assertThat(embeddedDataset.getOrDefault(DatasetConstant.SHOULD_RESOLVE_REFERENCES, "true"), is("false"));
    assertThat(embeddedDataset.getArchiveURI().toString(), is("http://example.com/archive.zip"));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) Test(org.junit.Test)

Example 45 with Dataset

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

the class DatasetImporterForTSVTest method withGenus.

@Test
public void withGenus() throws StudyImporterException {
    String firstFewLines = "sourceTaxonFamily\tsourceTaxonGenus\tinteractionTypeId\ttargetTaxonName\n" + "Bacillaceae\tBacillus\tRO:0002454\tMorus alba\n";
    Dataset dataset = getDataset(new TreeMap<URI, String>() {

        {
            put(URI.create("/interactions.tsv"), firstFewLines);
        }
    });
    DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
    importer.setDataset(dataset);
    importStudy(importer);
    Taxon taxon = taxonIndex.findTaxonByName("Bacillus");
    assertThat(taxon, is(notNullValue()));
    assertThat(taxon.getName(), is("Bacillus"));
    assertThat(taxon.getPath(), is("Bacillaceae | Bacillus"));
    assertThat(taxon.getPathNames(), is("family | genus"));
    final List<StudyNode> allStudies = NodeUtil.findAllStudies(getGraphDb());
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) Taxon(org.eol.globi.domain.Taxon) URI(java.net.URI) StudyNode(org.eol.globi.domain.StudyNode) 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