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.Iterator;
26 import java.util.NoSuchElementException;
28 import org.testng.annotations.BeforeClass;
29 import org.testng.annotations.Test;
31 public class VisibleColsIteratorTest
33 HiddenColumns hiddenCols;
35 HiddenColumns hiddenColsAtStart;
37 @BeforeClass(groups = { "Functional" })
40 hiddenCols = new HiddenColumns();
41 hiddenCols.hideColumns(2, 4);
43 hiddenColsAtStart = new HiddenColumns();
44 hiddenColsAtStart.hideColumns(0, 2);
48 * Test iterator iterates correctly through the columns
49 * when alignment has hidden cols
51 @Test(groups = { "Functional" })
52 public void testHasNextAndNextWithHidden()
54 Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 6);
61 assertTrue(count == 4, "hasNext() is false after 4 iterations");
65 * Test iterator iterates correctly through the columns
66 * when alignment has no hidden cols
68 @Test(groups = { "Functional" })
69 public void testHasNextAndNextNoHidden()
71 HiddenColumns test = new HiddenColumns();
72 Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3);
79 assertTrue(count == 4, "hasNext() is false after 4 iterations");
83 * Test iterator iterates correctly through the columns
84 * when alignment has hidden cols at start
86 @Test(groups = { "Functional" })
87 public void testHasNextAndNextStartHidden()
89 Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(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 Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4);
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 Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3);
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 HiddenColumns test = new HiddenColumns();
144 Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3);
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 Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(0, 6);
162 while (it3.hasNext())
170 * Test iterator always throws NoSuchElementException at end of iteration
171 * when alignment has hidden cols at end
174 groups = { "Functional" },
175 expectedExceptions = { NoSuchElementException.class })
176 public void testLastNextEndHidden() throws NoSuchElementException
178 Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4);
179 while (it4.hasNext())
187 * Test calls to remove throw UnsupportedOperationException
190 groups = { "Functional" },
191 expectedExceptions = { UnsupportedOperationException.class })
192 public void testRemove() throws UnsupportedOperationException
194 Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3);