JAL-1610 check reference annotations against alignment, not sequence
[jalview.git] / test / jalview / datamodel / SequenceTest.java
index d9101cf..3f91710 100644 (file)
@@ -88,7 +88,8 @@ public class SequenceTest
 
   /**
    * 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()
@@ -102,5 +103,21 @@ public class SequenceTest
     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]);
+
   }
 }