JAL-2485 JAL-2246 test Uniprot FTS summary
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 3 May 2017 09:43:52 +0000 (10:43 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 3 May 2017 09:43:52 +0000 (10:43 +0100)
test/jalview/ws/dbsources/RemoteFormatTest.java [new file with mode: 0644]

diff --git a/test/jalview/ws/dbsources/RemoteFormatTest.java b/test/jalview/ws/dbsources/RemoteFormatTest.java
new file mode 100644 (file)
index 0000000..a9cad80
--- /dev/null
@@ -0,0 +1,112 @@
+package jalview.ws.dbsources;
+
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
+import jalview.fts.api.FTSData;
+import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.api.FTSRestClientI;
+import jalview.fts.core.FTSRestRequest;
+import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.uniprot.UniProtFTSRestClient;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+/**
+ * A class to verify that remotely fetched data has an expected format and can
+ * be successfully processed by Jalview. This is intended as a first line of
+ * defence and early warning of service affecting changes to data fetched
+ * externally.
+ * <p>
+ * This is class is not intended to cover remote services e.g. alignment. Nor
+ * should it duplicate tests already provided by other classes (such as
+ * PDBFTSRestClientTest). Or maybe we will relocate those tests here...
+ */
+public class RemoteFormatTest
+{
+  @Test(groups = "Network")
+  public void testFetchUniprot()
+  {
+    // P00340
+  }
+
+  @Test(groups = "Network")
+  public void testFetchPdb()
+  {
+    // 1QIP
+  }
+
+  @Test(groups = "Network")
+  public void testFetchEmbl()
+  {
+    // X53828
+  }
+
+  @Test(groups = "Network")
+  public void testFetchEmblCDS()
+  {
+    // CAA37824
+  }
+
+  @Test(groups = "Network")
+  public void testFetchEnsembl()
+  {
+    // ENSG00000157764
+  }
+
+  @Test(groups = "Network")
+  public void testFetchEnsemblGenomes()
+  {
+    // DDB_G0283883
+  }
+
+  @Test(groups = "Network")
+  public void testFetchPfamSeed()
+  {
+    // PF03760
+  }
+
+  @Test(groups = "Network")
+  public void testFetchPfamFull()
+  {
+    // PF03760
+  }
+
+  @Test(groups = "Network")
+  public void testFetchRfamSeed()
+  {
+    // RF00014
+  }
+
+  @Test(groups = { "Network" })
+  public void testUniprotFreeTextSearch() throws Exception
+  {
+    List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
+    FTSRestClientI client = UniProtFTSRestClient.getInstance();
+    wantedFields.add(client.getDataColumnByNameOrCode("id"));
+    wantedFields.add(client.getDataColumnByNameOrCode("entry name"));
+    wantedFields.add(client.getDataColumnByNameOrCode("organism"));
+    wantedFields.add(client.getDataColumnByNameOrCode("reviewed")); // Status
+    wantedFields.add(client.getDataColumnByNameOrCode("length"));
+  
+    FTSRestRequest request = new FTSRestRequest();
+    request.setAllowEmptySeq(false);
+    request.setResponseSize(100);
+    request.setFieldToSearchBy("Search All");
+    request.setSearchTerm("metanephrops"); // lobster!
+    request.setWantedFields(wantedFields);
+  
+    FTSRestResponse response;
+    response = client.executeRequest(request);
+    assertTrue(response.getNumberOfItemsFound() > 20);
+    assertTrue(response.getSearchSummary() != null);
+    assertTrue(response.getSearchSummary().size() > 20);
+    // verify we successfully filtered out the header row (JAL-2485)
+    FTSData header = response.getSearchSummary().iterator().next();
+    assertFalse("Failed to filter out summary header row",
+            header.getSummaryData()[0].toString().equalsIgnoreCase("Entry"));
+  }
+}