2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.ebi;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertNull;
26 import org.testng.annotations.Test;
28 public class EBIFetchClientTest
31 * Test method that constructs URL to fetch from
33 @Test(groups = "Functional")
34 public void testBuildUrl()
39 assertEquals("http://www.ebi.ac.uk/ena/data/view/x53838&display=xml",
40 EBIFetchClient.buildUrl("X53838", "EMBL", "display=xml"));
45 assertEquals("http://www.ebi.ac.uk/ena/data/view/caa37824&display=xml",
46 EBIFetchClient.buildUrl("CAA37824", "EMBL", "display=xml"));
52 "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/uniprot/p00340/uniprotxml",
53 EBIFetchClient.buildUrl("P00340", "UNIPROT", "uniprotxml"));
58 assertEquals("http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/pdb",
59 EBIFetchClient.buildUrl("3A6S", "PDB", "pdb"));
65 "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/mmCIF",
66 EBIFetchClient.buildUrl("3A6S", "PDB", "mmCIF"));
70 * Test method that parses db:id;id;id
72 @Test(groups = "Functional")
73 public void testParseIds()
78 StringBuilder queries = new StringBuilder();
79 String db = EBIFetchClient.parseIds("pdb:3a6s;1A70", queries);
80 assertEquals("pdb", db);
81 assertEquals("3a6s,1A70", queries.toString());
84 * pdb specified on second accession
87 queries = new StringBuilder();
88 db = EBIFetchClient.parseIds("3a6s;pdb:1A70", queries);
89 assertEquals("pdb", db);
90 assertEquals("3a6s,1A70", queries.toString());
93 * uniprot, one accession
96 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
97 assertEquals("uniprot", db);
98 assertEquals("P00340", queries.toString());
101 * uniprot, one accession, appending to existing queries
103 queries.setLength(0);
104 queries.append("P30419");
105 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
106 assertEquals("uniprot", db);
107 assertEquals("P30419,P00340", queries.toString());
110 * pdb and uniprot mixed - rejected
112 queries.setLength(0);
113 db = EBIFetchClient.parseIds("pdb:3a6s;1a70;uniprot:P00340", queries);
115 assertEquals("3a6s,1a70", queries.toString());
118 * pdb and PDB mixed - ok
120 queries.setLength(0);
121 db = EBIFetchClient.parseIds("pdb:3a6s;pdb:1a70;PDB:1QIP", queries);
122 assertEquals("PDB", db);
123 assertEquals("3a6s,1a70,1QIP", queries.toString());
126 * no database (improper format)
128 queries.setLength(0);
129 db = EBIFetchClient.parseIds("P00340", queries);
131 assertEquals("P00340", queries.toString());