JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / test / jalview / gui / PDBSearchPanelTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
3  * Copyright (C) 2015 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.gui;
22
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertTrue;
25
26 import javax.swing.JInternalFrame;
27 import javax.swing.JTextField;
28
29 import org.testng.annotations.AfterMethod;
30 import org.testng.annotations.BeforeMethod;
31 import org.testng.annotations.Test;
32
33 public class PDBSearchPanelTest
34 {
35
36   @BeforeMethod(alwaysRun = true)
37   public void setUp() throws Exception
38   {
39   }
40
41   @AfterMethod
42   public void tearDown() throws Exception
43   {
44   }
45
46   @Test(groups = { "Functional" })
47   public void populateCmbSearchTargetOptionsTest()
48   {
49     PDBSearchPanel searchPanel = new PDBSearchPanel(null);
50     assertTrue(searchPanel.getCmbSearchTarget().getItemCount() > 0);
51     searchPanel.populateCmbSearchTargetOptions();
52   }
53
54   @Test(groups = { "Functional" })
55   public void testDecodeSearchTerm()
56   {
57     String expectedString = "1xyz OR text:2xyz OR text:3xyz";
58     String outcome = PDBSearchPanel.decodeSearchTerm("1xyz:A;2xyz;3xyz",
59             "text");
60     // System.out.println("1 >>>>>>>>>>> " + outcome);
61     assertEquals(expectedString, outcome);
62
63     expectedString = "1xyz";
64     outcome = PDBSearchPanel.decodeSearchTerm("1xyz", "text");
65     // System.out.println("2 >>>>>>>>>>> " + outcome);
66     assertEquals(expectedString, outcome);
67   }
68
69   @Test(groups = { "Functional" })
70   public void testgetPDBIdwithSpecifiedChain()
71   {
72
73     String expectedString = "1xyz:A";
74     String outcome = PDBSearchPanel.getPDBIdwithSpecifiedChain("1xyz",
75             "2xyz;3xyz;1xyz:A");
76     System.out.println("1 >>>>>>>>>>> " + outcome);
77     assertEquals(expectedString, outcome);
78
79     expectedString = "2xyz";
80     outcome = PDBSearchPanel.getPDBIdwithSpecifiedChain("2xyz",
81             "1xyz:A;2xyz;3xyz");
82     System.out.println("2 >>>>>>>>>>> " + outcome);
83     assertEquals(expectedString, outcome);
84
85     expectedString = "2xyz:A";
86     outcome = PDBSearchPanel.getPDBIdwithSpecifiedChain("2xyz", "2xyz:A");
87     System.out.println("3 >>>>>>>>>>> " + outcome);
88     assertEquals(expectedString, outcome);
89   }
90
91   @Test(groups = { "Network", "External" }, timeOut = 5000)
92   public void txt_search_ActionPerformedTest()
93   {
94     PDBSearchPanel searchPanel = new PDBSearchPanel(null);
95     JInternalFrame mainFrame = searchPanel.getMainFrame();
96     JTextField txt_search = searchPanel.getTxtSearch();
97
98     assertTrue(mainFrame.getTitle().length() == 20);
99     assertTrue(mainFrame.getTitle()
100             .equalsIgnoreCase("PDB Sequence Fetcher"));
101
102     txt_search.setText("ABC");
103
104     assertTrue(mainFrame.getTitle().length() > 20);
105     assertTrue(!mainFrame.getTitle().equalsIgnoreCase(
106             "PDB Sequence Fetcher"));
107   }
108
109 }