1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ext.ensembl; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
|
26 |
|
import jalview.datamodel.DBRefEntry; |
27 |
|
import jalview.gui.JvOptionPane; |
28 |
|
import jalview.util.JSONUtils; |
29 |
|
|
30 |
|
import java.io.IOException; |
31 |
|
import java.net.URL; |
32 |
|
import java.util.List; |
33 |
|
|
34 |
|
import org.json.simple.parser.ParseException; |
35 |
|
import org.testng.annotations.BeforeClass; |
36 |
|
import org.testng.annotations.Test; |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 3 |
Complexity Density: 0.18 |
|
38 |
|
public class EnsemblXrefTest |
39 |
|
{ |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
41 |
1 |
@BeforeClass(alwaysRun = true)... |
42 |
|
public void setUpJvOptionPane() |
43 |
|
{ |
44 |
1 |
JvOptionPane.setInteractiveMode(false); |
45 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
|
private static final String JSON = |
50 |
|
"[{\"primary_id\":\"CCDS5863\",\"dbname\":\"CCDS\"}," + |
51 |
|
"{\"primary_id\":\"P15056\",\"dbname\":\"Uniprot/SWISSPROT\",\"synonyms\":[\"C21\"]}," + |
52 |
|
"{\"primary_id\":\"GO:0000165\",\"dbname\":\"GO\"}]"; |
53 |
|
|
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
55 |
1 |
@Test(groups = "Functional")... |
56 |
|
public void testGetCrossReferences() |
57 |
|
{ |
58 |
1 |
String dbName = "ENSEMBL"; |
59 |
1 |
String dbVers = "0.6.2b1"; |
60 |
1 |
System.out.println(JSON); |
61 |
1 |
EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org", dbName, |
62 |
|
dbVers) |
63 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
1 |
@SuppressWarnings("unchecked")... |
65 |
|
@Override |
66 |
|
protected Object getJSON(URL url, List<String> ids, int msDelay, |
67 |
|
int mode, String mapKey) throws IOException, ParseException |
68 |
|
{ |
69 |
1 |
return ((List<Object>) JSONUtils.parse(JSON)).iterator(); |
70 |
|
} |
71 |
|
|
72 |
|
}; |
73 |
|
|
74 |
|
|
75 |
1 |
List<DBRefEntry> dbrefs = testee.getCrossReferences("ABCDE"); |
76 |
1 |
assertEquals(2, dbrefs.size()); |
77 |
1 |
assertEquals("CCDS", dbrefs.get(0).getSource()); |
78 |
1 |
assertEquals("CCDS5863", dbrefs.get(0).getAccessionId()); |
79 |
1 |
assertFalse(dbrefs.get(0).isPrimaryCandidate()); |
80 |
1 |
assertEquals(dbName + ":" + dbVers, dbrefs.get(0).getVersion()); |
81 |
|
|
82 |
1 |
assertEquals("UNIPROT", dbrefs.get(1).getSource()); |
83 |
1 |
assertEquals("P15056", dbrefs.get(1).getAccessionId()); |
84 |
1 |
assertEquals(dbName + ":" + dbVers, dbrefs.get(1).getVersion()); |
85 |
1 |
assertFalse(dbrefs.get(1).isPrimaryCandidate()); |
86 |
|
} |
87 |
|
} |