JAL-1238 test to see if the primary Uniprot source is placed first in list of Uniprot...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 18 Jan 2013 15:56:36 +0000 (15:56 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 18 Jan 2013 15:56:36 +0000 (15:56 +0000)
test/jalview/ws/seqfetcher/DbRefFetcherTest.java [new file with mode: 0644]

diff --git a/test/jalview/ws/seqfetcher/DbRefFetcherTest.java b/test/jalview/ws/seqfetcher/DbRefFetcherTest.java
new file mode 100644 (file)
index 0000000..2f826b3
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+ * 
+ */
+package jalview.ws.seqfetcher;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import jalview.datamodel.DBRefSource;
+import jalview.ws.DBRefFetcher;
+import jalview.ws.SequenceFetcher;
+import jalview.ws.dbsources.das.api.jalviewSourceI;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author jimp
+ *
+ */
+public class DbRefFetcherTest
+{
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception
+  {
+  }
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception
+  {
+  }
+
+  @Test
+  public void testStandardProtDbs()
+  {
+    String[] defdb = DBRefSource.PROTEINDBS;
+  List<DbSourceProxy> srces = new ArrayList<DbSourceProxy>();
+  for (String ddb : defdb)
+  {
+    SequenceFetcher sfetcher= new SequenceFetcher();
+    List<DbSourceProxy> srcesfordb = sfetcher.getSourceProxy(ddb);
+    
+    if (srcesfordb != null)
+    {
+      srces.addAll(srcesfordb);
+    }
+  }
+  DbSourceProxy uniprot=null;
+  int i=0;
+  // append the selected sequence sources to the default dbs
+  for (DbSourceProxy s:srces)
+  {
+    if (s.getDbSource().equalsIgnoreCase(DBRefSource.UNIPROT))
+    {
+      i++;
+    }
+    
+    if (s instanceof jalview.ws.dbsources.Uniprot)
+    {
+      uniprot = s;
+      break;
+    }
+  }
+          
+  assertTrue("Failed to find Uniprot source as first source amongst "+srces.size()+" sources (source was at position "+i+")", uniprot!=null && i<2);
+  }
+
+}