/**
* Tests for addAlignmentAnnotation. Note this method has the side-effect of
- * setting the sequenceRef on the annotation.
+ * setting the sequenceRef on the annotation. Adding the same annotation twice
+ * should be ignored.
*/
@Test
public void testAddAlignmentAnnotation()
AlignmentAnnotation[] anns = seq.getAnnotation();
assertEquals(1, anns.length);
assertSame(annotation, anns[0]);
+
+ // re-adding does nothing
+ seq.addAlignmentAnnotation(annotation);
+ anns = seq.getAnnotation();
+ assertEquals(1, anns.length);
+ assertSame(annotation, anns[0]);
+
+ // an identical but different annotation can be added
+ final AlignmentAnnotation annotation2 = new AlignmentAnnotation("a",
+ "b", 2d);
+ seq.addAlignmentAnnotation(annotation2);
+ anns = seq.getAnnotation();
+ assertEquals(2, anns.length);
+ assertSame(annotation, anns[0]);
+ assertSame(annotation2, anns[1]);
+
}
}