From 278ab3940ed405ca90993ebaf117f43a4e8aec26 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 3 May 2017 10:43:52 +0100 Subject: [PATCH] JAL-2485 JAL-2246 test Uniprot FTS summary --- test/jalview/ws/dbsources/RemoteFormatTest.java | 112 +++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 test/jalview/ws/dbsources/RemoteFormatTest.java diff --git a/test/jalview/ws/dbsources/RemoteFormatTest.java b/test/jalview/ws/dbsources/RemoteFormatTest.java new file mode 100644 index 0000000..a9cad80 --- /dev/null +++ b/test/jalview/ws/dbsources/RemoteFormatTest.java @@ -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. + *

+ * 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 wantedFields = new ArrayList(); + 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")); + } +} -- 1.7.10.2