Adding tests for 3DB, currently 2/4 corrects on PanelTest
[jalview.git] / test / jalview / fts / threedbeacons / TDBeaconsFTSRestClientTest.java
diff --git a/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java b/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java
new file mode 100644 (file)
index 0000000..be76222
--- /dev/null
@@ -0,0 +1,76 @@
+package jalview.fts.threedbeacons;
+
+import static org.testng.AssertJUnit.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.core.FTSRestRequest;
+import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
+import jalview.gui.JvOptionPane;
+
+public class TDBeaconsFTSRestClientTest
+{
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
+  @BeforeMethod(alwaysRun = true)
+  public void setUp() throws Exception
+  {
+  }
+
+  @AfterMethod(alwaysRun = true)
+  public void tearDown() throws Exception
+  {
+  }
+
+  @Test(groups = { "External", "Network" })
+  
+  public void executeRequestTest()
+  {
+    List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
+    try
+    {
+      wantedFields.add(TDBeaconsFTSRestClient.getInstance()
+              .getDataColumnByNameOrCode("uniprot_entry"));
+    } catch (Exception e1)
+    {
+      e1.printStackTrace();
+    }
+    System.out.println(wantedFields);
+
+    FTSRestRequest request = new FTSRestRequest();
+    //request.setAllowEmptySeq(false);
+    //request.setResponseSize(100);
+    request.setSearchTerm("01308.json");
+    //request.setWantedFields(wantedFields);
+    System.out.println(request.toString());
+
+    FTSRestResponse response;
+    try
+    {
+      response = TDBeaconsFTSRestClient.getInstance().executeRequest(request);
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+      Assert.fail("Couldn't execute webservice call!");
+      return;
+    }
+    //assertTrue(response.getNumberOfItemsFound() > 99);
+    assertTrue(response.getSearchSummary() != null);
+    assertTrue(response.getSearchSummary().size() > 99);
+  }
+
+}