1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
package jalview.datamodel; |
23 |
|
|
24 |
|
import static org.testng.Assert.assertEquals; |
25 |
|
import static org.testng.Assert.assertFalse; |
26 |
|
import static org.testng.Assert.assertNotEquals; |
27 |
|
import static org.testng.Assert.assertNotSame; |
28 |
|
import static org.testng.Assert.assertNull; |
29 |
|
import static org.testng.Assert.assertSame; |
30 |
|
import static org.testng.Assert.assertTrue; |
31 |
|
import static org.testng.Assert.fail; |
32 |
|
|
33 |
|
import jalview.datamodel.PDBEntry.Type; |
34 |
|
import jalview.gui.JvOptionPane; |
35 |
|
|
36 |
|
|
37 |
|
import org.testng.annotations.AfterMethod; |
38 |
|
import org.testng.annotations.BeforeClass; |
39 |
|
import org.testng.annotations.BeforeMethod; |
40 |
|
import org.testng.annotations.Test; |
41 |
|
|
|
|
| 99.3% |
Uncovered Elements: 1 (141) |
Complexity: 10 |
Complexity Density: 0.08 |
|
42 |
|
public class PDBEntryTest |
43 |
|
{ |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
45 |
1 |
@BeforeClass(alwaysRun = true)... |
46 |
|
public void setUpJvOptionPane() |
47 |
|
{ |
48 |
1 |
JvOptionPane.setInteractiveMode(false); |
49 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
50 |
|
} |
51 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
52 |
6 |
@BeforeMethod(alwaysRun = true)... |
53 |
|
public void setUp() throws Exception |
54 |
|
{ |
55 |
|
} |
56 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
57 |
6 |
@AfterMethod(alwaysRun = true)... |
58 |
|
public void tearDown() throws Exception |
59 |
|
{ |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (32) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
62 |
1 |
@Test(groups = { "Functional" })... |
63 |
|
public void testEquals() |
64 |
|
{ |
65 |
1 |
PDBEntry pdbEntry = new PDBEntry("1xyz", "A", PDBEntry.Type.PDB, |
66 |
|
"x/y/z/File"); |
67 |
|
|
68 |
|
|
69 |
1 |
PDBEntry case1 = new PDBEntry("1XYZ", "A", PDBEntry.Type.PDB, |
70 |
|
"x/y/z/File"); |
71 |
|
|
72 |
1 |
PDBEntry case2 = new PDBEntry("1xyz", "a", PDBEntry.Type.PDB, |
73 |
|
"x/y/z/File"); |
74 |
|
|
75 |
1 |
PDBEntry case3 = new PDBEntry("1xyz", "A", PDBEntry.Type.FILE, |
76 |
|
"x/y/z/File"); |
77 |
|
|
78 |
1 |
PDBEntry case4 = new PDBEntry(null, null, null, null); |
79 |
|
|
80 |
1 |
PDBEntry case5 = new PDBEntry(null, "A", PDBEntry.Type.PDB, |
81 |
|
"x/y/z/File"); |
82 |
|
|
83 |
1 |
PDBEntry case6 = new PDBEntry("1xyz", null, PDBEntry.Type.PDB, |
84 |
|
"x/y/z/File"); |
85 |
|
|
86 |
1 |
PDBEntry case7 = new PDBEntry("1xyz", "A", null, "x/y/z/File"); |
87 |
|
|
88 |
1 |
PDBEntry case8 = new PDBEntry("1xyz", "A", PDBEntry.Type.PDB, null); |
89 |
|
|
90 |
1 |
PDBEntry case9 = new PDBEntry("1xyz", "A", null, "x/y/z/File"); |
91 |
|
|
92 |
1 |
PDBEntry case10 = new PDBEntry("1xyz", "A", null, "a/b/c/File"); |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
1 |
assertFalse(pdbEntry.equals(null)); |
98 |
1 |
assertFalse(pdbEntry.equals("a")); |
99 |
1 |
assertEquals(case1, pdbEntry); |
100 |
1 |
assertEquals(case2, pdbEntry); |
101 |
1 |
assertNotEquals(case3, pdbEntry); |
102 |
1 |
assertNotEquals(case4, pdbEntry); |
103 |
1 |
assertNotEquals(case5, pdbEntry); |
104 |
1 |
assertNotEquals(case6, pdbEntry); |
105 |
1 |
assertNotEquals(case7, pdbEntry); |
106 |
1 |
assertNotEquals(case8, pdbEntry); |
107 |
1 |
assertEquals(case7, case9); |
108 |
1 |
assertNotEquals(case9, case10); |
109 |
|
|
110 |
|
|
111 |
1 |
case7.setProperty("hello", "world"); |
112 |
1 |
assertNotEquals(case7, case9); |
113 |
1 |
case9.setProperty("hello", "world"); |
114 |
1 |
assertEquals(case7, case9); |
115 |
1 |
case9.setProperty("hello", "WORLD"); |
116 |
1 |
assertNotEquals(case7, case9); |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
1 |
case1.setProperty("chain_code", "a"); |
122 |
1 |
assertFalse(pdbEntry.equals(case1)); |
123 |
1 |
assertFalse(case1.equals(pdbEntry)); |
124 |
|
} |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
126 |
1 |
@Test(groups = { "Functional" })... |
127 |
|
public void testSetChainCode() |
128 |
|
{ |
129 |
1 |
PDBEntry pdbEntry = new PDBEntry("1xyz", null, PDBEntry.Type.PDB, |
130 |
|
"x/y/z/File"); |
131 |
1 |
assertNull(pdbEntry.getChainCode()); |
132 |
|
|
133 |
1 |
pdbEntry.setChainCode("a"); |
134 |
1 |
assertEquals("a", pdbEntry.getChainCode()); |
135 |
|
|
136 |
1 |
pdbEntry.setChainCode(null); |
137 |
1 |
assertNull(pdbEntry.getChainCode()); |
138 |
|
} |
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
140 |
1 |
@Test(groups = { "Functional" })... |
141 |
|
public void testGetType() |
142 |
|
{ |
143 |
1 |
assertSame(PDBEntry.Type.FILE, PDBEntry.Type.getType("FILE")); |
144 |
1 |
assertSame(PDBEntry.Type.FILE, PDBEntry.Type.getType("File")); |
145 |
1 |
assertSame(PDBEntry.Type.FILE, PDBEntry.Type.getType("file")); |
146 |
1 |
assertNotSame(PDBEntry.Type.FILE, PDBEntry.Type.getType("file ")); |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
149 |
1 |
@Test(groups = { "Functional" })... |
150 |
|
public void testTypeMatches() |
151 |
|
{ |
152 |
|
|
153 |
1 |
assertTrue(PDBEntry.Type.FILE.matches("FILE")); |
154 |
1 |
assertTrue(PDBEntry.Type.FILE.matches("File")); |
155 |
1 |
assertTrue(PDBEntry.Type.FILE.matches("file")); |
156 |
1 |
assertFalse(PDBEntry.Type.FILE.matches("FILE ")); |
157 |
|
} |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (70) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
159 |
1 |
@Test(groups = { "Functional" })... |
160 |
|
public void testUpdateFrom() |
161 |
|
{ |
162 |
1 |
PDBEntry pdb1 = new PDBEntry("3A6S", null, null, null); |
163 |
1 |
PDBEntry pdb2 = new PDBEntry("3A6S", null, null, null); |
164 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
1 |
pdb2 = new PDBEntry("1A70", "A", null, null); |
170 |
1 |
assertFalse(pdb1.updateFrom(pdb2)); |
171 |
1 |
assertNull(pdb1.getChainCode()); |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
1 |
pdb2 = new PDBEntry("3a6s", "A", null, null); |
177 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
178 |
1 |
assertEquals(pdb1.getChainCode(), "A"); |
179 |
1 |
assertEquals(pdb1.getId(), "3A6S"); |
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
1 |
pdb1 = new PDBEntry("3A6S", null, null, null); |
185 |
1 |
pdb2 = new PDBEntry("3a6s", "A", null, null); |
186 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
187 |
1 |
assertEquals(pdb1.getChainCode(), "A"); |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
1 |
pdb2 = new PDBEntry("3A6S", "B", null, null); |
193 |
1 |
assertFalse(pdb1.updateFrom(pdb2)); |
194 |
1 |
assertEquals(pdb1.getChainCode(), "A"); |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
1 |
pdb1 = new PDBEntry("3A6S", null, null, null); |
200 |
1 |
pdb2 = new PDBEntry("3A6S", "B", null, null); |
201 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
202 |
1 |
assertEquals(pdb1.getChainCode(), "B"); |
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
1 |
pdb2 = new PDBEntry("3A6S", "B", Type.FILE, "filePath"); |
208 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
209 |
1 |
assertEquals(pdb1.getFile(), "filePath"); |
210 |
1 |
assertEquals(pdb1.getType(), Type.FILE.toString()); |
211 |
1 |
assertEquals(pdb1.getChainCode(), "B"); |
212 |
|
|
213 |
|
|
214 |
|
|
215 |
1 |
pdb1 = new PDBEntry("3A6S", null, null, "file1"); |
216 |
1 |
pdb2 = new PDBEntry("3A6S", "A", null, "file2"); |
217 |
1 |
assertFalse(pdb1.updateFrom(pdb2)); |
218 |
1 |
assertNull(pdb1.getChainCode()); |
219 |
1 |
assertEquals(pdb1.getFile(), "file1"); |
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
1 |
pdb1 = new PDBEntry("3A6S", null, null, "file1"); |
225 |
1 |
pdb2 = new PDBEntry("3A6S", null, Type.PDB, "file1"); |
226 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
227 |
1 |
assertEquals(pdb1.getType(), Type.PDB.toString()); |
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
1 |
pdb1 = new PDBEntry("3A6S", "A", null, null); |
233 |
1 |
pdb2 = new PDBEntry("3a6s", "a", Type.PDB, "file1"); |
234 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
235 |
1 |
assertEquals(pdb1.getType(), Type.PDB.toString()); |
236 |
1 |
assertEquals(pdb1.getId(), "3A6S"); |
237 |
1 |
assertEquals(pdb1.getFile(), "file1"); |
238 |
1 |
assertEquals(pdb1.getChainCode(), "A"); |
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
1 |
pdb1 = new PDBEntry("3A6S", "A", Type.PDB, "file1"); |
244 |
1 |
pdb2 = new PDBEntry("3A6S", null, null, null); |
245 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
246 |
1 |
assertEquals(pdb1.getChainCode(), "A"); |
247 |
1 |
assertEquals(pdb1.getType(), Type.PDB.toString()); |
248 |
1 |
assertEquals(pdb1.getFile(), "file1"); |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
1 |
pdb1 = new PDBEntry("3A6S", null, null, null); |
254 |
1 |
pdb2 = new PDBEntry("3A6S", null, null, null); |
255 |
1 |
pdb1.setProperty("destination", "mars"); |
256 |
1 |
pdb1.setProperty("hello", "world"); |
257 |
1 |
pdb2.setProperty("hello", "moon"); |
258 |
1 |
pdb2.setProperty("goodbye", "world"); |
259 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
260 |
1 |
assertEquals(pdb1.getProperty("destination"), "mars"); |
261 |
1 |
assertEquals(pdb1.getProperty("hello"), "moon"); |
262 |
1 |
assertEquals(pdb1.getProperty("goodbye"), "world"); |
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
1 |
pdb1 = new PDBEntry("3A6S", null, null, null); |
268 |
1 |
pdb2 = new PDBEntry("3A6S", null, null, null); |
269 |
1 |
pdb2.setProperty("hello", "moon"); |
270 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
271 |
1 |
assertEquals(pdb1.getProperty("hello"), "moon"); |
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
1 |
pdb1 = new PDBEntry("af:1xyz", "A", null, "a/b/c/File"); |
277 |
1 |
pdb2 = new PDBEntry("af-1xyz", "A", null, "a/b/c/File"); |
278 |
1 |
pdb1.setAuthoritative(true); |
279 |
|
|
280 |
1 |
assertTrue(pdb1.isAuthoritative()); |
281 |
1 |
assertFalse(pdb2.isAuthoritative()); |
282 |
|
|
283 |
1 |
assertTrue(pdb1.updateFrom(pdb2)); |
284 |
|
|
285 |
1 |
assertEquals(pdb1.getId(), "af:1xyz"); |
286 |
|
|
287 |
|
} |
288 |
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 2 |
Complexity Density: 0.14 |
1PASS
|
|
289 |
1 |
@Test(groups = { "Functional" })... |
290 |
|
public void testConstructor_fromDbref() |
291 |
|
{ |
292 |
1 |
PDBEntry pdb = new PDBEntry(new DBRefEntry("PDB", "0", "1A70")); |
293 |
1 |
assertEquals(pdb.getId(), "1A70"); |
294 |
1 |
assertNull(pdb.getChainCode()); |
295 |
1 |
assertNull(pdb.getType()); |
296 |
1 |
assertNull(pdb.getFile()); |
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
1 |
pdb = new PDBEntry(new DBRefEntry("PDB", "0", "1A70B")); |
302 |
1 |
assertEquals(pdb.getId(), "1A70"); |
303 |
1 |
assertEquals(pdb.getChainCode(), "B"); |
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
1 |
pdb = new PDBEntry(new DBRefEntry("PDB", "0", "1A70BC")); |
309 |
1 |
assertEquals(pdb.getId(), "1A70BC"); |
310 |
1 |
assertNull(pdb.getChainCode()); |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
1 |
try |
316 |
|
{ |
317 |
1 |
pdb = new PDBEntry(new DBRefEntry("PDBe", "0", "1A70")); |
318 |
0 |
fail("Expected exception"); |
319 |
|
} catch (IllegalArgumentException e) |
320 |
|
{ |
321 |
|
|
322 |
|
} |
323 |
|
} |
324 |
|
|
325 |
|
} |