Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 14:43:25 GMT
  2. Package jalview.datamodel

File AnnotationTest.java

 

Code metrics

0
16
6
1
82
73
6
0.38
2.67
6
1

Classes

Class Line # Actions
AnnotationTest 13 16 6
1.0100%
 

Contributing tests

This file is covered by 17 tests. .

Source view

1    package jalview.datamodel;
2   
3    import static org.hamcrest.MatcherAssert.assertThat;
4    import static org.hamcrest.Matchers.equalTo;
5    import static org.hamcrest.Matchers.is;
6    import static org.hamcrest.Matchers.nullValue;
7   
8    import java.awt.Color;
9   
10    import org.testng.annotations.DataProvider;
11    import org.testng.annotations.Test;
12   
 
13    public class AnnotationTest
14    {
 
15  1 toggle @Test(groups = "Functional")
16    public void testConstructor_ValueOnly()
17    {
18  1 var annotation = new Annotation(0.5f);
19  1 assertThat(annotation.displayCharacter, nullValue());
20  1 assertThat(annotation.description, nullValue());
21  1 assertThat(annotation.secondaryStructure, is(' '));
22  1 assertThat(annotation.value, is(0.5f));
23  1 assertThat(annotation.colour, is(nullValue()));
24    }
25   
 
26  1 toggle @Test(groups = "Functional")
27    public void testCopyConstructor_NullValue_EmptyAnnotationCreated()
28    {
29  1 var annotation = new Annotation((Annotation) null);
30  1 assertThat(annotation.displayCharacter, equalTo(""));
31  1 assertThat(annotation.description, equalTo(""));
32  1 assertThat(annotation.secondaryStructure, is(' '));
33  1 assertThat(annotation.value, is(0.0f));
34  1 assertThat(annotation.colour, is(nullValue()));
35    }
36   
 
37  1 toggle @DataProvider
38    public Object[] emptyAnnotations()
39    {
40  1 return new Object[] {
41    Annotation.EMPTY_ANNOTATION, new Annotation(0.0f),
42    new Annotation((Annotation) null),
43    new Annotation(Annotation.EMPTY_ANNOTATION),
44    new Annotation("", "", ' ', 0.0f),
45    new Annotation(null, null, ' ', 0.0f),
46    new Annotation("", "", '\0', 0.0f), new Annotation("", null, ' ', 0.0f),
47    new Annotation(null, "", ' ', 0.0f), new Annotation(" ", "", ' ', 0.0f),
48    new Annotation(" .", "", ' ', 0.0f), new Annotation("", " ", ' ', 0.0f),
49    new Annotation("", "", ' ', 0.0f, null),
50    new Annotation("", " ", ' ', 0.0f),
51    new Annotation("", "\n", ' ', 0.0f), };
52    }
53   
 
54  15 toggle @Test(groups = "Functional", dataProvider = "emptyAnnotations")
55    public void testIsWhitespace_EmptyAnnotations(Annotation annot)
56    {
57  15 assertThat("Annotation " + annot + " is not whitespace, but should be",
58    annot.isWhitespace());
59    }
60   
 
61  1 toggle @DataProvider
62    public Object[] nonEmptyAnnotations()
63    {
64  1 return new Object[] {
65    new Annotation(0.4f),
66    new Annotation(new Annotation(0.1f)),
67    new Annotation("A", "", ' ', 0.0f),
68    new Annotation("", "", ' ', 0.0f, Color.WHITE),
69    new Annotation(null, null, ' ', -0.1f),
70    new Annotation(null, null, 'A', 0.0f),
71    new Annotation(null, "desc", ' ', 0.0f),
72    new Annotation("0", "<nil>", '\0', 0.0f),
73    };
74    }
75   
 
76  8 toggle @Test(groups = "Functional", dataProvider = "nonEmptyAnnotations")
77    public void testIsWhitespace_NonEmptyAnnotation(Annotation annot)
78    {
79  8 assertThat("Annotation " + annot + " is whitespace, but should not be",
80    !annot.isWhitespace());
81    }
82    }