1 package jalview.fts.threedbeacons;
3 import static org.testng.AssertJUnit.assertTrue;
5 import java.util.ArrayList;
6 import java.util.Collection;
9 import org.testng.Assert;
10 import org.testng.annotations.AfterMethod;
11 import org.testng.annotations.BeforeClass;
12 import org.testng.annotations.BeforeMethod;
13 import org.testng.annotations.Test;
15 import jalview.fts.api.FTSDataColumnI;
16 import jalview.fts.core.FTSRestClient;
17 import jalview.fts.core.FTSRestRequest;
18 import jalview.fts.core.FTSRestResponse;
19 import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
20 import jalview.gui.JvOptionPane;
22 public class TDBeaconsFTSRestClientTest
24 @BeforeClass(alwaysRun = true)
25 public void setUpJvOptionPane()
27 JvOptionPane.setInteractiveMode(false);
28 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
31 private FTSRestClient ftsRestClient;
33 @BeforeMethod(alwaysRun = true)
34 public void setUp() throws Exception
36 ftsRestClient = new FTSRestClient()
40 public String getColumnDataConfigFileName()
42 return "/fts/tdbeacons_data_columns.txt";
46 public FTSRestResponse executeRequest(FTSRestRequest ftsRequest)
54 @AfterMethod(alwaysRun = true)
55 public void tearDown() throws Exception
60 public void getAllDefaulDisplayedDataColumns()
62 Assert.assertNotNull(ftsRestClient
63 .getAllDefaultDisplayedFTSDataColumns());
64 System.out.println(ftsRestClient.getAllDefaultDisplayedFTSDataColumns());
65 Assert.assertTrue(!ftsRestClient.getAllDefaultDisplayedFTSDataColumns()
67 Assert.assertEquals(ftsRestClient
68 .getAllDefaultDisplayedFTSDataColumns().size(), 3);
71 @Test(groups = { "Functional" })
72 public void getPrimaryKeyColumIndexTest()
74 Collection<FTSDataColumnI> wantedFields = ftsRestClient
75 .getAllDefaultDisplayedFTSDataColumns();
79 Assert.assertEquals(foundIndex, -1);
80 foundIndex = ftsRestClient.getPrimaryKeyColumIndex(wantedFields,
82 Assert.assertEquals(foundIndex, 0);
83 foundIndex = ftsRestClient
84 .getPrimaryKeyColumIndex(wantedFields, true);
85 Assert.assertEquals(foundIndex, 1);
89 Assert.fail("Exception thrown while testing...");
93 @Test(groups = { "External", "Network" })
94 public void executeRequestTest()
96 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
99 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
100 .getDataColumnByNameOrCode("model_category"));
101 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
102 .getDataColumnByNameOrCode("provider"));
103 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
104 .getDataColumnByNameOrCode("created"));
105 } catch (Exception e1)
107 e1.printStackTrace();
109 System.out.println("wantedFields >>" + wantedFields);
111 FTSRestRequest request = new FTSRestRequest();
112 //request.setAllowEmptySeq(false);
113 //request.setResponseSize(100);
114 request.setSearchTerm("01308.json");
115 request.setWantedFields(wantedFields);
116 System.out.println("request : " + request.getFieldToSearchBy());
117 System.out.println(request.toString());
119 FTSRestResponse response;
122 response = TDBeaconsFTSRestClient.getInstance().executeRequest(request);
123 } catch (Exception e)
126 Assert.fail("Couldn't execute webservice call!");
129 //assertTrue(response.getNumberOfItemsFound() > 99);
130 assertTrue(response.getSearchSummary() != null);
131 assertTrue(response.getSearchSummary().size() > 99);