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.AssertJUnit.assertEquals;
25 import java.util.List;
27 import org.testng.annotations.Test;
29 public class ColumnSelectionTest
32 @Test(groups = { "Functional" })
33 public void testAddElement()
35 ColumnSelection cs = new ColumnSelection();
38 List<Integer> sel = cs.getSelected();
39 assertEquals(2, sel.size());
40 assertEquals(new Integer(2), sel.get(0));
41 assertEquals(new Integer(5), sel.get(1));
45 * Test the remove method - in particular to verify that remove(int i) removes
46 * the element whose value is i, _NOT_ the i'th element.
48 @Test(groups = { "Functional" })
49 public void testRemoveElement()
51 ColumnSelection cs = new ColumnSelection();
55 // removing elements not in the list has no effect
58 List<Integer> sel = cs.getSelected();
59 assertEquals(2, sel.size());
60 assertEquals(new Integer(2), sel.get(0));
61 assertEquals(new Integer(5), sel.get(1));
63 // removing an element in the list removes it
65 assertEquals(1, sel.size());
66 assertEquals(new Integer(5), sel.get(0));
70 * Test the method that finds the visible column position of an alignment
71 * column, allowing for hidden columns.
73 @Test(groups = { "Functional" })
74 public void testFindColumnPosition()
76 ColumnSelection cs = new ColumnSelection();
77 assertEquals(5, cs.findColumnPosition(5));
79 // hiding column 6 makes no difference
81 assertEquals(5, cs.findColumnPosition(5));
83 // hiding column 5 makes no difference
85 assertEquals(5, cs.findColumnPosition(5));
87 // hiding column 4 moves column 5 to column 4
89 assertEquals(4, cs.findColumnPosition(5));
91 // hiding columns 1 and 2 moves column 5 to column 2
93 assertEquals(2, cs.findColumnPosition(5));