Merge branch 'bugs/JAL-2780_JAL-2781_pdbnegativenums' into releases/Release_2_10_4_Branch
[jalview.git] / test / jalview / datamodel / AlignmentTest.java
index 4b5d096..74ac146 100644 (file)
@@ -668,6 +668,17 @@ public class AlignmentTest
     // third found.. so
     assertFalse(iter.hasNext());
 
+    // search for annotation on one sequence with a particular label - expect
+    // one
+    SequenceI sqfound;
+    anns = al.findAnnotations(sqfound = al.getSequenceAt(1), null,
+            "Secondary Structure");
+    iter = anns.iterator();
+    assertTrue(iter.hasNext());
+    // expect reference to sequence 1 in the alignment
+    assertTrue(sqfound == iter.next().sequenceRef);
+    assertFalse(iter.hasNext());
+
     // null on all parameters == find all annotations
     anns = al.findAnnotations(null, null, null);
     iter = anns.iterator();
@@ -1321,4 +1332,22 @@ public class AlignmentTest
     // todo test coverage for annotations, mappings, groups,
     // hidden sequences, properties
   }
+
+  /**
+   * test that calcId == null on findOrCreate doesn't raise an NPE, and yields
+   * an annotation with a null calcId
+   * 
+   */
+  @Test(groups = "Functional")
+  public void testFindOrCreateForNullCalcId()
+  {
+    SequenceI seq = new Sequence("seq1", "FRMLPSRT-A--L-");
+    AlignmentI alignment = new Alignment(new SequenceI[] { seq });
+
+    AlignmentAnnotation ala = alignment.findOrCreateAnnotation(
+            "Temperature Factor", null, false, seq, null);
+    assertNotNull(ala);
+    assertEquals(seq, ala.sequenceRef);
+    assertEquals("", ala.calcId);
+  }
 }