2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import static org.testng.Assert.assertTrue;
25 import java.util.NoSuchElementException;
27 import org.testng.annotations.BeforeClass;
28 import org.testng.annotations.Test;
30 public class VisibleColsIteratorTest
32 HiddenColumns hiddenCols;
34 HiddenColumns hiddenColsAtStart;
36 @BeforeClass(groups = { "Functional" })
39 hiddenCols = new HiddenColumns();
40 hiddenCols.hideColumns(2, 4);
42 hiddenColsAtStart = new HiddenColumns();
43 hiddenColsAtStart.hideColumns(0, 2);
47 * Test iterator iterates correctly through the columns
48 * when alignment has hidden cols
50 @Test(groups = { "Functional" })
51 public void testHasNextAndNextWithHidden()
53 VisibleColsIterator it = new VisibleColsIterator(0, 6, hiddenCols);
60 assertTrue(count == 4, "hasNext() is false after 4 iterations");
64 * Test iterator iterates correctly through the columns
65 * when alignment has no hidden cols
67 @Test(groups = { "Functional" })
68 public void testHasNextAndNextNoHidden()
70 VisibleColsIterator it2 = new VisibleColsIterator(0, 3,
78 assertTrue(count == 4, "hasNext() is false after 4 iterations");
82 * Test iterator iterates correctly through the columns
83 * when alignment has hidden cols at start
85 @Test(groups = { "Functional" })
86 public void testHasNextAndNextStartHidden()
88 VisibleColsIterator it3 = new VisibleColsIterator(0, 6,
96 assertTrue(count == 4, "hasNext() is false after 4 iterations");
100 * Test iterator iterates correctly through the columns
101 * when alignment has hidden cols at end
103 @Test(groups = { "Functional" })
104 public void testHasNextAndNextEndHidden()
106 VisibleColsIterator it4 = new VisibleColsIterator(0, 4, hiddenCols);
108 while (it4.hasNext())
113 assertTrue(count == 2, "hasNext() is false after 2 iterations");
118 * Test iterator always throws NoSuchElementException at end of iteration
119 * when alignment has hidden cols
122 groups = { "Functional" },
123 expectedExceptions = { NoSuchElementException.class })
124 public void testLastNextWithHidden() throws NoSuchElementException
126 VisibleColsIterator it = new VisibleColsIterator(0, 3, hiddenCols);
135 * Test iterator always throws NoSuchElementException at end of iteration
136 * when alignment has no hidden cols
139 groups = { "Functional" },
140 expectedExceptions = { NoSuchElementException.class })
141 public void testLastNextNoHidden() throws NoSuchElementException
143 VisibleColsIterator it2 = new VisibleColsIterator(0, 3,
144 new HiddenColumns());
145 while (it2.hasNext())
153 * Test iterator always throws NoSuchElementException at end of iteration
154 * when alignment has hidden cols at start
157 groups = { "Functional" },
158 expectedExceptions = { NoSuchElementException.class })
159 public void testLastNextStartHidden() throws NoSuchElementException
161 VisibleColsIterator it3 = new VisibleColsIterator(0, 6,
163 while (it3.hasNext())
171 * Test iterator always throws NoSuchElementException at end of iteration
172 * when alignment has hidden cols at end
175 groups = { "Functional" },
176 expectedExceptions = { NoSuchElementException.class })
177 public void testLastNextEndHidden() throws NoSuchElementException
179 VisibleColsIterator it4 = new VisibleColsIterator(0, 4, hiddenCols);
180 while (it4.hasNext())
188 * Test calls to remove throw UnsupportedOperationException
191 groups = { "Functional" },
192 expectedExceptions = { UnsupportedOperationException.class })
193 public void testRemove() throws UnsupportedOperationException
195 VisibleColsIterator it = new VisibleColsIterator(0, 3, hiddenCols);