JAL-2226 new method to search for annotation matching particular description as well...
[jalview.git] / test / jalview / datamodel / SequenceTest.java
index 6d07113..eb75645 100644 (file)
@@ -192,6 +192,35 @@ public class SequenceTest
     assertTrue(seq.getAlignmentAnnotations(null, null).isEmpty());
   }
 
+
+  @Test(groups = { "Functional" })
+  public void testGetAlignmentAnnotations_forCalcIdLabelAndDescription()
+  {
+    addAnnotation("label1", "desc1", "calcId1", 1f);
+    AlignmentAnnotation ann2 = addAnnotation("label2", "desc2", "calcId2",
+            1f);
+    addAnnotation("label2", "desc3", "calcId3", 1f);
+    AlignmentAnnotation ann4 = addAnnotation("label2", "desc3", "calcId2",
+            1f);
+    addAnnotation("label5", "desc3", null, 1f);
+    addAnnotation(null, "desc3", "calcId3", 1f);
+
+    List<AlignmentAnnotation> anns = seq.getAlignmentAnnotations("calcId2",
+            "label2", "desc3");
+    assertEquals(1, anns.size());
+    assertSame(ann4, anns.get(0));
+    /**
+     * null matching should fail
+     */
+    assertTrue(seq.getAlignmentAnnotations("calcId3", "label2",null).isEmpty());
+    
+    assertTrue(seq.getAlignmentAnnotations("calcId2", "label3",null).isEmpty());
+    assertTrue(seq.getAlignmentAnnotations("calcId3", "label5",null).isEmpty());
+    assertTrue(seq.getAlignmentAnnotations("calcId2", null,null).isEmpty());
+    assertTrue(seq.getAlignmentAnnotations(null, "label3",null).isEmpty());
+    assertTrue(seq.getAlignmentAnnotations(null, null,null).isEmpty());
+  }
+
   /**
    * Tests for addAlignmentAnnotation. Note this method has the side-effect of
    * setting the sequenceRef on the annotation. Adding the same annotation twice