X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FAllRowsIteratorTest.java;h=9f4c65b644667ca2caff724758549d5e72b62182;hb=refs%2Fheads%2Fpatch%2FJAL-4062_sort_and_merge_contiguousregions;hp=fd1d29d67c81a45b43d3f01ff9e620b14f3b1ee3;hpb=2ca081eebf90c6731cd79bde140ca2fecc9c9644;p=jalview.git diff --git a/test/jalview/datamodel/AllRowsIteratorTest.java b/test/jalview/datamodel/AllRowsIteratorTest.java index fd1d29d..9f4c65b 100644 --- a/test/jalview/datamodel/AllRowsIteratorTest.java +++ b/test/jalview/datamodel/AllRowsIteratorTest.java @@ -34,9 +34,9 @@ public class AllRowsIteratorTest { AlignmentI al; - Hashtable hiddenRepSequences = new Hashtable(); + Hashtable hiddenRepSequences = new Hashtable<>(); - @BeforeClass + @BeforeClass(alwaysRun = true) public void setup() { // create random alignment @@ -69,8 +69,10 @@ public class AllRowsIteratorTest * Test iterator throws NoSuchElementException at end of iteration */ @Test( - groups = { "Functional" }, - expectedExceptions = { NoSuchElementException.class }) + groups = + { "Functional" }, + expectedExceptions = + { NoSuchElementException.class }) public void testLastNext() throws NoSuchElementException { AllRowsIterator it = new AllRowsIterator(0, 3, al); @@ -85,15 +87,16 @@ public class AllRowsIteratorTest * Test iterator throws UnsupportedOperationException on call to remove */ @Test( - groups = { "Functional" }, - expectedExceptions = { UnsupportedOperationException.class }) + groups = + { "Functional" }, + expectedExceptions = + { UnsupportedOperationException.class }) public void testRemove() throws UnsupportedOperationException { AllRowsIterator it = new AllRowsIterator(0, 3, al); it.remove(); } - /* * Hide sequences between start and end */ @@ -110,4 +113,21 @@ public class AllRowsIteratorTest hiddenRepSequences.put(allseqs[start], theseSeqs); } + + /* + * Test iterator behaves correctly when there is only one element in the collection + */ + @Test(groups = { "Functional" }) + public void testOneElement() + { + AllRowsIterator it = new AllRowsIterator(0, 0, al); + int count = 0; + while (it.hasNext()) + { + it.next(); + count++; + } + assertTrue(count == 1, "hasNext() is false after 1 iteration"); + } + }