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 jalview.gui.JvOptionPane;
28 import org.testng.annotations.BeforeClass;
29 import org.testng.annotations.Test;
31 public class EBIFetchClientTest
34 @BeforeClass(alwaysRun = true)
35 public void setUpJvOptionPane()
37 JvOptionPane.setInteractiveMode(false);
38 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
42 * Test method that constructs URL to fetch from
44 @Test(groups = "Functional")
45 public void testBuildUrl()
50 assertEquals("http://www.ebi.ac.uk/ena/data/view/x53838&display=xml",
51 EBIFetchClient.buildUrl("X53838", "EMBL", "display=xml"));
56 assertEquals("http://www.ebi.ac.uk/ena/data/view/caa37824&display=xml",
57 EBIFetchClient.buildUrl("CAA37824", "EMBL", "display=xml"));
63 "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/uniprot/p00340/uniprotxml",
64 EBIFetchClient.buildUrl("P00340", "UNIPROT", "uniprotxml"));
69 assertEquals("http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/pdb",
70 EBIFetchClient.buildUrl("3A6S", "PDB", "pdb"));
76 "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/mmCIF",
77 EBIFetchClient.buildUrl("3A6S", "PDB", "mmCIF"));
81 * Test method that parses db:id;id;id
83 @Test(groups = "Functional")
84 public void testParseIds()
89 StringBuilder queries = new StringBuilder();
90 String db = EBIFetchClient.parseIds("pdb:3a6s;1A70", queries);
91 assertEquals("pdb", db);
92 assertEquals("3a6s,1A70", queries.toString());
95 * pdb specified on second accession
98 queries = new StringBuilder();
99 db = EBIFetchClient.parseIds("3a6s;pdb:1A70", queries);
100 assertEquals("pdb", db);
101 assertEquals("3a6s,1A70", queries.toString());
104 * uniprot, one accession
106 queries.setLength(0);
107 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
108 assertEquals("uniprot", db);
109 assertEquals("P00340", queries.toString());
112 * uniprot, one accession, appending to existing queries
114 queries.setLength(0);
115 queries.append("P30419");
116 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
117 assertEquals("uniprot", db);
118 assertEquals("P30419,P00340", queries.toString());
121 * pdb and uniprot mixed - rejected
123 queries.setLength(0);
124 db = EBIFetchClient.parseIds("pdb:3a6s;1a70;uniprot:P00340", queries);
126 assertEquals("3a6s,1a70", queries.toString());
129 * pdb and PDB mixed - ok
131 queries.setLength(0);
132 db = EBIFetchClient.parseIds("pdb:3a6s;pdb:1a70;PDB:1QIP", queries);
133 assertEquals("PDB", db);
134 assertEquals("3a6s,1a70,1QIP", queries.toString());
137 * no database (improper format)
139 queries.setLength(0);
140 db = EBIFetchClient.parseIds("P00340", queries);
142 assertEquals("P00340", queries.toString());