1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io.gff; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import jalview.gui.JvOptionPane; |
28 |
|
|
29 |
|
import java.util.Arrays; |
30 |
|
import java.util.List; |
31 |
|
import java.util.Map; |
32 |
|
|
33 |
|
import org.testng.annotations.BeforeClass; |
34 |
|
import org.testng.annotations.Test; |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (95) |
Complexity: 3 |
Complexity Density: 0.03 |
|
36 |
|
public class GffHelperBaseTest |
37 |
|
{ |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
39 |
1 |
@BeforeClass(alwaysRun = true)... |
40 |
|
public void setUpJvOptionPane() |
41 |
|
{ |
42 |
1 |
JvOptionPane.setInteractiveMode(false); |
43 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
44 |
|
} |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
50 |
1 |
@Test(groups = { "Functional" })... |
51 |
|
public void testParseNameValuePairs() |
52 |
|
{ |
53 |
1 |
assertTrue(GffHelperBase.parseNameValuePairs(null, ";", ' ', ",") |
54 |
|
.isEmpty()); |
55 |
1 |
assertTrue(GffHelperBase.parseNameValuePairs("", ";", ' ', ",") |
56 |
|
.isEmpty()); |
57 |
1 |
assertTrue(GffHelperBase.parseNameValuePairs("hello=world", ";", ' ', |
58 |
|
",").isEmpty()); |
59 |
|
|
60 |
1 |
Map<String, List<String>> map = GffHelperBase.parseNameValuePairs( |
61 |
|
"hello world", ";", ' ', ", "); |
62 |
1 |
assertEquals(1, map.size()); |
63 |
1 |
assertEquals(1, map.get("hello").size()); |
64 |
1 |
assertEquals("world", map.get("hello").get(0)); |
65 |
|
|
66 |
1 |
map = GffHelperBase |
67 |
|
.parseNameValuePairs( |
68 |
|
"Method= manual curation ;nothing; Notes=F2 S ; Notes=Metal,Shiny; Type=", |
69 |
|
";", '=', ","); |
70 |
|
|
71 |
|
|
72 |
1 |
assertEquals(2, map.size()); |
73 |
|
|
74 |
1 |
assertEquals(1, map.get("Method").size()); |
75 |
1 |
assertEquals("manual curation", map.get("Method").get(0)); |
76 |
|
|
77 |
1 |
assertEquals(3, map.get("Notes").size()); |
78 |
1 |
assertEquals("F2 S", map.get("Notes").get(0)); |
79 |
1 |
assertEquals("Metal", map.get("Notes").get(1)); |
80 |
1 |
assertEquals("Shiny", map.get("Notes").get(2)); |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (75) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
86 |
1 |
@Test(groups = "Functional")... |
87 |
|
public void testTrimMapping() |
88 |
|
{ |
89 |
1 |
int[] from = { 1, 12 }; |
90 |
1 |
int[] to = { 20, 31 }; |
91 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 1)); |
92 |
1 |
assertEquals("[1, 12]", Arrays.toString(from)); |
93 |
1 |
assertEquals("[20, 31]", Arrays.toString(to)); |
94 |
|
|
95 |
|
|
96 |
1 |
from = new int[] { 1, 13 }; |
97 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 1)); |
98 |
1 |
assertEquals("[1, 12]", Arrays.toString(from)); |
99 |
1 |
assertEquals("[20, 31]", Arrays.toString(to)); |
100 |
|
|
101 |
|
|
102 |
1 |
to = new int[] { 20, 33 }; |
103 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 1)); |
104 |
1 |
assertEquals("[1, 12]", Arrays.toString(from)); |
105 |
1 |
assertEquals("[20, 31]", Arrays.toString(to)); |
106 |
|
|
107 |
|
|
108 |
1 |
from = new int[] { 12, 1 }; |
109 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 1)); |
110 |
1 |
assertEquals("[12, 1]", Arrays.toString(from)); |
111 |
1 |
assertEquals("[20, 31]", Arrays.toString(to)); |
112 |
|
|
113 |
|
|
114 |
1 |
to = new int[] { 31, 20 }; |
115 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 1)); |
116 |
1 |
assertEquals("[12, 1]", Arrays.toString(from)); |
117 |
1 |
assertEquals("[31, 20]", Arrays.toString(to)); |
118 |
|
|
119 |
|
|
120 |
1 |
from = new int[] { 14, 1 }; |
121 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 1)); |
122 |
1 |
assertEquals("[14, 3]", Arrays.toString(from)); |
123 |
1 |
assertEquals("[31, 20]", Arrays.toString(to)); |
124 |
|
|
125 |
|
|
126 |
1 |
to = new int[] { 31, 10 }; |
127 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 1)); |
128 |
1 |
assertEquals("[14, 3]", Arrays.toString(from)); |
129 |
1 |
assertEquals("[31, 20]", Arrays.toString(to)); |
130 |
|
|
131 |
|
|
132 |
1 |
from = new int[] { 1, 18 }; |
133 |
1 |
to = new int[] { 4, 9 }; |
134 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 3, 1)); |
135 |
1 |
assertEquals("[1, 18]", Arrays.toString(from)); |
136 |
1 |
assertEquals("[4, 9]", Arrays.toString(to)); |
137 |
|
|
138 |
|
|
139 |
1 |
from = new int[] { 1, 20 }; |
140 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 3, 1)); |
141 |
1 |
assertEquals("[1, 18]", Arrays.toString(from)); |
142 |
1 |
assertEquals("[4, 9]", Arrays.toString(to)); |
143 |
|
|
144 |
|
|
145 |
1 |
from = new int[] { 20, 1 }; |
146 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 3, 1)); |
147 |
1 |
assertEquals("[20, 3]", Arrays.toString(from)); |
148 |
1 |
assertEquals("[4, 9]", Arrays.toString(to)); |
149 |
|
|
150 |
|
|
151 |
1 |
from = new int[] { 20, 1 }; |
152 |
1 |
to = new int[] { 9, 4 }; |
153 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 3, 1)); |
154 |
1 |
assertEquals("[20, 3]", Arrays.toString(from)); |
155 |
1 |
assertEquals("[9, 4]", Arrays.toString(to)); |
156 |
|
|
157 |
|
|
158 |
1 |
from = new int[] { 4, 9 }; |
159 |
1 |
to = new int[] { 1, 18 }; |
160 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 3)); |
161 |
1 |
assertEquals("[4, 9]", Arrays.toString(from)); |
162 |
1 |
assertEquals("[1, 18]", Arrays.toString(to)); |
163 |
|
|
164 |
|
|
165 |
1 |
to = new int[] { 1, 20 }; |
166 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 3)); |
167 |
1 |
assertEquals("[4, 9]", Arrays.toString(from)); |
168 |
1 |
assertEquals("[1, 18]", Arrays.toString(to)); |
169 |
|
|
170 |
|
|
171 |
1 |
to = new int[] { 20, 1 }; |
172 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 3)); |
173 |
1 |
assertEquals("[4, 9]", Arrays.toString(from)); |
174 |
1 |
assertEquals("[20, 3]", Arrays.toString(to)); |
175 |
|
|
176 |
|
|
177 |
1 |
from = new int[] { 9, 4 }; |
178 |
1 |
to = new int[] { 20, 1 }; |
179 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 3)); |
180 |
1 |
assertEquals("[9, 4]", Arrays.toString(from)); |
181 |
1 |
assertEquals("[20, 3]", Arrays.toString(to)); |
182 |
|
|
183 |
|
|
184 |
1 |
from = new int[] { 4, 10 }; |
185 |
1 |
to = new int[] { 1, 18 }; |
186 |
1 |
assertTrue(GffHelperBase.trimMapping(from, to, 1, 3)); |
187 |
1 |
assertEquals("[4, 9]", Arrays.toString(from)); |
188 |
1 |
assertEquals("[1, 18]", Arrays.toString(to)); |
189 |
|
|
190 |
|
|
191 |
1 |
from = new int[] { 4, 10 }; |
192 |
1 |
to = new int[] { 1, 19 }; |
193 |
1 |
assertFalse(GffHelperBase.trimMapping(from, to, 1, 3)); |
194 |
1 |
assertEquals("[4, 10]", Arrays.toString(from)); |
195 |
1 |
assertEquals("[1, 19]", Arrays.toString(to)); |
196 |
|
|
197 |
|
} |
198 |
|
} |