JAL-4090 JAL-4334 position status when start, end or pos is unknown is stored in...
[jalview.git] / test / jalview / datamodel / AllColsIteratorTest.java
index fbb20be..3394794 100644 (file)
@@ -30,14 +30,13 @@ import org.testng.annotations.Test;
 public class AllColsIteratorTest
 {
   HiddenColumns hiddenCols;
-  
-  @BeforeClass
+
+  @BeforeClass(alwaysRun = true)
   public void setup()
   {
     hiddenCols = new HiddenColumns();
-   hiddenCols.hideColumns(2,4);
+    hiddenCols.hideColumns(2, 4);
   }
-  
 
   /*
    * Test iterator iterates through collection correctly
@@ -59,8 +58,10 @@ public class AllColsIteratorTest
    * Test iterator throws NoSuchElementException at end of iteration
    */
   @Test(
-    groups = { "Functional" },
-    expectedExceptions = { NoSuchElementException.class })
+    groups =
+    { "Functional" },
+    expectedExceptions =
+    { NoSuchElementException.class })
   public void testLastNext() throws NoSuchElementException
   {
     AllColsIterator it = new AllColsIterator(0, 3, hiddenCols);
@@ -75,11 +76,30 @@ public class AllColsIteratorTest
    * Test iterator throws UnsupportedOperationException on call to remove
    */
   @Test(
-    groups = { "Functional" },
-    expectedExceptions = { UnsupportedOperationException.class })
+    groups =
+    { "Functional" },
+    expectedExceptions =
+    { UnsupportedOperationException.class })
   public void testRemove() throws UnsupportedOperationException
   {
     AllColsIterator it = new AllColsIterator(0, 3, hiddenCols);
     it.remove();
   }
+
+  /*
+   * Test iterator behaves correctly when there is only one element in the collection
+   */
+  @Test(groups = { "Functional" })
+  public void testOneElement()
+  {
+    HiddenColumns hidden = new HiddenColumns();
+    AllColsIterator it = new AllColsIterator(0, 0, hidden);
+    int count = 0;
+    while (it.hasNext())
+    {
+      it.next();
+      count++;
+    }
+    assertTrue(count == 1, "hasNext() is false after 1 iteration");
+  }
 }