import static org.testng.AssertJUnit.assertTrue;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import org.testng.Assert;
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;
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<FTSDataColumnI> 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<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
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;
assertTrue(response.getSearchSummary() != null);
assertTrue(response.getSearchSummary().size() > 99);
}
-
}