Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package jalview.gui

File AnnotationLabelsTest.java

 

Code metrics

0
52
2
1
153
82
2
0.04
26
2
1

Classes

Class Line # Actions
AnnotationLabelsTest 11 52 2
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

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   
 
11    public class AnnotationLabelsTest
12    {
 
13  1 toggle @Test(groups = "Functional")
14    public void testGetTooltip()
15    {
16  1 assertNull(AnnotationLabels.getTooltip(null));
17   
18    /*
19    * simple description only
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    * description needing html encoding
28    * (no idea why '<' is encoded but '>' is not)
29    */
30  1 ann.description = "TCoffee scores < 56 and > 28";
31  1 expected = "<html>TCoffee scores &lt; 56 and > 28</html>";
32  1 assertEquals(AnnotationLabels.getTooltip(ann), expected);
33   
34    /*
35    * description already html formatted
36    */
37  1 ann.description = "<html>hello world</html>";
38  1 assertEquals(AnnotationLabels.getTooltip(ann), ann.description);
39   
40    /*
41    * simple description and score
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    * html description and score
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    * score, no description
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    * sequenceref, simple description
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 &lt; 12</html>";
74  1 assertEquals(AnnotationLabels.getTooltip(ann), expected);
75   
76    /*
77    * sequenceref, html description, score
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    * no score, null description
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    * no score, empty description, sequenceRef
95    */
96  1 ann.description = "";
97  1 assertEquals(AnnotationLabels.getTooltip(ann), "<html>Seq1 :</html>");
98   
99    /*
100    * no score, empty description, no sequenceRef
101    */
102  1 ann.sequenceRef = null;
103  1 assertNull(AnnotationLabels.getTooltip(ann));
104    }
105   
 
106  1 toggle @Test(groups = "Functional")
107    public void testGetStatusMessage()
108    {
109  1 assertNull(AnnotationLabels.getStatusMessage(null, null));
110   
111    /*
112    * simple label
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    * with sequence ref
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    * with graph group (degenerate, one annotation only)
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    * graph group with two members; note labels are appended in
138    * reverse order (matching rendering order on screen)
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    * graph group with no sequence ref
147    */
148  1 aa.sequenceRef = null;
149  1 assertEquals(
150    AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
151    { aa, aa2 }), "IUPredWS Long, IUPredWS Short");
152    }
153    }