1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.jws2; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import static org.testng.AssertJUnit.assertEquals; |
26 |
|
import static org.testng.AssertJUnit.assertFalse; |
27 |
|
import static org.testng.AssertJUnit.assertTrue; |
28 |
|
|
29 |
|
import jalview.bin.Cache; |
30 |
|
import jalview.bin.Console; |
31 |
|
import jalview.gui.JvOptionPane; |
32 |
|
import jalview.ws.jabaws.JalviewJabawsTestUtils; |
33 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
34 |
|
|
35 |
|
import java.util.ArrayList; |
36 |
|
import java.util.Iterator; |
37 |
|
import java.util.List; |
38 |
|
|
39 |
|
import org.testng.annotations.BeforeClass; |
40 |
|
import org.testng.annotations.Test; |
41 |
|
|
42 |
|
import compbio.metadata.Option; |
43 |
|
import compbio.metadata.Parameter; |
44 |
|
import compbio.metadata.Preset; |
45 |
|
import compbio.metadata.PresetManager; |
46 |
|
import compbio.metadata.WrongParameterException; |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@Test(singleThreaded = true) |
|
|
| 0% |
Uncovered Elements: 69 (69) |
Complexity: 13 |
Complexity Density: 0.25 |
|
53 |
|
public class ParameterUtilsTest |
54 |
|
{ |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
56 |
0 |
@BeforeClass(alwaysRun = true)... |
57 |
|
public void setUpJvOptionPane() |
58 |
|
{ |
59 |
0 |
JvOptionPane.setInteractiveMode(false); |
60 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
private static List<String> serviceTests = new ArrayList<String>(); |
68 |
|
|
69 |
|
private static Jws2Discoverer disc = null; |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
71 |
0 |
@BeforeClass(alwaysRun = true)... |
72 |
|
public static void setUpBeforeClass() throws Exception |
73 |
|
{ |
74 |
0 |
serviceTests.add("AAConWS".toLowerCase(Locale.ROOT)); |
75 |
0 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
76 |
0 |
Console.initLogger(); |
77 |
0 |
disc = JalviewJabawsTestUtils.getJabawsDiscoverer(); |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 6 |
Complexity Density: 0.23 |
4-
|
|
80 |
0 |
@Test(groups = { "Network" })... |
81 |
|
public void testWriteParameterSet() throws WrongParameterException |
82 |
|
{ |
83 |
0 |
for (Jws2Instance service : disc.getServices()) |
84 |
|
{ |
85 |
0 |
if (isForTesting(service)) |
86 |
|
{ |
87 |
|
|
88 |
0 |
List<Preset> prl = null; |
89 |
0 |
PresetManager prman = service.getPresets(); |
90 |
0 |
if (prman == null) |
91 |
|
{ |
92 |
0 |
continue; |
93 |
|
} |
94 |
0 |
prl = prman.getPresets(); |
95 |
0 |
if (prl == null) |
96 |
|
{ |
97 |
0 |
continue; |
98 |
|
} |
99 |
0 |
for (Preset pr : prl) |
100 |
|
{ |
101 |
0 |
List<String> writeparam = null; |
102 |
0 |
List<String> readparam = null; |
103 |
0 |
writeparam = ParameterUtils.writeParameterSet( |
104 |
|
pr.getArguments(service.getRunnerConfig()), " "); |
105 |
0 |
List<Option> pset = ParameterUtils.processParameters(writeparam, |
106 |
|
service.getRunnerConfig(), " "); |
107 |
0 |
readparam = ParameterUtils.writeParameterSet(pset, " "); |
108 |
0 |
Iterator<String> o = pr.getOptions().iterator(); |
109 |
0 |
Iterator<String> s = writeparam.iterator(); |
110 |
0 |
Iterator<String> t = readparam.iterator(); |
111 |
0 |
boolean failed = false; |
112 |
0 |
while (s.hasNext() && t.hasNext()) |
113 |
|
{ |
114 |
0 |
String on = o.next(); |
115 |
0 |
String sn = s.next(); |
116 |
0 |
String st = t.next(); |
117 |
0 |
final String errorMsg = "Original was " + on + " Phase 1 wrote " |
118 |
|
+ sn + "\tPhase 2 wrote " + st; |
119 |
0 |
assertEquals(errorMsg, sn, st); |
120 |
0 |
assertEquals(errorMsg, sn, on); |
121 |
|
} |
122 |
|
} |
123 |
|
} |
124 |
|
} |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
@param |
132 |
|
@return |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
0 |
public boolean isForTesting(Jws2Instance service)... |
135 |
|
{ |
136 |
0 |
return serviceTests.size() == 0 || serviceTests |
137 |
|
.contains(service.serviceType.toLowerCase(Locale.ROOT)); |
138 |
|
} |
139 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
4-
|
|
140 |
0 |
@Test(groups = { "Network" })... |
141 |
|
public void testCopyOption() |
142 |
|
{ |
143 |
0 |
for (Jws2Instance service : disc.getServices()) |
144 |
|
{ |
145 |
0 |
if (isForTesting(service)) |
146 |
|
{ |
147 |
0 |
List<Option<?>> options = service.getRunnerConfig().getOptions(); |
148 |
0 |
for (Option<?> o : options) |
149 |
|
{ |
150 |
0 |
System.out.println("Testing copyOption for option " + o.getName() |
151 |
|
+ " of " + service.getActionText()); |
152 |
0 |
Option<?> cpy = ParameterUtils.copyOption(o); |
153 |
0 |
assertTrue(cpy.equals(o)); |
154 |
0 |
assertEquals(cpy.getName(), o.getName()); |
155 |
0 |
assertFalse(cpy == o); |
156 |
|
|
157 |
|
} |
158 |
|
} |
159 |
|
} |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
4-
|
|
164 |
0 |
@Test(groups = { "Network" })... |
165 |
|
public void testCopyParameter() |
166 |
|
{ |
167 |
0 |
for (Jws2Instance service : disc.getServices()) |
168 |
|
{ |
169 |
0 |
if (isForTesting(service)) |
170 |
|
{ |
171 |
0 |
List<Parameter> parameters = service.getRunnerConfig() |
172 |
|
.getParameters(); |
173 |
0 |
for (Parameter o : parameters) |
174 |
|
{ |
175 |
0 |
System.out.println("Testing copyParameter for parameter " |
176 |
|
+ o.getName() + " of " + service.getActionText()); |
177 |
0 |
Parameter cpy = ParameterUtils.copyParameter(o); |
178 |
0 |
assertTrue(cpy.equals(o)); |
179 |
0 |
assertFalse(cpy == o); |
180 |
0 |
assertEquals(cpy.getName(), o.getName()); |
181 |
|
|
182 |
|
} |
183 |
|
} |
184 |
|
} |
185 |
|
} |
186 |
|
} |