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 RangeElementsIteratorTest
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
126 { NoSuchElementException.class })
127 public void testLastNextWithHidden() throws NoSuchElementException
129 Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3);
138 * Test iterator always throws NoSuchElementException at end of iteration
139 * when alignment has no hidden cols
145 { NoSuchElementException.class })
146 public void testLastNextNoHidden() throws NoSuchElementException
148 HiddenColumns test = new HiddenColumns();
149 Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3);
150 while (it2.hasNext())
158 * Test iterator always throws NoSuchElementException at end of iteration
159 * when alignment has hidden cols at start
165 { NoSuchElementException.class })
166 public void testLastNextStartHidden() throws NoSuchElementException
168 Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(0, 6);
169 while (it3.hasNext())
177 * Test iterator always throws NoSuchElementException at end of iteration
178 * when alignment has hidden cols at end
184 { NoSuchElementException.class })
185 public void testLastNextEndHidden() throws NoSuchElementException
187 Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4);
188 while (it4.hasNext())
196 * Test calls to remove throw UnsupportedOperationException
202 { UnsupportedOperationException.class })
203 public void testRemove() throws UnsupportedOperationException
205 Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3);