1 package jalview.testutils;
3 import org.testng.annotations.DataProvider;
4 import org.testng.annotations.Test;
5 import jalview.datamodel.Annotation;
7 import static org.hamcrest.MatcherAssert.assertThat;
12 public class AnnotationsMatcherTest
15 public Object[][] matchingAnnotationsLists()
17 return new Object[][] {
20 new Annotation("C", "", 'C', 0.0f),
21 new Annotation("C", "", 'C', 0.1f),
22 new Annotation("B", "", 'B', 0.2f) },
24 new Annotation("C", "", 'C', 0.0f),
25 new Annotation("C", "", 'C', 0.1f),
26 new Annotation("B", "", 'B', 0.2f) } },
29 new Annotation("X", "xxx", 'X', 1.3f),
30 new Annotation("V", "vvv", 'V', 1.5f),
31 new Annotation("B", "bbb", 'B', 2.5f) },
33 new Annotation("X", "xxx", 'X', 1.3f),
34 new Annotation("V", "vvv", 'V', 1.5f),
35 new Annotation("B", "bbb", 'B', 2.5f) } },
38 new Annotation("A", "", 'A', 0.2f, Color.RED),
39 new Annotation("A", "", 'A', 0.3f, Color.GREEN),
40 new Annotation("C", "", 'C', 0.4f, Color.YELLOW),
41 new Annotation("C", "", 'C', 0.5f) },
43 new Annotation("A", "", 'A', 0.2f, Color.RED),
44 new Annotation("A", "", 'A', 0.3f, Color.GREEN),
45 new Annotation("C", "", 'C', 0.4f, Color.YELLOW),
46 new Annotation("C", "", 'C', 0.5f) } },
49 Annotation.EMPTY_ANNOTATION, Annotation.EMPTY_ANNOTATION },
51 Annotation.EMPTY_ANNOTATION, Annotation.EMPTY_ANNOTATION } } };
54 @Test(groups = { "Functional" }, dataProvider = "matchingAnnotationsLists")
55 public void testMatchesSafely_matchingAnnotations(Annotation[] template,
56 Annotation[] testdata)
58 assert new AnnotationsMatcher(Arrays.asList(template))
59 .matchesSafely(testdata);
63 public Object[][] matchingAnnotations()
65 return new Object[][] {
67 new Annotation("A", "aaa", 'A', 0.1f),
68 new Annotation("A", "aaa", 'A', 0.1f) },
70 new Annotation("A", "abcdef", 'A', 0.1f, Color.RED),
71 new Annotation("A", "abcdef", 'A', 0.1f, Color.RED) },
73 new Annotation("", "xxxx", ' ', 0.0f),
74 new Annotation("", "xxxx", ' ', 0.0f) },
76 new Annotation("", "", ' ', 0.0f),
77 new Annotation("", "", ' ', 0.0f) },
79 new Annotation(null, null, ' ', 0.0f),
80 new Annotation(null, null, ' ', 0.0f) },
82 new Annotation(null, "", ' ', 0.0f),
83 new Annotation("", null, ' ', 0.0f) } };
86 @Test(groups = { "Functional" }, dataProvider = "matchingAnnotations")
87 public void testAnnotationsEqual_matchingAnnotations(Annotation first,
90 assert AnnotationsMatcher.annotationsEqual(first, second);
93 @Test(groups = { "Functional" })
94 public void testAnnotationsEqual_compareNullDisplayCharToEmpty()
96 assert AnnotationsMatcher
97 .annotationsEqual(new Annotation("", "description", 'A', 0.1f),
98 new Annotation(null, "description", 'A', 0.1f));
99 assert AnnotationsMatcher
100 .annotationsEqual(new Annotation(null, "description", 'A', 0.1f),
101 new Annotation("", "description", 'A', 0.1f));
104 @Test(groups = { "Functional" })
105 public void testAnnotationsEqual_compareNullDescriptionToEmpty()
107 assert AnnotationsMatcher
108 .annotationsEqual(new Annotation("A", null, 'A', 0.2f),
109 new Annotation("A", "", 'A', 0.2f));
110 assert AnnotationsMatcher
111 .annotationsEqual(new Annotation("A", "", 'A', 0.2f),
112 new Annotation("A", null, 'A', 0.2f));
115 @Test(groups = { "Functional" })
116 public void testAnnotationsEqual_compareNullDisplayCharToBlank()
118 assert !AnnotationsMatcher
119 .annotationsEqual(new Annotation(" ", "aaa", 'A', 0.03f),
120 new Annotation(null, "aaa", 'A', 0.03f));
121 assert !AnnotationsMatcher
122 .annotationsEqual(new Annotation(null, "aaa", 'A', 0.04f),
123 new Annotation(" ", "aaa", 'A', 0.04f));
126 @Test(groups = { "Functional" })
127 public void testAnnotationsEqual_compareNullDescriptionToBlank()
129 assert !AnnotationsMatcher
130 .annotationsEqual(new Annotation("A", null, 'A', 0.0f),
131 new Annotation("A", " ", 'A', 0.0f));
132 assert !AnnotationsMatcher
133 .annotationsEqual(new Annotation("A", " ", 'A', 0.01f),
134 new Annotation("A", null, 'A', 0.01f));