2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertNull;
26 import jalview.datamodel.AlignmentAnnotation;
27 import jalview.datamodel.Sequence;
29 import org.testng.annotations.Test;
31 public class AnnotationLabelsTest
33 @Test(groups = "Functional")
34 public void testGetTooltip()
36 assertNull(AnnotationLabels.getTooltip(null));
39 * simple description only
41 AlignmentAnnotation ann = new AlignmentAnnotation("thelabel", "thedesc",
43 String expected = "<html>thedesc</html>";
44 assertEquals(AnnotationLabels.getTooltip(ann), expected);
47 * description needing html encoding
48 * (no idea why '<' is encoded but '>' is not)
50 ann.description = "TCoffee scores < 56 and > 28";
51 expected = "<html>TCoffee scores < 56 and > 28</html>";
52 assertEquals(AnnotationLabels.getTooltip(ann), expected);
55 * description already html formatted
57 ann.description = "<html>hello world</html>";
58 assertEquals(AnnotationLabels.getTooltip(ann), ann.description);
61 * simple description and score
63 ann.description = "hello world";
65 expected = "<html>hello world<br/> Score: 2.34</html>";
66 assertEquals(AnnotationLabels.getTooltip(ann), expected);
69 * html description and score
71 ann.description = "<html>hello world</html>";
73 expected = "<html>hello world<br/> Score: 2.34</html>";
74 assertEquals(AnnotationLabels.getTooltip(ann), expected);
77 * score, no description
79 ann.description = " ";
80 assertEquals(AnnotationLabels.getTooltip(ann),
81 "<html> Score: 2.34</html>");
82 ann.description = null;
83 assertEquals(AnnotationLabels.getTooltip(ann),
84 "<html> Score: 2.34</html>");
87 * sequenceref, simple description
89 ann.description = "Count < 12";
90 ann.sequenceRef = new Sequence("Seq1", "MLRIQST");
92 ann.score = Double.NaN;
93 expected = "<html>Seq1 : Count < 12</html>";
94 assertEquals(AnnotationLabels.getTooltip(ann), expected);
97 * sequenceref, html description, score
99 ann.description = "<html>Score < 4.8</html>";
100 ann.sequenceRef = new Sequence("Seq1", "MLRIQST");
102 expected = "<html>Seq1 : Score < 4.8<br/> Score: -2.1</html>";
103 assertEquals(AnnotationLabels.getTooltip(ann), expected);
106 * no score, null description
108 ann.description = null;
109 ann.hasScore = false;
110 ann.score = Double.NaN;
111 assertNull(AnnotationLabels.getTooltip(ann));
114 * no score, empty description, sequenceRef
116 ann.description = "";
117 assertEquals(AnnotationLabels.getTooltip(ann), "<html>Seq1 :</html>");
120 * no score, empty description, no sequenceRef
122 ann.sequenceRef = null;
123 assertNull(AnnotationLabels.getTooltip(ann));
126 @Test(groups = "Functional")
127 public void testGetStatusMessage()
129 assertNull(AnnotationLabels.getStatusMessage(null, null));
134 AlignmentAnnotation aa = new AlignmentAnnotation("IUPredWS Short",
135 "Protein disorder", null);
136 assertEquals(AnnotationLabels.getStatusMessage(aa, null),
142 aa.setSequenceRef(new Sequence("FER_CAPAA", "MIGRKQL"));
143 assertEquals(AnnotationLabels.getStatusMessage(aa, null),
144 "FER_CAPAA : IUPredWS Short");
147 * with graph group (degenerate, one annotation only)
150 AlignmentAnnotation aa2 = new AlignmentAnnotation("IUPredWS Long",
151 "Protein disorder", null);
153 AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
154 { aa, aa2 }), "FER_CAPAA : IUPredWS Short");
157 * graph group with two members; note labels are appended in
158 * reverse order (matching rendering order on screen)
162 AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
163 { aa, aa2 }), "FER_CAPAA : IUPredWS Long, IUPredWS Short");
166 * graph group with no sequence ref
168 aa.sequenceRef = null;
170 AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
171 { aa, aa2 }), "IUPredWS Long, IUPredWS Short");