3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertNull;
6 import jalview.datamodel.AlignmentAnnotation;
7 import jalview.datamodel.Sequence;
9 import org.testng.annotations.Test;
11 public class AnnotationLabelsTest
13 @Test(groups = "Functional")
14 public void testGetTooltip()
16 assertNull(AnnotationLabels.getTooltip(null));
19 * simple description only
21 AlignmentAnnotation ann = new AlignmentAnnotation("thelabel", "thedesc",
23 String expected = "<html>thedesc</html>";
24 assertEquals(AnnotationLabels.getTooltip(ann), expected);
27 * description needing html encoding
28 * (no idea why '<' is encoded but '>' is not)
30 ann.description = "TCoffee scores < 56 and > 28";
31 expected = "<html>TCoffee scores < 56 and > 28</html>";
32 assertEquals(AnnotationLabels.getTooltip(ann), expected);
35 * description already html formatted
37 ann.description = "<html>hello world</html>";
38 assertEquals(AnnotationLabels.getTooltip(ann), ann.description);
41 * simple description and score
43 ann.description = "hello world";
45 expected = "<html>hello world<br/> Score: 2.34</html>";
46 assertEquals(AnnotationLabels.getTooltip(ann), expected);
49 * html description and score
51 ann.description = "<html>hello world</html>";
53 expected = "<html>hello world<br/> Score: 2.34</html>";
54 assertEquals(AnnotationLabels.getTooltip(ann), expected);
57 * score, no description
59 ann.description = " ";
60 assertEquals(AnnotationLabels.getTooltip(ann),
61 "<html> Score: 2.34</html>");
62 ann.description = null;
63 assertEquals(AnnotationLabels.getTooltip(ann),
64 "<html> Score: 2.34</html>");
67 * sequenceref, simple description
69 ann.description = "Count < 12";
70 ann.sequenceRef = new Sequence("Seq1", "MLRIQST");
72 ann.score = Double.NaN;
73 expected = "<html>Seq1 : Count < 12</html>";
74 assertEquals(AnnotationLabels.getTooltip(ann), expected);
77 * sequenceref, html description, score
79 ann.description = "<html>Score < 4.8</html>";
80 ann.sequenceRef = new Sequence("Seq1", "MLRIQST");
82 expected = "<html>Seq1 : Score < 4.8<br/> Score: -2.1</html>";
83 assertEquals(AnnotationLabels.getTooltip(ann), expected);
86 * no score, null description
88 ann.description = null;
90 ann.score = Double.NaN;
91 assertNull(AnnotationLabels.getTooltip(ann));
94 * no score, empty description, sequenceRef
97 assertEquals(AnnotationLabels.getTooltip(ann), "<html>Seq1 :</html>");
100 * no score, empty description, no sequenceRef
102 ann.sequenceRef = null;
103 assertNull(AnnotationLabels.getTooltip(ann));
106 @Test(groups = "Functional")
107 public void testGetStatusMessage()
109 assertNull(AnnotationLabels.getStatusMessage(null, null));
114 AlignmentAnnotation aa = new AlignmentAnnotation("IUPredWS Short",
115 "Protein disorder", null);
116 assertEquals(AnnotationLabels.getStatusMessage(aa, null),
122 aa.setSequenceRef(new Sequence("FER_CAPAA", "MIGRKQL"));
123 assertEquals(AnnotationLabels.getStatusMessage(aa, null),
124 "FER_CAPAA : IUPredWS Short");
127 * with graph group (degenerate, one annotation only)
130 AlignmentAnnotation aa2 = new AlignmentAnnotation("IUPredWS Long",
131 "Protein disorder", null);
133 AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
134 { aa, aa2 }), "FER_CAPAA : IUPredWS Short");
137 * graph group with two members; note labels are appended in
138 * reverse order (matching rendering order on screen)
142 AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
143 { aa, aa2 }), "FER_CAPAA : IUPredWS Long, IUPredWS Short");
146 * graph group with no sequence ref
148 aa.sequenceRef = null;
150 AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
151 { aa, aa2 }), "IUPredWS Long, IUPredWS Short");