Skip to content
Snippets Groups Projects
Commit d4f8828f authored by Christopher Schankula's avatar Christopher Schankula :earth_africa:
Browse files

error handling for nameToID

parent 6c63ed75
No related branches found
No related tags found
No related merge requests found
...@@ -2,13 +2,15 @@ package biotree; ...@@ -2,13 +2,15 @@ package biotree;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.io.IOException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class TestBioTree { public class TestBioTree {
@Before @Before
public static void main(String[] args) { public static void main(String[] args) throws IOException {
BioTree.init(); BioTree.init();
BioTree.processRecord(125125); BioTree.processRecord(125125);
BioTree.processRecord(125125); BioTree.processRecord(125125);
...@@ -29,6 +31,7 @@ public class TestBioTree { ...@@ -29,6 +31,7 @@ public class TestBioTree {
//System.out.println(String.format("%-26s %s", nodes.get(i).getName(), nodes.get(i).getTaxonType())); //System.out.println(String.format("%-26s %s", nodes.get(i).getName(), nodes.get(i).getTaxonType()));
//} //}
BioTree.printTree(); BioTree.printTree();
System.out.println(WormsAPI.nameToID("Hello"));
} }
......
...@@ -38,11 +38,11 @@ public class WormsAPI { ...@@ -38,11 +38,11 @@ public class WormsAPI {
* @return Aphia (taxon) ID of given scientific name. * @return Aphia (taxon) ID of given scientific name.
* @throws IOException * @throws IOException
*/ */
public static int nameToID(String scientificName) throws IOException { public static Integer nameToID(String scientificName) throws IOException {
scientificName = repSpaces(scientificName); scientificName = repSpaces(scientificName);
String resp = makeRequest( String resp = makeRequest(
String.format("http://marinespecies.org/rest/AphiaIDByName/%s?marine_only=false", scientificName)); String.format("http://marinespecies.org/rest/AphiaIDByName/%s?marine_only=false", scientificName));
if (resp.length() == 0) return null;
return Integer.parseInt(resp); return Integer.parseInt(resp);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment