X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Ffts%2Fthreedbeacons%2FTDBeaconsFTSRestClientTest.java;fp=test%2Fjalview%2Ffts%2Fthreedbeacons%2FTDBeaconsFTSRestClientTest.java;h=3c0d61647a83af8eb6d7fb542d62ce032efd92fe;hb=f640efee12150d1ae174c64c936f4630716cb7c4;hp=be7622296073a1fa232359b36bd954239e1ed470;hpb=fff909498fd8b1c6150b02afcd56dbccc2571c04;p=jalview.git diff --git a/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java b/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java index be76222..3c0d616 100644 --- a/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java +++ b/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java @@ -3,6 +3,7 @@ package jalview.fts.threedbeacons; import static org.testng.AssertJUnit.assertTrue; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import org.testng.Assert; @@ -12,6 +13,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import jalview.fts.api.FTSDataColumnI; +import jalview.fts.core.FTSRestClient; import jalview.fts.core.FTSRestRequest; import jalview.fts.core.FTSRestResponse; import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient; @@ -25,37 +27,93 @@ public class TDBeaconsFTSRestClientTest JvOptionPane.setInteractiveMode(false); JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); } + + private FTSRestClient ftsRestClient; @BeforeMethod(alwaysRun = true) public void setUp() throws Exception { + ftsRestClient = new FTSRestClient() + { + + @Override + public String getColumnDataConfigFileName() + { + return "/fts/tdbeacons_data_columns.txt"; + } + + @Override + public FTSRestResponse executeRequest(FTSRestRequest ftsRequest) + throws Exception + { + return null; + } + }; } @AfterMethod(alwaysRun = true) public void tearDown() throws Exception { } - - @Test(groups = { "External", "Network" }) + @Test + public void getAllDefaulDisplayedDataColumns() + { + Assert.assertNotNull(ftsRestClient + .getAllDefaultDisplayedFTSDataColumns()); + System.out.println(ftsRestClient.getAllDefaultDisplayedFTSDataColumns()); + Assert.assertTrue(!ftsRestClient.getAllDefaultDisplayedFTSDataColumns() + .isEmpty()); + Assert.assertEquals(ftsRestClient + .getAllDefaultDisplayedFTSDataColumns().size(), 3); + } + + @Test(groups = { "Functional" }) + public void getPrimaryKeyColumIndexTest() + { + Collection wantedFields = ftsRestClient + .getAllDefaultDisplayedFTSDataColumns(); + int foundIndex = -1; + try + { + Assert.assertEquals(foundIndex, -1); + foundIndex = ftsRestClient.getPrimaryKeyColumIndex(wantedFields, + false); + Assert.assertEquals(foundIndex, 0); + foundIndex = ftsRestClient + .getPrimaryKeyColumIndex(wantedFields, true); + Assert.assertEquals(foundIndex, 1); + } catch (Exception e) + { + e.printStackTrace(); + Assert.fail("Exception thrown while testing..."); + } + } + + @Test(groups = { "External", "Network" }) public void executeRequestTest() { List wantedFields = new ArrayList(); try { wantedFields.add(TDBeaconsFTSRestClient.getInstance() - .getDataColumnByNameOrCode("uniprot_entry")); + .getDataColumnByNameOrCode("model_category")); + wantedFields.add(TDBeaconsFTSRestClient.getInstance() + .getDataColumnByNameOrCode("provider")); + wantedFields.add(TDBeaconsFTSRestClient.getInstance() + .getDataColumnByNameOrCode("created")); } catch (Exception e1) { e1.printStackTrace(); } - System.out.println(wantedFields); + System.out.println("wantedFields >>" + wantedFields); FTSRestRequest request = new FTSRestRequest(); //request.setAllowEmptySeq(false); //request.setResponseSize(100); request.setSearchTerm("01308.json"); - //request.setWantedFields(wantedFields); + request.setWantedFields(wantedFields); + System.out.println("request : " + request.getFieldToSearchBy()); System.out.println(request.toString()); FTSRestResponse response; @@ -72,5 +130,4 @@ public class TDBeaconsFTSRestClientTest assertTrue(response.getSearchSummary() != null); assertTrue(response.getSearchSummary().size() > 99); } - }