import static jalview.datamodel.Annotation.EMPTY_ANNOTATION;
import static jalview.testutils.Matchers.matchesAnnotations;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.*;
import static org.testng.Assert.assertNull;
import static org.testng.AssertJUnit.assertEquals;
matchesAnnotations(new Annotation(1), new Annotation(2),
new Annotation(3), new Annotation(8), new Annotation(9)));
}
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateNegativeStart()
+ {
+ Annotation[] annots = annotsRange(8);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(-5, 1, hc);
+ assertThat(ann.annotations,
+ matchesAnnotations(new Annotation(0), new Annotation(1)));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateNegativeStartAndEnd()
+ {
+ Annotation[] annots = annotsRange(8);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(-5, -2, hc);
+ assertThat(ann.annotations, is(emptyArray()));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateEndBeyondSize()
+ {
+ Annotation[] annots = annotsRange(8);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(6, 10, hc);
+ assertThat(ann.annotations, matchesAnnotations(new Annotation(6), new Annotation(7)));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateStartAndEndBeyondSize()
+ {
+ Annotation[] annots = annotsRange(4);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(6, 10, hc);
+ assertThat(ann.annotations, is(emptyArray()));
+ }
+
+ static Annotation[] annotsRange(int stop)
+ {
+ Annotation[] annotations = new Annotation[stop];
+ for (int i = 0; i < stop; i++)
+ annotations[i] = new Annotation(i);
+ return annotations;
+ }
}