1 |
|
package jalview.gui; |
2 |
|
|
3 |
|
import static org.testng.Assert.assertEquals; |
4 |
|
import static org.testng.Assert.assertNull; |
5 |
|
|
6 |
|
import jalview.datamodel.AlignmentAnnotation; |
7 |
|
import jalview.datamodel.Sequence; |
8 |
|
|
9 |
|
import org.testng.annotations.Test; |
10 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (54) |
Complexity: 2 |
Complexity Density: 0.04 |
|
11 |
|
public class AnnotationLabelsTest |
12 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (40) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
13 |
1 |
@Test(groups = "Functional")... |
14 |
|
public void testGetTooltip() |
15 |
|
{ |
16 |
1 |
assertNull(AnnotationLabels.getTooltip(null)); |
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
1 |
AlignmentAnnotation ann = new AlignmentAnnotation("thelabel", "thedesc", |
22 |
|
null); |
23 |
1 |
String expected = "<html>thedesc</html>"; |
24 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), expected); |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
1 |
ann.description = "TCoffee scores < 56 and > 28"; |
31 |
1 |
expected = "<html>TCoffee scores < 56 and > 28</html>"; |
32 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), expected); |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
1 |
ann.description = "<html>hello world</html>"; |
38 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), ann.description); |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
1 |
ann.description = "hello world"; |
44 |
1 |
ann.setScore(2.34d); |
45 |
1 |
expected = "<html>hello world<br/> Score: 2.34</html>"; |
46 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), expected); |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
1 |
ann.description = "<html>hello world</html>"; |
52 |
1 |
ann.setScore(2.34d); |
53 |
1 |
expected = "<html>hello world<br/> Score: 2.34</html>"; |
54 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), expected); |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
1 |
ann.description = " "; |
60 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), |
61 |
|
"<html> Score: 2.34</html>"); |
62 |
1 |
ann.description = null; |
63 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), |
64 |
|
"<html> Score: 2.34</html>"); |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
1 |
ann.description = "Count < 12"; |
70 |
1 |
ann.sequenceRef = new Sequence("Seq1", "MLRIQST"); |
71 |
1 |
ann.hasScore = false; |
72 |
1 |
ann.score = Double.NaN; |
73 |
1 |
expected = "<html>Seq1 : Count < 12</html>"; |
74 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), expected); |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
1 |
ann.description = "<html>Score < 4.8</html>"; |
80 |
1 |
ann.sequenceRef = new Sequence("Seq1", "MLRIQST"); |
81 |
1 |
ann.setScore(-2.1D); |
82 |
1 |
expected = "<html>Seq1 : Score < 4.8<br/> Score: -2.1</html>"; |
83 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), expected); |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
1 |
ann.description = null; |
89 |
1 |
ann.hasScore = false; |
90 |
1 |
ann.score = Double.NaN; |
91 |
1 |
assertNull(AnnotationLabels.getTooltip(ann)); |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
1 |
ann.description = ""; |
97 |
1 |
assertEquals(AnnotationLabels.getTooltip(ann), "<html>Seq1 :</html>"); |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
1 |
ann.sequenceRef = null; |
103 |
1 |
assertNull(AnnotationLabels.getTooltip(ann)); |
104 |
|
} |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
106 |
1 |
@Test(groups = "Functional")... |
107 |
|
public void testGetStatusMessage() |
108 |
|
{ |
109 |
1 |
assertNull(AnnotationLabels.getStatusMessage(null, null)); |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
1 |
AlignmentAnnotation aa = new AlignmentAnnotation("IUPredWS Short", |
115 |
|
"Protein disorder", null); |
116 |
1 |
assertEquals(AnnotationLabels.getStatusMessage(aa, null), |
117 |
|
"IUPredWS Short"); |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
1 |
aa.setSequenceRef(new Sequence("FER_CAPAA", "MIGRKQL")); |
123 |
1 |
assertEquals(AnnotationLabels.getStatusMessage(aa, null), |
124 |
|
"FER_CAPAA : IUPredWS Short"); |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
1 |
aa.graphGroup = 1; |
130 |
1 |
AlignmentAnnotation aa2 = new AlignmentAnnotation("IUPredWS Long", |
131 |
|
"Protein disorder", null); |
132 |
1 |
assertEquals( |
133 |
|
AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[] |
134 |
|
{ aa, aa2 }), "FER_CAPAA : IUPredWS Short"); |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
1 |
aa2.graphGroup = 1; |
141 |
1 |
assertEquals( |
142 |
|
AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[] |
143 |
|
{ aa, aa2 }), "FER_CAPAA : IUPredWS Long, IUPredWS Short"); |
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
1 |
aa.sequenceRef = null; |
149 |
1 |
assertEquals( |
150 |
|
AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[] |
151 |
|
{ aa, aa2 }), "IUPredWS Long, IUPredWS Short"); |
152 |
|
} |
153 |
|
} |