JAL-3446 unused imports removed
[jalview.git] / test / jalview / fts / service / pdb / PDBFTSPanelTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.fts.service.pdb;
22
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertTrue;
25
26 import javax.swing.JInternalFrame;
27
28 import org.testng.annotations.AfterMethod;
29 import org.testng.annotations.BeforeClass;
30 import org.testng.annotations.BeforeMethod;
31 import org.testng.annotations.Test;
32
33 import jalview.gui.JvOptionPane;
34 import junit.extensions.PA;
35
36 public class PDBFTSPanelTest
37 {
38
39   @BeforeClass(alwaysRun = true)
40   public void setUpJvOptionPane()
41   {
42     JvOptionPane.setInteractiveMode(false);
43     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
44   }
45
46   @BeforeMethod(alwaysRun = true)
47   public void setUp() throws Exception
48   {
49   }
50
51   @AfterMethod(alwaysRun = true)
52   public void tearDown() throws Exception
53   {
54   }
55
56   @Test(groups = { "Functional" })
57   public void populateCmbSearchTargetOptionsTest()
58   {
59     PDBFTSPanel searchPanel = new PDBFTSPanel(null);
60     assertTrue(searchPanel.getCmbSearchTarget().getItemCount() > 0);
61     searchPanel.populateCmbSearchTargetOptions();
62   }
63
64   @Test(groups = { "Functional" })
65   public void testDecodeSearchTerm()
66   {
67     String expectedString = "1xyz OR text:2xyz OR text:3xyz";
68     String outcome = PDBFTSPanel.decodeSearchTerm("1xyz:A;2xyz;3xyz",
69             "text");
70     // System.out.println("1 >>>>>>>>>>> " + outcome);
71     assertEquals(expectedString, outcome);
72
73     expectedString = "1xyz";
74     outcome = PDBFTSPanel.decodeSearchTerm("1xyz", "text");
75     // System.out.println("2 >>>>>>>>>>> " + outcome);
76     assertEquals(expectedString, outcome);
77   }
78
79   @Test(groups = { "Functional" })
80   public void testgetPDBIdwithSpecifiedChain()
81   {
82
83     String expectedString = "1xyz:A";
84     String outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("1xyz",
85             "2xyz;3xyz;1xyz:A");
86     System.out.println("1 >>>>>>>>>>> " + outcome);
87     assertEquals(expectedString, outcome);
88
89     expectedString = "2xyz";
90     outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("2xyz",
91             "1xyz:A;2xyz;3xyz");
92     System.out.println("2 >>>>>>>>>>> " + outcome);
93     assertEquals(expectedString, outcome);
94
95     expectedString = "2xyz:A";
96     outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("2xyz", "2xyz:A");
97     System.out.println("3 >>>>>>>>>>> " + outcome);
98     assertEquals(expectedString, outcome);
99   }
100
101   @Test(groups = { "External" }, timeOut = 8000)
102   public void txt_search_ActionPerformedTest()
103   {
104     PDBFTSPanel searchPanel = new PDBFTSPanel(null);
105     JInternalFrame mainFrame = searchPanel.getMainFrame();
106 //    JComboBox<String> txt_search = PA.gsearchPanel.getTxtSearch();
107
108     assertTrue(mainFrame.getTitle().length() == 20);
109     assertTrue(mainFrame.getTitle()
110             .equalsIgnoreCase("PDB Sequence Fetcher"));
111     PA.invokeMethod(PA.getValue(searchPanel, "txt_search"), "setSelectedItem(java.lang.String)", "ABC");
112   //  txt_search.setSelectedItem("ABC");
113     try
114     {
115       // wait for web-service to handle response
116       Thread.sleep(3000);
117     } catch (InterruptedException e)
118     {
119       e.printStackTrace();
120     }
121     assertTrue(mainFrame.getTitle().length() > 20);
122     assertTrue(!mainFrame.getTitle().equalsIgnoreCase(
123             "PDB Sequence Fetcher"));
124   }
125
126 }