Clover icon

jalviewX

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

File EnsemblXrefTest.java

 

Code metrics

0
17
3
1
85
52
3
0.18
5.67
3
1

Classes

Class Line # Actions
EnsemblXrefTest 38 17 3 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

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.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   
29    import java.io.BufferedReader;
30    import java.io.IOException;
31    import java.io.StringReader;
32    import java.net.URL;
33    import java.util.List;
34   
35    import org.testng.annotations.BeforeClass;
36    import org.testng.annotations.Test;
37   
 
38    public class EnsemblXrefTest
39    {
40   
 
41  1 toggle @BeforeClass(alwaysRun = true)
42    public void setUpJvOptionPane()
43    {
44  1 JvOptionPane.setInteractiveMode(false);
45  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
46    }
47   
48    //@formatter:off
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    //@formatter:on
54   
 
55  1 toggle @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    {
 
64  1 toggle @Override
65    protected BufferedReader getHttpResponse(URL url, List<String> ids)
66    throws IOException
67    {
68  1 return new BufferedReader(new StringReader(JSON));
69    }
70    };
71   
72    // synonyms and GO terms are not returned
73  1 List<DBRefEntry> dbrefs = testee.getCrossReferences("ABCDE");
74  1 assertEquals(2, dbrefs.size());
75  1 assertEquals("CCDS", dbrefs.get(0).getSource());
76  1 assertEquals("CCDS5863", dbrefs.get(0).getAccessionId());
77  1 assertFalse(dbrefs.get(0).isPrimaryCandidate());
78  1 assertEquals(dbName + ":" + dbVers, dbrefs.get(0).getVersion());
79    // Uniprot name should get converted to Jalview canonical form
80  1 assertEquals("UNIPROT", dbrefs.get(1).getSource());
81  1 assertEquals("P15056", dbrefs.get(1).getAccessionId());
82  1 assertEquals(dbName + ":" + dbVers, dbrefs.get(1).getVersion());
83  1 assertFalse(dbrefs.get(1).isPrimaryCandidate());
84    }
85    }