JAL-1517 fix copyright for 2.8.2
[jalview.git] / test / jalview / ws / seqfetcher / DbRefFetcherTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3  * Copyright (C) 2014 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.seqfetcher;
22
23 import static org.junit.Assert.*;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28 import jalview.datamodel.DBRefSource;
29 import jalview.ws.DBRefFetcher;
30 import jalview.ws.SequenceFetcher;
31 import jalview.ws.dbsources.das.api.jalviewSourceI;
32
33 import org.junit.AfterClass;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36
37 /**
38  * @author jimp
39  *
40  */
41 public class DbRefFetcherTest
42 {
43
44   /**
45    * @throws java.lang.Exception
46    */
47   @BeforeClass
48   public static void setUpBeforeClass() throws Exception
49   {
50   }
51
52   /**
53    * @throws java.lang.Exception
54    */
55   @AfterClass
56   public static void tearDownAfterClass() throws Exception
57   {
58   }
59
60   @Test
61   public void testStandardProtDbs()
62   {
63     String[] defdb = DBRefSource.PROTEINDBS;
64   List<DbSourceProxy> srces = new ArrayList<DbSourceProxy>();
65   for (String ddb : defdb)
66   {
67     SequenceFetcher sfetcher= new SequenceFetcher();
68     List<DbSourceProxy> srcesfordb = sfetcher.getSourceProxy(ddb);
69     
70     if (srcesfordb != null)
71     {
72       srces.addAll(srcesfordb);
73     }
74   }
75   DbSourceProxy uniprot=null;
76   int i=0;
77   // append the selected sequence sources to the default dbs
78   for (DbSourceProxy s:srces)
79   {
80     if (s.getDbSource().equalsIgnoreCase(DBRefSource.UNIPROT))
81     {
82       i++;
83     }
84     
85     if (s instanceof jalview.ws.dbsources.Uniprot)
86     {
87       uniprot = s;
88       break;
89     }
90   }
91           
92   assertTrue("Failed to find Uniprot source as first source amongst "+srces.size()+" sources (source was at position "+i+")", uniprot!=null && i<2);
93   }
94
95 }