Added (and passed !)all the FTS tests from test.fts.core
authorArnaldo <arnaud.gucciardi@gmail.com>
Thu, 25 Mar 2021 14:47:13 +0000 (15:47 +0100)
committerArnaldo <arnaud.gucciardi@gmail.com>
Thu, 25 Mar 2021 14:47:13 +0000 (15:47 +0100)
test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java

index 3c0d616..fad7750 100644 (file)
@@ -4,7 +4,9 @@ import static org.testng.AssertJUnit.assertTrue;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
@@ -13,6 +15,7 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI;
 import jalview.fts.core.FTSRestClient;
 import jalview.fts.core.FTSRestRequest;
 import jalview.fts.core.FTSRestResponse;
@@ -66,6 +69,7 @@ public class TDBeaconsFTSRestClientTest
             .isEmpty());
     Assert.assertEquals(ftsRestClient
             .getAllDefaultDisplayedFTSDataColumns().size(), 3);
+    // currently 3, may change -> change this test and the nexts accordingly
   }
   
   @Test(groups = { "Functional" })
@@ -90,6 +94,151 @@ public class TDBeaconsFTSRestClientTest
     }
   }
   
+  @Test(groups = { "Functional" })
+  public void getDataColumnsFieldsAsCommaDelimitedString()
+  {
+    Collection<FTSDataColumnI> wantedFields = ftsRestClient
+            .getAllDefaultDisplayedFTSDataColumns();
+    String actual = ftsRestClient
+            .getDataColumnsFieldsAsCommaDelimitedString(wantedFields);
+    Assert.assertEquals(actual,
+            "id,uniprot_accession,entry name");
+  }
+  
+  @Test(groups = { "Functional" })
+  public void getAllFTSDataColumns()
+  {
+    Collection<FTSDataColumnI> allFields = ftsRestClient
+            .getAllFTSDataColumns();
+    Assert.assertNotNull(allFields);
+    //System.out.println(allFields.size());
+    Assert.assertEquals(allFields.size(), 3);
+  }
+  
+  @Test(groups = { "Functional" })
+  public void getSearchableDataColumns()
+  {
+    Collection<FTSDataColumnI> searchableFields = ftsRestClient
+            .getSearchableDataColumns();
+    Assert.assertNotNull(searchableFields);
+    //System.out.println(searchableFields.size());
+    Assert.assertEquals(searchableFields.size(), 1); //only 1, as of first 3DB test
+  }
+  
+  @Test(groups = { "Functional" })
+  public void getPrimaryKeyColumn()
+  {
+    FTSDataColumnI expectedPKColumn;
+    try
+    {
+      expectedPKColumn = ftsRestClient
+              .getDataColumnByNameOrCode("Uniprot Id");
+      Assert.assertNotNull(ftsRestClient.getPrimaryKeyColumn());
+      Assert.assertEquals(ftsRestClient.getPrimaryKeyColumn(),
+              expectedPKColumn);
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+      Assert.fail("Exception thrown while testing...");
+    }
+  }
+  
+  @Test(groups = { "Functional" })
+  public void getDataColumnByNameOrCode()
+  {
+    try
+    {
+      FTSDataColumnI foundDataCol = ftsRestClient
+              .getDataColumnByNameOrCode("uniprot_accession");
+      Assert.assertNotNull(foundDataCol);
+      Assert.assertEquals(foundDataCol.getName(), "UniProt Accession");
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+      Assert.fail("Exception thrown while testing...");
+    }
+  }
+  
+  @Test(groups = { "Functional" })
+  public void getDataColumnGroupById()
+  {
+    FTSDataColumnGroupI foundDataColGroup;
+    try
+    {
+      foundDataColGroup = ftsRestClient.getDataColumnGroupById("g2");
+      Assert.assertNotNull(foundDataColGroup);
+      Assert.assertEquals(foundDataColGroup.getName(), "Name");
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+  }
+  
+  @Test(groups = { "Functional" })
+  public void getDefaultResponsePageSize()
+  {
+    int defaultResSize = ftsRestClient.getDefaultResponsePageSize();
+    Assert.assertEquals(defaultResSize, 100); //why 100 or 500 ? pdb is 100, uniprot 500
+  }
+  
+  @Test(groups = { "Functional" })
+  public void getColumnMinWidthTest()
+  {
+    try
+    {
+      FTSDataColumnI foundDataCol = ftsRestClient
+              .getDataColumnByNameOrCode("uniprot_accession");
+      Assert.assertNotNull(foundDataCol);
+      int actualColMinWidth = foundDataCol.getMinWidth();
+      Assert.assertEquals(actualColMinWidth, 50);
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+      Assert.fail("Exception thrown while testing...");
+    }
+  }
+  // could add test for MaxWidth & PreferedWith
+  
+  @Test(groups = { "Functional" })
+  public void getColumnClassTest()
+  {
+    try
+    {
+      FTSDataColumnI foundDataCol = ftsRestClient
+              .getDataColumnByNameOrCode("uniprot_accession");
+      Assert.assertNotNull(foundDataCol);
+      Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(),
+              String.class);
+      foundDataCol = ftsRestClient.getDataColumnByNameOrCode("id");
+      Assert.assertNotNull(foundDataCol);
+      Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(),
+              String.class);
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+      Assert.fail("Exception thrown while testing...");
+    }
+  }
+  
+  @Test(groups = { "Functional" })
+  public void coverageForEqualsAndHashFunction()
+  {
+    Set<FTSDataColumnI> uniqueSet = new HashSet<FTSDataColumnI>();
+    Collection<FTSDataColumnI> searchableCols = ftsRestClient
+            .getSearchableDataColumns();
+    System.out.println(searchableCols);
+    for (FTSDataColumnI foundCol : searchableCols)
+    {
+      System.out.println(foundCol.toString());
+      uniqueSet.add(foundCol);
+      uniqueSet.add(foundCol);
+    }
+    Assert.assertTrue(!uniqueSet.isEmpty());
+    //Assert.assertEquals(uniqueSet.size(), 22); -> 1 or 2 currently for 3DB
+  }
+  
+  
+  
   @Test(groups = { "External", "Network" })  
   public void executeRequestTest()
   {