Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package jalview.ws.ebi

File EBIFetchClientTest.java

 

Code metrics

0
36
3
1
139
64
3
0.08
12
3
1

Classes

Class Line # Actions
EBIFetchClientTest 31 36 3
0.00%
 

Contributing tests

No tests hitting this source file were found.

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  0 toggle @BeforeClass(alwaysRun = true)
35    public void setUpJvOptionPane()
36    {
37  0 JvOptionPane.setInteractiveMode(false);
38  0 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
39    }
40   
41    /**
42    * Test method that constructs URL to fetch from
43    */
 
44  0 toggle @Test(groups = "Functional")
45    public void testBuildUrl()
46    {
47    /*
48    * EMBL
49    */
50  0 assertEquals(
51    "https://www.ebi.ac.uk/ena/browser/api/embl/x53838?download=true&gzip=true",
52    EBIFetchClient.buildUrl("X53838", "EMBL", "display=xml"));
53   
54    /*
55    * EMBLCDS
56    */
57  0 assertEquals(
58    "https://www.ebi.ac.uk/ena/browser/api/embl/caa37824?download=true&gzip=true",
59    EBIFetchClient.buildUrl("CAA37824", "EMBL", "display=xml"));
60   
61    /*
62    * PDB / pdb
63    */
64  0 assertEquals("https://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/pdb",
65    EBIFetchClient.buildUrl("3A6S", "PDB", "pdb"));
66   
67    /*
68    * PDB / mmCIF
69    */
70  0 assertEquals(
71    "https://www.ebi.ac.uk/Tools/dbfetch/dbfetch/pdb/3a6s/mmCIF",
72    EBIFetchClient.buildUrl("3A6S", "PDB", "mmCIF"));
73    }
74   
75    /**
76    * Test method that parses db:id;id;id
77    */
 
78  0 toggle @Test(groups = "Functional")
79    public void testParseIds()
80    {
81    /*
82    * pdb, two accessions
83    */
84  0 StringBuilder queries = new StringBuilder();
85  0 String db = EBIFetchClient.parseIds("pdb:3a6s;1A70", queries);
86  0 assertEquals("pdb", db);
87  0 assertEquals("3a6s,1A70", queries.toString());
88   
89    /*
90    * pdb specified on second accession
91    */
92  0 queries.setLength(0);
93  0 queries = new StringBuilder();
94  0 db = EBIFetchClient.parseIds("3a6s;pdb:1A70", queries);
95  0 assertEquals("pdb", db);
96  0 assertEquals("3a6s,1A70", queries.toString());
97   
98    /*
99    * uniprot, one accession
100    */
101  0 queries.setLength(0);
102  0 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
103  0 assertEquals("uniprot", db);
104  0 assertEquals("P00340", queries.toString());
105   
106    /*
107    * uniprot, one accession, appending to existing queries
108    */
109  0 queries.setLength(0);
110  0 queries.append("P30419");
111  0 db = EBIFetchClient.parseIds("uniprot:P00340", queries);
112  0 assertEquals("uniprot", db);
113  0 assertEquals("P30419,P00340", queries.toString());
114   
115    /*
116    * pdb and uniprot mixed - rejected
117    */
118  0 queries.setLength(0);
119  0 db = EBIFetchClient.parseIds("pdb:3a6s;1a70;uniprot:P00340", queries);
120  0 assertNull(db);
121  0 assertEquals("3a6s,1a70", queries.toString());
122   
123    /*
124    * pdb and PDB mixed - ok
125    */
126  0 queries.setLength(0);
127  0 db = EBIFetchClient.parseIds("pdb:3a6s;pdb:1a70;PDB:1QIP", queries);
128  0 assertEquals("PDB", db);
129  0 assertEquals("3a6s,1a70,1QIP", queries.toString());
130   
131    /*
132    * no database (improper format)
133    */
134  0 queries.setLength(0);
135  0 db = EBIFetchClient.parseIds("P00340", queries);
136  0 assertNull(db);
137  0 assertEquals("P00340", queries.toString());
138    }
139    }