Adding tests for 3DB, currently 2/4 corrects on PanelTest
[jalview.git] / test / jalview / fts / threedbeacons / TDBeaconsFTSRestClientTest.java
1 package jalview.fts.threedbeacons;
2
3 import static org.testng.AssertJUnit.assertTrue;
4
5 import java.util.ArrayList;
6 import java.util.List;
7
8 import org.testng.Assert;
9 import org.testng.annotations.AfterMethod;
10 import org.testng.annotations.BeforeClass;
11 import org.testng.annotations.BeforeMethod;
12 import org.testng.annotations.Test;
13
14 import jalview.fts.api.FTSDataColumnI;
15 import jalview.fts.core.FTSRestRequest;
16 import jalview.fts.core.FTSRestResponse;
17 import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
18 import jalview.gui.JvOptionPane;
19
20 public class TDBeaconsFTSRestClientTest
21 {
22   @BeforeClass(alwaysRun = true)
23   public void setUpJvOptionPane()
24   {
25     JvOptionPane.setInteractiveMode(false);
26     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
27   }
28
29   @BeforeMethod(alwaysRun = true)
30   public void setUp() throws Exception
31   {
32   }
33
34   @AfterMethod(alwaysRun = true)
35   public void tearDown() throws Exception
36   {
37   }
38
39   @Test(groups = { "External", "Network" })
40   
41   public void executeRequestTest()
42   {
43     List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
44     try
45     {
46       wantedFields.add(TDBeaconsFTSRestClient.getInstance()
47               .getDataColumnByNameOrCode("uniprot_entry"));
48     } catch (Exception e1)
49     {
50       e1.printStackTrace();
51     }
52     System.out.println(wantedFields);
53
54     FTSRestRequest request = new FTSRestRequest();
55     //request.setAllowEmptySeq(false);
56     //request.setResponseSize(100);
57     request.setSearchTerm("01308.json");
58     //request.setWantedFields(wantedFields);
59     System.out.println(request.toString());
60
61     FTSRestResponse response;
62     try
63     {
64       response = TDBeaconsFTSRestClient.getInstance().executeRequest(request);
65     } catch (Exception e)
66     {
67       e.printStackTrace();
68       Assert.fail("Couldn't execute webservice call!");
69       return;
70     }
71     //assertTrue(response.getNumberOfItemsFound() > 99);
72     assertTrue(response.getSearchSummary() != null);
73     assertTrue(response.getSearchSummary().size() > 99);
74   }
75
76 }