Skip to content

Commit

Permalink
bump to globi libs v0.12.1; add tests for empty access.tsv
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpoelen committed Apr 26, 2019
1 parent 22b9808 commit cebfc7e
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<description>Discover, cache and check species interaction data</description>

<properties>
<globi.version>0.11.1</globi.version>
<globi.version>0.12.1</globi.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<project.build.testResourceEncoding>UTF-8</project.build.testResourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.globalbioticinteractions.elton.cmd;

import com.beust.jcommander.JCommander;
import org.junit.Assert;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.net.URISyntaxException;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.assertThat;

public class CmdInteractionsIT {

@Test
public void interactions() throws URISyntaxException {
JCommander jc = new CmdLine().buildCommander();
jc.parse("interactions",
"--cache-dir=/home/jorrit/proj/parasite-tracker/tmp");

Assert.assertEquals(jc.getParsedCommand(), "interactions");

JCommander actual = jc.getCommands().get(jc.getParsedCommand());
Assert.assertEquals(actual.getObjects().size(), 1);
Object cmd = actual.getObjects().get(0);
Assert.assertEquals(cmd.getClass(), CmdInteractions.class);
CmdInteractions cmdInteractions = (CmdInteractions) actual.getObjects().get(0);
assertThat(cmdInteractions.getNamespaces().size(), is(1));
// assertThat(cmdInteractions.getNamespaces(), hasItem("globalbioticinteractions/template-dataset"));

if (actual.getObjects().get(0) instanceof Runnable) {
ByteArrayOutputStream out1 = new ByteArrayOutputStream();
PrintStream out = new PrintStream(out1);
((CmdInteractions) actual.getObjects().get(0)).run(out);
assertThat(out1.toString(), startsWith("\tLeptoconchus incycloseris\t\t\t\t\thttp://purl.obolibrary.org/obo/RO_0002444\tparasiteOf\t\tFungia (Cycloseris) costulata\t\t\t\t\t\t\t\t\t\t10.1007/s13127-011-0039-1\thttps://doi.org/10.1007/s13127-011-0039-1\tGittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1\tglobalbioticinteractions/template-dataset\tJorrit H. Poelen. 2014. Species associations manually extracted from literature.\thttps://zenodo.org/record/207958/files/globalbioticinteractions/template-dataset-0.0.2.zip\t2017-09-19T17:01:39Z\t631d3777cf83e1abea848b59a6589c470cf0c7d0fd99682c4c104481ad9a543f\tdev\n"));
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,25 @@ public void namesWithHeader() throws URISyntaxException {
}
}

@Test
public void namesWithHeaderEmpty() throws URISyntaxException {
JCommander jc = new CmdLine().buildCommander();
jc.parse("names",
"--cache-dir=" + CmdTestUtil.cacheDirTestFor("/dataset-cache-empty/globalbioticinteractions/template-dataset/access.tsv"));

JCommander actual = jc.getCommands().get(jc.getParsedCommand());

if (actual.getObjects().get(0) instanceof Runnable) {
ByteArrayOutputStream out1 = new ByteArrayOutputStream();
PrintStream out = new PrintStream(out1);
((CmdNames) actual.getObjects().get(0)).run(out);
String actualOutput = out1.toString();
String[] actualLines = StringUtils.splitByWholeSeparator(actualOutput, "\n");
assertThat(actualLines[0], is("taxonId\ttaxonName\ttaxonRank\ttaxonPath\ttaxonPathIds\ttaxonPathNames\tnamespace\tcitation\tarchiveURI\tlastSeenAt\tcontentHash\teltonVersion"));
assertThat(actualLines[1], is("\tLeptoconchus incycloseris\t\t\t\t\tglobalbioticinteractions/template-dataset\tJorrit H. Poelen. 2014. Species associations manually extracted from literature.\thttps://zenodo.org/record/207958/files/globalbioticinteractions/template-dataset-0.0.2.zip\t2017-09-19T17:01:39Z\t631d3777cf83e1abea848b59a6589c470cf0c7d0fd99682c4c104481ad9a543f\tdev"));
assertThat(actualLines[1].split("\t").length, is(actualLines[0].split("\t").length));
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

final class CmdTestUtil {
static String cacheDirTest() throws URISyntaxException {
URL accessURL = CmdNamesTest.class.getResource("/dataset-cache-test/globalbioticinteractions/template-dataset/access.tsv");
String name = "/dataset-cache-test/globalbioticinteractions/template-dataset/access.tsv";
return cacheDirTestFor(name);
}

static String cacheDirTestFor(String name) throws URISyntaxException {
URL accessURL = CmdNamesTest.class.getResource(name);
assertThat(accessURL, is(notNullValue()));
return new File(accessURL.toURI()).getParentFile().getParentFile().getParentFile().getAbsolutePath();
}
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_comment": "Sample GloBI dataset descriptor. See http://github.com/globalbioticinteractions for more information.",
"citation": "Jorrit H. Poelen. 2014. Species associations manually extracted from literature."
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
globalbioticinteractions/template-dataset https://zenodo.org/record/207958/files/globalbioticinteractions/template-dataset-0.0.2.zip 2017-09-19T17:01:39Z application/globi
globalbioticinteractions/template-dataset https://zenodo.org/record/207958/files/globalbioticinteractions/template-dataset-0.0.2.zip 631d3777cf83e1abea848b59a6589c470cf0c7d0fd99682c4c104481ad9a543f 2017-09-19T17:01:39Z
globalbioticinteractions/template-dataset jar:file:/home/jorrit/proj/globi/globinizer/./datasets/globalbioticinteractions/template-dataset/631d3777cf83e1abea848b59a6589c470cf0c7d0fd99682c4c104481ad9a543f!/globalbioticinteractions-template-dataset-e68f448/globi.json 1cc8eff62af0e6bb3e7771666e2e4109f351b7dfc6fc1dc8314e5671a8eecb80 2017-09-19T17:01:39Z
globalbioticinteractions/template-dataset jar:file:/home/jorrit/proj/globi/globinizer/./datasets/globalbioticinteractions/template-dataset/631d3777cf83e1abea848b59a6589c470cf0c7d0fd99682c4c104481ad9a543f!/globalbioticinteractions-template-dataset-e68f448/interactions.tsv c1b37add5ee5f30916f19811c59c2960e3b68ecf1a3846afe1776014c4c96271 2017-09-19T17:01:39Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sourceTaxonId sourceTaxonName interactionTypeId interactionTypeName targetTaxonId targetTaxonName localityId localityName decimalLatitude decimalLongitude observationDateTime referenceDoi referenceCitation
Leptoconchus incycloseris RO:0002444 parasite of Fungia (Cycloseris) costulata doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus infungites RO:0002444 parasite of Fungia (Fungia) fungites doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus ingrandifungi RO:0002444 parasite of Sandalolitha dentata doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus ingranulosa RO:0002444 parasite of Fungia (Wellsofungia) granulosa doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus inlimax RO:0002444 parasite of Herpolitha limax doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus inpileus RO:0002444 parasite of Halomitra pileus doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus inpleuractis RO:0002444 parasite of Fungia (Pleuractis) gravis doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus inpleuractis RO:0002444 parasite of Fungia (Pleuractis) moluccensis doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus inpleuractis RO:0002444 parasite of Fungia (Pleuractis) paumotensis doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus massini RO:0002444 parasite of Fungia (Verrillofungia) concinna doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1
Leptoconchus massini RO:0002444 parasite of Fungia (Verrillofungia) repanda doi:10.1007/s13127-011-0039-1 Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1

0 comments on commit cebfc7e

Please sign in to comment.