1 package jalview.datamodel;
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;
10 import org.testng.annotations.DataProvider;
11 import org.testng.annotations.Test;
13 public class AnnotationTest
15 @Test(groups = "Functional")
16 public void testConstructor_ValueOnly()
18 var annotation = new Annotation(0.5f);
19 assertThat(annotation.displayCharacter, nullValue());
20 assertThat(annotation.description, nullValue());
21 assertThat(annotation.secondaryStructure, is(' '));
22 assertThat(annotation.value, is(0.5f));
23 assertThat(annotation.colour, is(nullValue()));
26 @Test(groups = "Functional")
27 public void testCopyConstructor_NullValue_EmptyAnnotationCreated()
29 var annotation = new Annotation((Annotation) null);
30 assertThat(annotation.displayCharacter, equalTo(""));
31 assertThat(annotation.description, equalTo(""));
32 assertThat(annotation.secondaryStructure, is(' '));
33 assertThat(annotation.value, is(0.0f));
34 assertThat(annotation.colour, is(nullValue()));
38 public Object[] emptyAnnotations()
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), };
54 @Test(groups = "Functional", dataProvider = "emptyAnnotations")
55 public void testIsWhitespace_EmptyAnnotations(Annotation annot)
57 assertThat("Annotation " + annot + " is not whitespace, but should be",
58 annot.isWhitespace());
62 public Object[] nonEmptyAnnotations()
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),
76 @Test(groups = "Functional", dataProvider = "nonEmptyAnnotations")
77 public void testIsWhitespace_NonEmptyAnnotation(Annotation annot)
79 assertThat("Annotation " + annot + " is whitespace, but should not be",
80 !annot.isWhitespace());