1 package jalview.ws.ebi;
3 import static org.testng.AssertJUnit.assertEquals;
4 import static org.testng.AssertJUnit.assertNull;
6 import org.testng.annotations.Test;
8 public class EBIFetchClientTest
11 * Test method that constructs URL to fetch from
13 @Test(groups = "Functional")
14 public void testBuildUrl()
19 assertEquals("http://www.ebi.ac.uk/ena/data/view/x53838&display=xml",
20 EBIFetchClient.buildUrl("X53838", "EMBL", "display=xml"));
25 assertEquals("http://www.ebi.ac.uk/ena/data/view/caa37824&display=xml",
26 EBIFetchClient.buildUrl("CAA37824", "EMBL", "display=xml"));
32 "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/uniprot/p00340/uniprotxml",
33 EBIFetchClient.buildUrl("P00340", "UNIPROT", "uniprotxml"));
38 assertEquals("http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/pdb",
39 EBIFetchClient.buildUrl("3A6S", "PDB", "pdb"));
45 "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/mmCIF",
46 EBIFetchClient.buildUrl("3A6S", "PDB", "mmCIF"));
50 * Test method that parses db:id;id;id
52 @Test(groups = "Functional")
53 public void testParseIds()
58 StringBuilder queries = new StringBuilder();
59 String db = EBIFetchClient.parseIds("pdb:3a6s;1A70", queries);
60 assertEquals("pdb", db);
61 assertEquals("3a6s,1A70", queries.toString());
64 * pdb specified on second accession
67 queries = new StringBuilder();
68 db = EBIFetchClient.parseIds("3a6s;pdb:1A70", queries);
69 assertEquals("pdb", db);
70 assertEquals("3a6s,1A70", queries.toString());
73 * uniprot, one accession
76 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
77 assertEquals("uniprot", db);
78 assertEquals("P00340", queries.toString());
81 * uniprot, one accession, appending to existing queries
84 queries.append("P30419");
85 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
86 assertEquals("uniprot", db);
87 assertEquals("P30419,P00340", queries.toString());
90 * pdb and uniprot mixed - rejected
93 db = EBIFetchClient.parseIds("pdb:3a6s;1a70;uniprot:P00340", queries);
95 assertEquals("3a6s,1a70", queries.toString());
98 * pdb and PDB mixed - ok
100 queries.setLength(0);
101 db = EBIFetchClient.parseIds("pdb:3a6s;pdb:1a70;PDB:1QIP", queries);
102 assertEquals("PDB", db);
103 assertEquals("3a6s,1a70,1QIP", queries.toString());
106 * no database (improper format)
108 queries.setLength(0);
109 db = EBIFetchClient.parseIds("P00340", queries);
111 assertEquals("P00340", queries.toString());