Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.ws.ebi

File EBIFetchClientTest.java

 

Code metrics

0
36
3
1
137
62
3
0.08
12
3
1

Classes

Class Line # Actions
EBIFetchClientTest 31 36 3 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.ws.ebi;
22   
23    import static org.testng.AssertJUnit.assertEquals;
24    import static org.testng.AssertJUnit.assertNull;
25   
26    import jalview.gui.JvOptionPane;
27   
28    import org.testng.annotations.BeforeClass;
29    import org.testng.annotations.Test;
30   
 
31    public class EBIFetchClientTest
32    {
33   
 
34  1 toggle @BeforeClass(alwaysRun = true)
35    public void setUpJvOptionPane()
36    {
37  1 JvOptionPane.setInteractiveMode(false);
38  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
39    }
40   
41    /**
42    * Test method that constructs URL to fetch from
43    */
 
44  1 toggle @Test(groups = "Functional")
45    public void testBuildUrl()
46    {
47    /*
48    * EMBL
49    */
50  1 assertEquals("https://www.ebi.ac.uk/ena/data/view/x53838&display=xml",
51    EBIFetchClient.buildUrl("X53838", "EMBL", "display=xml"));
52   
53    /*
54    * EMBLCDS
55    */
56  1 assertEquals("https://www.ebi.ac.uk/ena/data/view/caa37824&display=xml",
57    EBIFetchClient.buildUrl("CAA37824", "EMBL", "display=xml"));
58   
59    /*
60    * PDB / pdb
61    */
62  1 assertEquals("https://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/pdb",
63    EBIFetchClient.buildUrl("3A6S", "PDB", "pdb"));
64   
65    /*
66    * PDB / mmCIF
67    */
68  1 assertEquals(
69    "https://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/mmCIF",
70    EBIFetchClient.buildUrl("3A6S", "PDB", "mmCIF"));
71    }
72   
73    /**
74    * Test method that parses db:id;id;id
75    */
 
76  1 toggle @Test(groups = "Functional")
77    public void testParseIds()
78    {
79    /*
80    * pdb, two accessions
81    */
82  1 StringBuilder queries = new StringBuilder();
83  1 String db = EBIFetchClient.parseIds("pdb:3a6s;1A70", queries);
84  1 assertEquals("pdb", db);
85  1 assertEquals("3a6s,1A70", queries.toString());
86   
87    /*
88    * pdb specified on second accession
89    */
90  1 queries.setLength(0);
91  1 queries = new StringBuilder();
92  1 db = EBIFetchClient.parseIds("3a6s;pdb:1A70", queries);
93  1 assertEquals("pdb", db);
94  1 assertEquals("3a6s,1A70", queries.toString());
95   
96    /*
97    * uniprot, one accession
98    */
99  1 queries.setLength(0);
100  1 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
101  1 assertEquals("uniprot", db);
102  1 assertEquals("P00340", queries.toString());
103   
104    /*
105    * uniprot, one accession, appending to existing queries
106    */
107  1 queries.setLength(0);
108  1 queries.append("P30419");
109  1 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
110  1 assertEquals("uniprot", db);
111  1 assertEquals("P30419,P00340", queries.toString());
112   
113    /*
114    * pdb and uniprot mixed - rejected
115    */
116  1 queries.setLength(0);
117  1 db = EBIFetchClient.parseIds("pdb:3a6s;1a70;uniprot:P00340", queries);
118  1 assertNull(db);
119  1 assertEquals("3a6s,1a70", queries.toString());
120   
121    /*
122    * pdb and PDB mixed - ok
123    */
124  1 queries.setLength(0);
125  1 db = EBIFetchClient.parseIds("pdb:3a6s;pdb:1a70;PDB:1QIP", queries);
126  1 assertEquals("PDB", db);
127  1 assertEquals("3a6s,1a70,1QIP", queries.toString());
128   
129    /*
130    * no database (improper format)
131    */
132  1 queries.setLength(0);
133  1 db = EBIFetchClient.parseIds("P00340", queries);
134  1 assertNull(db);
135  1 assertEquals("P00340", queries.toString());
136    }
137    }