X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FAlignmentTest.java;h=d6e09fdb48d99129030e5c20c99b73655ed390b4;hb=f782e40f6f1b3f2bb22927891493c5faf318625b;hp=c5d09c16eeccff48b0a518c82376cc957a7bcc61;hpb=f5c4a8a268a77ac474addbc778e85b75ffa05da3;p=jalview.git diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index c5d09c1..d6e09fd 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -620,6 +620,67 @@ public class AlignmentTest assertFalse(iter.hasNext()); } + /** + * Test method that returns annotations that match on reference sequence, + * label, or calcId. + */ + @Test(groups = { "Functional" }) + public void testFindAnnotations_bySeqLabelandorCalcId() + { + // TODO: finish testFindAnnotations_bySeqLabelandorCalcId test + /* Note - this is an incomplete test - need to check null or + * non-null [ matches, not matches ] behaviour for each of the three + * parameters..*/ + + // search for a single, unique calcId with wildcards on other params + Iterable anns = al.findAnnotations(null, + "CalcIdForD.melanogaster.2", null); + Iterator iter = anns.iterator(); + assertTrue(iter.hasNext()); + AlignmentAnnotation ann = iter.next(); + assertEquals("D.melanogaster.2", ann.sequenceRef.getName()); + assertFalse(iter.hasNext()); + + // save reference to test sequence reference parameter + SequenceI rseq = ann.sequenceRef; + + // search for annotation associated with a single sequence + anns = al.findAnnotations(rseq, null, null); + iter = anns.iterator(); + assertTrue(iter.hasNext()); + ann = iter.next(); + assertEquals("D.melanogaster.2", ann.sequenceRef.getName()); + assertFalse(iter.hasNext()); + + // search for annotation with a non-existant calcId + anns = al.findAnnotations(null, "CalcIdForD.melanogaster.?", null); + iter = anns.iterator(); + assertFalse(iter.hasNext()); + + // search for annotation with a particular label - expect three + anns = al.findAnnotations(null, null, "Secondary Structure"); + iter = anns.iterator(); + assertTrue(iter.hasNext()); + iter.next(); + assertTrue(iter.hasNext()); + iter.next(); + assertTrue(iter.hasNext()); + iter.next(); + // third found.. so + assertFalse(iter.hasNext()); + + // null on all parameters == find all annotations + anns = al.findAnnotations(null, null, null); + iter = anns.iterator(); + int n = al.getAlignmentAnnotation().length; + while (iter.hasNext()) + { + n--; + iter.next(); + } + assertTrue("Found " + n + " fewer annotations from search.", n == 0); + } + @Test(groups = { "Functional" }) public void testDeleteAllAnnotations_includingAutocalculated() {