1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.workers; |
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.api.AlignCalcManagerI; |
28 |
|
import jalview.api.AlignCalcWorkerI; |
29 |
|
import jalview.api.FeatureRenderer; |
30 |
|
import jalview.datamodel.Alignment; |
31 |
|
import jalview.datamodel.AlignmentAnnotation; |
32 |
|
import jalview.datamodel.AlignmentI; |
33 |
|
import jalview.datamodel.Annotation; |
34 |
|
import jalview.datamodel.Sequence; |
35 |
|
import jalview.datamodel.SequenceI; |
36 |
|
import jalview.gui.AlignFrame; |
37 |
|
import jalview.gui.JvOptionPane; |
38 |
|
|
39 |
|
import java.util.Collections; |
40 |
|
import java.util.List; |
41 |
|
|
42 |
|
import org.testng.annotations.BeforeClass; |
43 |
|
import org.testng.annotations.BeforeMethod; |
44 |
|
import org.testng.annotations.Test; |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (41) |
Complexity: 8 |
Complexity Density: 0.24 |
|
46 |
|
public class AlignCalcManagerTest |
47 |
|
{ |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
49 |
1 |
@BeforeClass(alwaysRun = true)... |
50 |
|
public void setUpJvOptionPane() |
51 |
|
{ |
52 |
1 |
JvOptionPane.setInteractiveMode(false); |
53 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
54 |
|
} |
55 |
|
|
56 |
|
private AlignFrame alignFrame; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 2 |
Complexity Density: 0.08 |
1PASS
|
|
63 |
1 |
@Test(groups = "Functional")... |
64 |
|
public void testRemoveWorkerForAnnotation() |
65 |
|
{ |
66 |
1 |
AlignCalcManagerI acm = alignFrame.getViewport().getCalcManager(); |
67 |
1 |
final AlignmentAnnotation ann1 = new AlignmentAnnotation("Ann1", "desc", |
68 |
|
new Annotation[] {}); |
69 |
1 |
final AlignmentAnnotation ann2 = new AlignmentAnnotation("Ann2", "desc", |
70 |
|
new Annotation[] {}); |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
1 |
AlignCalcWorkerI worker1 = makeWorker(ann1, true); |
77 |
1 |
AlignCalcWorkerI worker2 = makeWorker(ann1, false); |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
1 |
synchronized (this) |
89 |
|
{ |
90 |
1 |
try |
91 |
|
{ |
92 |
1 |
wait(100); |
93 |
|
} catch (InterruptedException e) |
94 |
|
{ |
95 |
|
|
96 |
|
} |
97 |
|
} |
98 |
|
|
99 |
1 |
List<AlignCalcWorkerI> workers = acm |
100 |
|
.getRegisteredWorkersOfClass(worker1.getClass()); |
101 |
1 |
assertEquals(2, workers.size()); |
102 |
1 |
assertTrue(workers.contains(worker1)); |
103 |
1 |
assertTrue(workers.contains(worker2)); |
104 |
1 |
assertFalse(acm.isDisabled(worker1)); |
105 |
1 |
assertFalse(acm.isDisabled(worker2)); |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
1 |
acm.removeWorkerForAnnotation(ann2); |
111 |
1 |
assertTrue(acm.getRegisteredWorkersOfClass(worker1.getClass()) |
112 |
|
.contains(worker1)); |
113 |
1 |
assertTrue(acm.getRegisteredWorkersOfClass(worker1.getClass()) |
114 |
|
.contains(worker2)); |
115 |
1 |
assertFalse(acm.isDisabled(worker1)); |
116 |
1 |
assertFalse(acm.isDisabled(worker2)); |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
1 |
acm.removeWorkerForAnnotation(ann1); |
123 |
1 |
assertEquals(1, |
124 |
|
acm.getRegisteredWorkersOfClass(worker1.getClass()).size()); |
125 |
1 |
assertTrue(acm.getRegisteredWorkersOfClass(worker1.getClass()) |
126 |
|
.contains(worker2)); |
127 |
1 |
assertFalse(acm.isDisabled(worker1)); |
128 |
1 |
assertFalse(acm.isDisabled(worker2)); |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
@param |
135 |
|
@param |
136 |
|
@return |
137 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
138 |
2 |
AnnotationWorker makeWorker(final AlignmentAnnotation ann,... |
139 |
|
final boolean deletable) |
140 |
|
{ |
141 |
2 |
AnnotationProviderI annotationProvider = new AnnotationProviderI() |
142 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
2 |
@Override... |
144 |
|
public List<AlignmentAnnotation> calculateAnnotation(AlignmentI al, |
145 |
|
FeatureRenderer fr) |
146 |
|
{ |
147 |
2 |
return Collections.singletonList(ann); |
148 |
|
} |
149 |
|
}; |
150 |
2 |
return new AnnotationWorker(alignFrame.getViewport(), |
151 |
|
alignFrame.alignPanel, annotationProvider) |
152 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
153 |
2 |
@Override... |
154 |
|
public boolean isDeletable() |
155 |
|
{ |
156 |
2 |
return deletable; |
157 |
|
} |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
159 |
4 |
@Override... |
160 |
|
public boolean involves(AlignmentAnnotation ann1) |
161 |
|
{ |
162 |
4 |
return ann == ann1; |
163 |
|
} |
164 |
|
}; |
165 |
|
} |
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
167 |
1 |
@BeforeMethod(alwaysRun = true)... |
168 |
|
public void setUp() |
169 |
|
{ |
170 |
1 |
AlignmentI al = new Alignment( |
171 |
|
new SequenceI[] |
172 |
|
{ new Sequence("Seq1", "ABC") }); |
173 |
1 |
al.setDataset(null); |
174 |
1 |
alignFrame = new AlignFrame(al, 3, 1); |
175 |
|
} |
176 |
|
} |