Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 14:43:25 GMT
  2. Package jalview.ws.gui

File Jws2ParamView.java

 

Coverage histogram

../../../img/srcFileCovDistChart1.png
57% of files have more coverage

Code metrics

20
46
5
1
183
131
18
0.39
9.2
5
3.6

Classes

Class Line # Actions
Jws2ParamView 54 46 18
0.0281690142.8%
 

Contributing tests

No tests hitting this source file were found.

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.ws.gui;
22   
23    import java.util.Locale;
24   
25    import jalview.bin.Cache;
26    import jalview.bin.Console;
27    import jalview.gui.JvOptionPane;
28    import jalview.gui.WsJobParameters;
29    import jalview.util.MessageManager;
30    import jalview.ws.api.ServiceWithParameters;
31    import jalview.ws.jabaws.JalviewJabawsTestUtils;
32    import jalview.ws.jws2.JabaPreset;
33    import jalview.ws.jws2.Jws2Discoverer;
34    import jalview.ws.jws2.jabaws2.Jws2Instance;
35    import jalview.ws.params.ArgumentI;
36    import jalview.ws.params.ParamDatastoreI;
37   
38    import java.awt.BorderLayout;
39    import java.awt.event.WindowAdapter;
40    import java.awt.event.WindowEvent;
41    import java.util.ArrayList;
42    import java.util.Iterator;
43    import java.util.List;
44   
45    import javax.swing.JFrame;
46    import javax.swing.JPanel;
47   
48    import org.testng.annotations.BeforeClass;
49    import org.testng.annotations.Test;
50   
51    import compbio.metadata.Preset;
52    import compbio.metadata.PresetManager;
53   
 
54    public class Jws2ParamView
55    {
56   
 
57  0 toggle @BeforeClass(alwaysRun = true)
58    public void setUpJvOptionPane()
59    {
60  0 JvOptionPane.setInteractiveMode(false);
61  0 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
62    }
63   
64    /**
65    * which services to test
66    */
67    public static List<String> serviceTests = new ArrayList<>();
68   
69    /**
70    * which presets to test for services
71    */
72    public static List<String> presetTests = new ArrayList<>();
 
73  4 toggle static
74    {
75  4 serviceTests.add("AAConWS".toLowerCase(Locale.ROOT));
76    }
77   
78    public static Jws2Discoverer disc = null;
79   
 
80  0 toggle @BeforeClass(alwaysRun = true)
81    public static void setUpBeforeClass() throws Exception
82    {
83  0 Cache.loadProperties("test/jalview/io/testProps.jvprops");
84  0 disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
85    }
86   
87    /**
88    * This test marked Interactive as it appears to need user action to complete
89    * rather than hang
90    */
91   
 
92  0 toggle @Test(groups = { "Interactive" }, enabled = true)
93    public void testJws2Gui()
94    {
95  0 Iterator<String> presetEnum = presetTests.iterator();
96  0 for (ServiceWithParameters _service : disc.getServices())
97    {
98    // This will fail for non-jabaws services
99  0 Jws2Instance service = (Jws2Instance) _service;
100  0 if (serviceTests.size() == 0
101    || serviceTests.contains(service.getName().toLowerCase(Locale.ROOT)))
102    {
103  0 List<Preset> prl = null;
104  0 Preset pr = null;
105  0 if (presetEnum.hasNext())
106    {
107  0 PresetManager prman = service.getPresets();
108  0 if (prman != null)
109    {
110  0 pr = prman.getPresetByName(presetEnum.next());
111  0 if (pr == null)
112    {
113    // just grab the last preset.
114  0 prl = prman.getPresets();
115    }
116    }
117    }
118    else
119    {
120  0 PresetManager prman = service.getPresets();
121  0 if (prman != null)
122    {
123  0 prl = prman.getPresets();
124    }
125    }
126  0 Iterator<Preset> en = (prl == null) ? null : prl.iterator();
127  0 while (en != null && en.hasNext())
128    {
129  0 if (en != null)
130    {
131  0 if (!en.hasNext())
132    {
133  0 en = prl.iterator();
134    }
135  0 pr = en.next();
136    }
137  0 WsJobParameters pgui = new WsJobParameters((ParamDatastoreI) null,
138    service, new JabaPreset(service, pr),
139    (List<ArgumentI>) null);
140  0 JFrame jf = new JFrame(MessageManager
141    .formatMessage("label.ws_parameters_for", new String[]
142    { service.getActionText() }));
143  0 jf.setSize(700, 800);
144  0 JPanel cont = new JPanel(new BorderLayout());
145  0 pgui.validate();
146  0 cont.setPreferredSize(pgui.getPreferredSize());
147  0 cont.add(pgui, BorderLayout.CENTER);
148  0 jf.setLayout(new BorderLayout());
149  0 jf.add(cont, BorderLayout.CENTER);
150  0 jf.validate();
151   
152  0 final Thread thr = Thread.currentThread();
153   
154    /*
155    * This seems to need a user to manually inspect / test / close the
156    * GUI for each service tested. Not standalone JUnit.
157    */
158  0 jf.addWindowListener(new WindowAdapter()
159    {
 
160  0 toggle @Override
161    public void windowClosing(WindowEvent e)
162    {
163  0 thr.interrupt();
164    }
165    });
166  0 jf.setVisible(true);
167  0 boolean inter = false;
168  0 while (!inter)
169    {
170  0 try
171    {
172  0 Thread.sleep(10 * 1000);
173    } catch (InterruptedException e)
174    {
175  0 inter = true;
176    }
177    }
178  0 jf.dispose();
179    }
180    }
181    }
182    }
183    }