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);
58 int result = it.next();
59 System.out.println(result);
62 assertTrue(count == 4, "hasNext() is false after 4 iterations");
66 * Test iterator iterates correctly through the columns
67 * when alignment has no hidden cols
69 @Test(groups = { "Functional" })
70 public void testHasNextAndNextNoHidden()
72 HiddenColumns test = new HiddenColumns();
73 Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3);
80 assertTrue(count == 4, "hasNext() is false after 4 iterations");
84 * Test iterator iterates correctly through the columns
85 * when alignment has hidden cols at start
87 @Test(groups = { "Functional" })
88 public void testHasNextAndNextStartHidden()
90 Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(0, 6);
97 assertTrue(count == 4, "hasNext() is false after 4 iterations");
101 * Test iterator iterates correctly through the columns
102 * when alignment has hidden cols at end
104 @Test(groups = { "Functional" })
105 public void testHasNextAndNextEndHidden()
107 Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4);
109 while (it4.hasNext())
114 assertTrue(count == 2, "hasNext() is false after 2 iterations");
119 * Test iterator always throws NoSuchElementException at end of iteration
120 * when alignment has hidden cols
123 groups = { "Functional" },
124 expectedExceptions = { NoSuchElementException.class })
125 public void testLastNextWithHidden() throws NoSuchElementException
127 Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3);
136 * Test iterator always throws NoSuchElementException at end of iteration
137 * when alignment has no hidden cols
140 groups = { "Functional" },
141 expectedExceptions = { NoSuchElementException.class })
142 public void testLastNextNoHidden() throws NoSuchElementException
144 HiddenColumns test = new HiddenColumns();
145 Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3);
146 while (it2.hasNext())
154 * Test iterator always throws NoSuchElementException at end of iteration
155 * when alignment has hidden cols at start
158 groups = { "Functional" },
159 expectedExceptions = { NoSuchElementException.class })
160 public void testLastNextStartHidden() throws NoSuchElementException
162 Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(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 Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4);
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 Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3);