TDB.executeRequest fix & test passed
authorArnaldo <arnaud.gucciardi@gmail.com>
Thu, 25 Mar 2021 15:49:48 +0000 (16:49 +0100)
committerArnaldo <arnaud.gucciardi@gmail.com>
Thu, 25 Mar 2021 15:49:48 +0000 (16:49 +0100)
src/jalview/fts/core/FTSRestResponse.java
src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java
test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java

index a5c8705..66db2a0 100644 (file)
@@ -42,7 +42,7 @@ public class FTSRestResponse
 {
   private int numberOfItemsFound;
   
-  private int sequenceLength;
+  private Long sequenceLength;
 
   private String responseTime;
 
@@ -78,12 +78,12 @@ public class FTSRestResponse
     this.searchSummary = searchSummary;
   }
   
-  public int getSequenceLength() {
+  public long getSequenceLength() {
     return sequenceLength;
   }
   
-  public void setSequenceLength(int sequenceLength) {
-    this.sequenceLength = sequenceLength;
+  public void setSequenceLength(Long seqLength) {
+    this.sequenceLength = seqLength;
   }
 
   /**
index e6d45e5..b6be709 100644 (file)
@@ -75,13 +75,13 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
         clientResponseClass = ClientResponse.class;
       }
       WebResource webResource;
-      webResource = client.resource(DEFAULT_THREEDBEACONS_DOMAIN)
-              .queryParam("ac", query);
+      webResource = client.resource(DEFAULT_THREEDBEACONS_DOMAIN).path(query);
+      URI uri = webResource.getURI();
+//              .queryParam("P", query);
 //              .queryParam("rows", String.valueOf(responseSize))
 //              .queryParam("P",query);
-      URI uri = webResource.getURI();
-        
-      System.out.println(uri);
+//      URI uri = webResource.getURI();
+      System.out.println(uri.toString());
         
       // Execute the REST request
       ClientResponse clientResponse = webResource
@@ -92,7 +92,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
       Map<String, Object> jsonObj = null;
       String responseString = null;
   
-      System.out.println("query >>>>>>> " + tdbRestRequest.toString());
+      //System.out.println("query >>>>>>> " + tdbRestRequest.toString());
         
       // Check the response status and report exception if one occurs
       int responseStatus = clientResponse.getStatus();
@@ -140,8 +140,8 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
       
   }
   
-  public String setSearchTerm() {
-    return null;
+  public String setSearchTerm(String term) {
+    return term;
   }
   
   public static FTSRestResponse parseTDBeaconsJsonResponse(
@@ -169,7 +169,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
       //String seqLength = tdbEntry.get("sequence_length").toString();
       //int seqLength = Integer.valueOf(tdbEntry.get("sequence_length").toString());
       
-      int seqLength = (int) ((Map<String, Object>) jsonObj.get("uniprot_entry")).get("sequence_length");
+      Long seqLength = (Long) ((Map<String, Object>) jsonObj.get("uniprot_entry")).get("sequence_length");
       result = new ArrayList<>();
       List<Object> structures = (List<Object>) jsonObj.get("structures");
       int numFound = 0;
@@ -304,8 +304,7 @@ private static FTSData getFTSData(Map<String, Object> tdbJsonStructure,
   @Override
   public String getColumnDataConfigFileName()
   {
-    // TODO Auto-generated method stub
-    return null;
+    return "/fts/tdbeacons_data_columns.txt";
   }
   
   public static FTSRestClientI getInstance()
index fad7750..fe1f3bc 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.fts.threedbeacons;
 
+import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertTrue;
 
 import java.util.ArrayList;
@@ -19,6 +20,7 @@ import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI;
 import jalview.fts.core.FTSRestClient;
 import jalview.fts.core.FTSRestRequest;
 import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.pdb.PDBFTSRestClient;
 import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
 import jalview.gui.JvOptionPane;
 
@@ -237,8 +239,36 @@ public class TDBeaconsFTSRestClientTest
     //Assert.assertEquals(uniqueSet.size(), 22); -> 1 or 2 currently for 3DB
   }
   
+  @Test(groups = { "Functional" })
+  public void getTDBIdColumIndexTest()
+  {
+    List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
+    try
+    {
+      wantedFields.add(TDBeaconsFTSRestClient.getInstance()
+              .getDataColumnByNameOrCode("id"));
+      wantedFields.add(TDBeaconsFTSRestClient.getInstance()
+              .getDataColumnByNameOrCode("uniprot_accession"));
+      wantedFields.add(TDBeaconsFTSRestClient.getInstance()
+              .getDataColumnByNameOrCode("entry name"));
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+    try
+    {
+      assertEquals(1, PDBFTSRestClient.getInstance()
+              .getPrimaryKeyColumIndex(wantedFields, true));
+//      assertEquals(4, PDBFTSRestClient.getInstance()
+//              .getPrimaryKeyColumIndex(wantedFields, false));
+    } catch (Exception e)
+    {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+  }
   
-  
+
   @Test(groups = { "External", "Network" })  
   public void executeRequestTest()
   {
@@ -246,11 +276,11 @@ public class TDBeaconsFTSRestClientTest
     try
     {
       wantedFields.add(TDBeaconsFTSRestClient.getInstance()
-              .getDataColumnByNameOrCode("model_category"));
+              .getDataColumnByNameOrCode("id"));
       wantedFields.add(TDBeaconsFTSRestClient.getInstance()
-              .getDataColumnByNameOrCode("provider"));
+              .getDataColumnByNameOrCode("uniprot_accession"));
       wantedFields.add(TDBeaconsFTSRestClient.getInstance()
-              .getDataColumnByNameOrCode("created"));
+              .getDataColumnByNameOrCode("entry name"));
     } catch (Exception e1)
     {
       e1.printStackTrace();
@@ -258,8 +288,8 @@ public class TDBeaconsFTSRestClientTest
     System.out.println("wantedFields >>" + wantedFields);
 
     FTSRestRequest request = new FTSRestRequest();
-    //request.setAllowEmptySeq(false);
-    //request.setResponseSize(100);
+    request.setResponseSize(100);
+    request.setFieldToSearchBy("P");
     request.setSearchTerm("01308.json");
     request.setWantedFields(wantedFields);
     System.out.println("request : " + request.getFieldToSearchBy());
@@ -275,8 +305,8 @@ public class TDBeaconsFTSRestClientTest
       Assert.fail("Couldn't execute webservice call!");
       return;
     }
-    //assertTrue(response.getNumberOfItemsFound() > 99);
     assertTrue(response.getSearchSummary() != null);
-    assertTrue(response.getSearchSummary().size() > 99);
+    assertTrue(response.getNumberOfItemsFound() > 99);
+    System.out.println(response.getSearchSummary().size());
   }
 }