1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertSame; |
26 |
|
import static org.testng.AssertJUnit.assertTrue; |
27 |
|
|
28 |
|
import jalview.gui.JvOptionPane; |
29 |
|
import jalview.util.MapList; |
30 |
|
|
31 |
|
import org.testng.annotations.BeforeClass; |
32 |
|
import org.testng.annotations.Test; |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (91) |
Complexity: 4 |
Complexity Density: 0.05 |
|
34 |
|
public class DBRefEntryTest |
35 |
|
{ |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
37 |
1 |
@BeforeClass(alwaysRun = true)... |
38 |
|
public void setUpJvOptionPane() |
39 |
|
{ |
40 |
1 |
JvOptionPane.setInteractiveMode(false); |
41 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
42 |
|
} |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
47 |
1 |
@Test(groups = { "Functional" })... |
48 |
|
public void testEqualRef() |
49 |
|
{ |
50 |
1 |
DBRefEntry ref1 = new DBRefEntry("UNIPROT", "1", "V71633"); |
51 |
1 |
assertTrue(ref1.equalRef(ref1)); |
52 |
1 |
assertFalse(ref1.equalRef(null)); |
53 |
|
|
54 |
|
|
55 |
1 |
DBRefEntry ref2 = new DBRefEntry("uniprot", "1", "v71633"); |
56 |
1 |
assertTrue(ref1.equalRef(ref2)); |
57 |
1 |
assertTrue(ref2.equalRef(ref1)); |
58 |
|
|
59 |
|
|
60 |
1 |
assertFalse(ref1.equalRef(new DBRefEntry("UNIPRO", "1", "V71633"))); |
61 |
1 |
assertFalse(ref1.equalRef(new DBRefEntry("UNIPROT", "2", "V71633"))); |
62 |
1 |
assertFalse(ref1.equalRef(new DBRefEntry("UNIPROT", "1", "V71632"))); |
63 |
|
|
64 |
|
|
65 |
1 |
ref1.setMap( |
66 |
|
new Mapping(new MapList(new int[] |
67 |
|
{ 1, 3 }, new int[] { 1, 1 }, 3, 1))); |
68 |
1 |
assertTrue(ref1.equalRef(ref2)); |
69 |
1 |
assertTrue(ref2.equalRef(ref1)); |
70 |
1 |
ref1.setMap( |
71 |
|
new Mapping(new MapList(new int[] |
72 |
|
{ 1, 6 }, new int[] { 1, 2 }, 3, 1))); |
73 |
1 |
assertTrue(ref1.equalRef(ref2)); |
74 |
1 |
assertTrue(ref2.equalRef(ref1)); |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (44) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
81 |
1 |
@Test(groups = { "Functional" })... |
82 |
|
public void testUpdateFrom() |
83 |
|
{ |
84 |
1 |
DBRefEntry ref1 = new DBRefEntry("UNIPROT", "1", "V71633"); |
85 |
|
|
86 |
1 |
assertFalse(ref1.updateFrom(null)); |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
1 |
DBRefEntry ref2 = new DBRefEntry("uniprot", "1", "v71633"); |
92 |
1 |
assertTrue(ref1.updateFrom(ref2)); |
93 |
1 |
assertEquals("UNIPROT", ref1.getSource()); |
94 |
1 |
assertEquals("V71633", ref1.getAccessionId()); |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
1 |
Mapping map = new Mapping( |
100 |
|
new MapList(new int[] |
101 |
|
{ 1, 3 }, new int[] { 1, 1 }, 3, 1)); |
102 |
1 |
ref2.setMap(map); |
103 |
1 |
assertTrue(ref1.updateFrom(ref2)); |
104 |
1 |
assertSame(map, ref1.getMap()); |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
1 |
ref2.setMap(new Mapping(map)); |
110 |
1 |
assertTrue(ref1.updateFrom(ref2)); |
111 |
1 |
assertSame(map, ref1.getMap()); |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
1 |
ref2.setSource("pdb"); |
117 |
1 |
assertFalse(ref1.updateFrom(ref2)); |
118 |
1 |
ref2.setSource(ref1.getSource()); |
119 |
1 |
ref2.setAccessionId("P12345"); |
120 |
1 |
assertFalse(ref1.updateFrom(ref2)); |
121 |
1 |
ref2.setAccessionId(ref1.getAccessionId()); |
122 |
1 |
ref1.setVersion("2"); |
123 |
1 |
assertFalse(ref1.updateFrom(ref2)); |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
1 |
ref2.setVersion(null); |
129 |
1 |
assertFalse(ref1.updateFrom(ref2)); |
130 |
1 |
assertEquals("2", ref1.getVersion()); |
131 |
1 |
ref2.setVersion("3"); |
132 |
1 |
ref1.setVersion("0"); |
133 |
1 |
assertTrue(ref1.updateFrom(ref2)); |
134 |
1 |
assertEquals("3", ref1.getVersion()); |
135 |
1 |
ref1.setVersion("UNIPROT:0"); |
136 |
1 |
assertTrue(ref1.updateFrom(ref2)); |
137 |
1 |
assertEquals("3", ref1.getVersion()); |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
1 |
ref1.setCanonical(false); |
143 |
1 |
ref2.setCanonical(true); |
144 |
1 |
assertTrue(ref1.updateFrom(ref2)); |
145 |
1 |
assertTrue(ref1.isCanonical()); |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
1 |
ref1.setCanonical(true); |
151 |
1 |
ref2.setCanonical(false); |
152 |
1 |
assertFalse(ref1.updateFrom(ref2)); |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
1 |
ref1.setVersion("UNIPROT:1"); |
158 |
1 |
assertFalse(ref1.updateFrom(ref2)); |
159 |
1 |
assertEquals("UNIPROT:1", ref1.getVersion()); |
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
1 |
ref1.setVersion("10"); |
165 |
1 |
assertFalse(ref1.updateFrom(ref2)); |
166 |
1 |
assertEquals("10", ref1.getVersion()); |
167 |
|
} |
168 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
169 |
1 |
@Test(groups = { "Functional" })... |
170 |
|
public void testIsPrimaryCandidate() |
171 |
|
{ |
172 |
1 |
DBRefEntry dbr = new DBRefEntry(DBRefSource.UNIPROT, "", "Q12345"); |
173 |
1 |
assertTrue(dbr.isPrimaryCandidate()); |
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
1 |
dbr.setMap( |
179 |
|
new Mapping(null, new int[] |
180 |
|
{ 1, 3 }, new int[] { 1, 3 }, 1, 1)); |
181 |
1 |
assertTrue(dbr.isPrimaryCandidate()); |
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
1 |
dbr.setMap( |
187 |
|
new Mapping(null, new int[] |
188 |
|
{ 1, 3, 6, 9 }, new int[] { 1, 3, 6, 9 }, 1, 1)); |
189 |
1 |
assertFalse(dbr.isPrimaryCandidate()); |
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
1 |
dbr.setMap( |
195 |
|
new Mapping(null, new int[] |
196 |
|
{ 1, 4 }, new int[] { 2, 5 }, 1, 1)); |
197 |
1 |
assertFalse(dbr.isPrimaryCandidate()); |
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
1 |
dbr.setMap( |
203 |
|
new Mapping(null, new int[] |
204 |
|
{ 1, 2, 6, 9 }, new int[] { 1, 3, 7, 9 }, 1, 1)); |
205 |
1 |
assertFalse(dbr.isPrimaryCandidate()); |
206 |
1 |
dbr.setMap(null); |
207 |
1 |
assertTrue(dbr.isPrimaryCandidate()); |
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
1 |
dbr.setVersion(DBRefSource.EMBL + ":0"); |
213 |
1 |
assertFalse(dbr.isPrimaryCandidate()); |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
1 |
dbr.setVersion("0.1.b"); |
219 |
1 |
assertTrue(dbr.isPrimaryCandidate()); |
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
1 |
dbr.setVersion(null); |
225 |
1 |
assertFalse(dbr.isPrimaryCandidate()); |
226 |
1 |
dbr.setVersion(""); |
227 |
1 |
assertTrue(dbr.isPrimaryCandidate()); |
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
1 |
dbr.setMap( |
233 |
|
new Mapping(new Sequence("foo", "ASDF"), new int[] |
234 |
|
{ 1, 3 }, new int[] { 1, 3 }, 1, 1)); |
235 |
1 |
assertFalse(dbr.isPrimaryCandidate()); |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
1 |
dbr.setMap( |
241 |
|
new Mapping(null, new int[] |
242 |
|
{ 1, 3 }, new int[] { 1, 3 }, 1, 3)); |
243 |
1 |
assertFalse(dbr.isPrimaryCandidate()); |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
1 |
dbr.setMap( |
249 |
|
new Mapping(null, new int[] |
250 |
|
{ 1, 4 }, new int[] { 1, 4 }, 2, 2)); |
251 |
1 |
assertFalse(dbr.isPrimaryCandidate()); |
252 |
|
} |
253 |
|
} |