1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.util; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertNull; |
25 |
|
import static org.testng.AssertJUnit.fail; |
26 |
|
|
27 |
|
import jalview.gui.JvOptionPane; |
28 |
|
|
29 |
|
import java.text.ParseException; |
30 |
|
import java.util.List; |
31 |
|
|
32 |
|
import org.testng.annotations.BeforeClass; |
33 |
|
import org.testng.annotations.Test; |
34 |
|
|
|
|
| 96.8% |
Uncovered Elements: 2 (62) |
Complexity: 5 |
Complexity Density: 0.08 |
|
35 |
|
public class DnaUtilsTest |
36 |
|
{ |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
38 |
1 |
@BeforeClass(alwaysRun = true)... |
39 |
|
public void setUpJvOptionPane() |
40 |
|
{ |
41 |
1 |
JvOptionPane.setInteractiveMode(false); |
42 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
43 |
|
} |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@throws |
49 |
|
|
50 |
|
@see |
51 |
|
|
|
|
| 98.1% |
Uncovered Elements: 1 (54) |
Complexity: 2 |
Complexity Density: 0.04 |
1PASS
|
|
52 |
1 |
@Test(groups = { "Functional" })... |
53 |
|
public void testParseLocation() throws ParseException |
54 |
|
{ |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
1 |
List<int[]> ranges = DnaUtils.parseLocation("467"); |
59 |
1 |
assertEquals(1, ranges.size()); |
60 |
1 |
assertEquals(467, ranges.get(0)[0]); |
61 |
1 |
assertEquals(467, ranges.get(0)[1]); |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
1 |
ranges = DnaUtils.parseLocation("12..78"); |
67 |
1 |
assertEquals(1, ranges.size()); |
68 |
1 |
assertEquals(12, ranges.get(0)[0]); |
69 |
1 |
assertEquals(78, ranges.get(0)[1]); |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
1 |
ranges = DnaUtils.parseLocation("join(12..78,134..202,322..345)"); |
75 |
1 |
assertEquals(3, ranges.size()); |
76 |
1 |
assertEquals(12, ranges.get(0)[0]); |
77 |
1 |
assertEquals(78, ranges.get(0)[1]); |
78 |
1 |
assertEquals(134, ranges.get(1)[0]); |
79 |
1 |
assertEquals(202, ranges.get(1)[1]); |
80 |
1 |
assertEquals(322, ranges.get(2)[0]); |
81 |
1 |
assertEquals(345, ranges.get(2)[1]); |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
1 |
ranges = DnaUtils.parseLocation("complement(34..126)"); |
87 |
1 |
assertEquals(1, ranges.size()); |
88 |
1 |
assertEquals(126, ranges.get(0)[0]); |
89 |
1 |
assertEquals(34, ranges.get(0)[1]); |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
1 |
ranges = DnaUtils |
95 |
|
.parseLocation("complement(join(2691..4571,4918..5163))"); |
96 |
1 |
assertEquals(2, ranges.size()); |
97 |
1 |
assertEquals(5163, ranges.get(0)[0]); |
98 |
1 |
assertEquals(4918, ranges.get(0)[1]); |
99 |
1 |
assertEquals(4571, ranges.get(1)[0]); |
100 |
1 |
assertEquals(2691, ranges.get(1)[1]); |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
1 |
ranges = DnaUtils.parseLocation( |
106 |
|
"join(complement(4918..5163),complement(2691..4571))"); |
107 |
1 |
assertEquals(2, ranges.size()); |
108 |
1 |
assertEquals(5163, ranges.get(0)[0]); |
109 |
1 |
assertEquals(4918, ranges.get(0)[1]); |
110 |
1 |
assertEquals(4571, ranges.get(1)[0]); |
111 |
1 |
assertEquals(2691, ranges.get(1)[1]); |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
@see |
116 |
|
|
117 |
1 |
ranges = DnaUtils |
118 |
|
.parseLocation("join(complement(36618..36700),86988..87064)"); |
119 |
1 |
assertEquals(2, ranges.size()); |
120 |
1 |
assertEquals(36700, ranges.get(0)[0]); |
121 |
1 |
assertEquals(36618, ranges.get(0)[1]); |
122 |
1 |
assertEquals(86988, ranges.get(1)[0]); |
123 |
1 |
assertEquals(87064, ranges.get(1)[1]); |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
1 |
checkForParseException("<34..126"); |
129 |
1 |
checkForParseException("35..>126"); |
130 |
1 |
checkForParseException("34.126"); |
131 |
1 |
checkForParseException("34^126"); |
132 |
1 |
checkForParseException("order(34..126,130..180)"); |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
1 |
checkForParseException(""); |
138 |
1 |
checkForParseException("JOIN(1..2)"); |
139 |
1 |
checkForParseException("join(1..2"); |
140 |
1 |
checkForParseException("join(1..2("); |
141 |
1 |
checkForParseException("complement(1..2"); |
142 |
1 |
checkForParseException("complement(1..2("); |
143 |
1 |
try |
144 |
|
{ |
145 |
1 |
assertNull(DnaUtils.parseLocation(null)); |
146 |
0 |
fail("Expected exception"); |
147 |
|
} catch (NullPointerException e) |
148 |
|
{ |
149 |
|
|
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
1 |
checkForParseException("join(1..2,join(4..5,10..12),18..22)"); |
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
1 |
checkForParseException( |
162 |
|
"join(complement(36618..36700,4000..4200),86988..87064)"); |
163 |
|
} |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
@param |
169 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
170 |
13 |
void checkForParseException(String location)... |
171 |
|
{ |
172 |
13 |
try |
173 |
|
{ |
174 |
13 |
DnaUtils.parseLocation(location); |
175 |
0 |
fail("Expected exception"); |
176 |
|
} catch (ParseException e) |
177 |
|
{ |
178 |
|
|
179 |
|
} |
180 |
|
} |
181 |
|
|
182 |
|
} |