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