Created 3Dbeacons data_columns.txt Test passed for data columns
[jalview.git] / test / jalview / fts / threedbeacons / TDBeaconsFTSRestClientTest.java
index be76222..3c0d616 100644 (file)
@@ -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<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;
@@ -72,5 +130,4 @@ public class TDBeaconsFTSRestClientTest
     assertTrue(response.getSearchSummary() != null);
     assertTrue(response.getSearchSummary().size() > 99);
   }
-
 }