Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.fts.service.pdb

File PDBFTSPanelTest.java

 

Code metrics

0
33
7
1
128
84
8
0.24
4.71
7
1.14

Classes

Class Line # Actions
PDBFTSPanelTest 38 33 8 11
0.72572.5%
 

Contributing tests

This file is covered by 3 tests. .

Source view

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 jalview.gui.JvOptionPane;
27   
28    import javax.swing.JComboBox;
29    import javax.swing.JInternalFrame;
30   
31    import org.testng.annotations.AfterMethod;
32    import org.testng.annotations.BeforeClass;
33    import org.testng.annotations.BeforeMethod;
34    import org.testng.annotations.Test;
35   
36    import junit.extensions.PA;
37   
 
38    public class PDBFTSPanelTest
39    {
40   
 
41  1 toggle @BeforeClass(alwaysRun = true)
42    public void setUpJvOptionPane()
43    {
44  1 JvOptionPane.setInteractiveMode(false);
45  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
46    }
47   
 
48  3 toggle @BeforeMethod(alwaysRun = true)
49    public void setUp() throws Exception
50    {
51    }
52   
 
53  3 toggle @AfterMethod(alwaysRun = true)
54    public void tearDown() throws Exception
55    {
56    }
57   
 
58  1 toggle @Test(groups = { "Functional" })
59    public void populateCmbSearchTargetOptionsTest()
60    {
61  1 PDBFTSPanel searchPanel = new PDBFTSPanel(null);
62  1 assertTrue(searchPanel.getCmbSearchTarget().getItemCount() > 0);
63  1 searchPanel.populateCmbSearchTargetOptions();
64    }
65   
 
66  1 toggle @Test(groups = { "Functional" })
67    public void testDecodeSearchTerm()
68    {
69  1 String expectedString = "1xyz OR text:2xyz OR text:3xyz";
70  1 String outcome = PDBFTSPanel.decodeSearchTerm("1xyz:A;2xyz;3xyz",
71    "text");
72    // System.out.println("1 >>>>>>>>>>> " + outcome);
73  1 assertEquals(expectedString, outcome);
74   
75  1 expectedString = "1xyz";
76  1 outcome = PDBFTSPanel.decodeSearchTerm("1xyz", "text");
77    // System.out.println("2 >>>>>>>>>>> " + outcome);
78  1 assertEquals(expectedString, outcome);
79    }
80   
 
81  1 toggle @Test(groups = { "Functional" })
82    public void testgetPDBIdwithSpecifiedChain()
83    {
84   
85  1 String expectedString = "1xyz:A";
86  1 String outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("1xyz",
87    "2xyz;3xyz;1xyz:A");
88  1 System.out.println("1 >>>>>>>>>>> " + outcome);
89  1 assertEquals(expectedString, outcome);
90   
91  1 expectedString = "2xyz";
92  1 outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("2xyz",
93    "1xyz:A;2xyz;3xyz");
94  1 System.out.println("2 >>>>>>>>>>> " + outcome);
95  1 assertEquals(expectedString, outcome);
96   
97  1 expectedString = "2xyz:A";
98  1 outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("2xyz", "2xyz:A");
99  1 System.out.println("3 >>>>>>>>>>> " + outcome);
100  1 assertEquals(expectedString, outcome);
101    }
102   
 
103  0 toggle @Test(groups = { "External" }, timeOut = 8000)
104    public void txt_search_ActionPerformedTest()
105    {
106  0 PDBFTSPanel searchPanel = new PDBFTSPanel(null);
107  0 JInternalFrame mainFrame = searchPanel.getMainFrame();
108    // JComboBox<String> txt_search = PA.gsearchPanel.getTxtSearch();
109   
110  0 assertTrue(mainFrame.getTitle().length() == 20);
111  0 assertTrue(mainFrame.getTitle()
112    .equalsIgnoreCase("PDB Sequence Fetcher"));
113  0 PA.invokeMethod(PA.getValue(searchPanel, "txt_search"), "setSelectedItem(java.lang.String)", "ABC");
114    // txt_search.setSelectedItem("ABC");
115  0 try
116    {
117    // wait for web-service to handle response
118  0 Thread.sleep(3000);
119    } catch (InterruptedException e)
120    {
121  0 e.printStackTrace();
122    }
123  0 assertTrue(mainFrame.getTitle().length() > 20);
124  0 assertTrue(!mainFrame.getTitle().equalsIgnoreCase(
125    "PDB Sequence Fetcher"));
126    }
127   
128    }