| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.datamodel; |
| 22 |
|
|
| 23 |
|
import static org.testng.Assert.assertTrue; |
| 24 |
|
|
| 25 |
|
import java.util.Iterator; |
| 26 |
|
import java.util.NoSuchElementException; |
| 27 |
|
|
| 28 |
|
import org.testng.annotations.BeforeClass; |
| 29 |
|
import org.testng.annotations.Test; |
| 30 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (75) |
Complexity: 18 |
Complexity Density: 0.37 |
|
| 31 |
|
public class RangeElementsIteratorTest |
| 32 |
|
{ |
| 33 |
|
HiddenColumns hiddenCols; |
| 34 |
|
|
| 35 |
|
HiddenColumns hiddenColsAtStart; |
| 36 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 37 |
1 |
@BeforeClass(groups = { "Functional" })... |
| 38 |
|
public void setup() |
| 39 |
|
{ |
| 40 |
1 |
hiddenCols = new HiddenColumns(); |
| 41 |
1 |
hiddenCols.hideColumns(2, 4); |
| 42 |
|
|
| 43 |
1 |
hiddenColsAtStart = new HiddenColumns(); |
| 44 |
1 |
hiddenColsAtStart.hideColumns(0, 2); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
1PASS
|
|
| 51 |
1 |
@Test(groups = { "Functional" })... |
| 52 |
|
public void testHasNextAndNextWithHidden() |
| 53 |
|
{ |
| 54 |
1 |
Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 6); |
| 55 |
1 |
int count = 0; |
| 56 |
5 |
while (it.hasNext()) |
| 57 |
|
{ |
| 58 |
4 |
int result = it.next(); |
| 59 |
4 |
System.out.println(result); |
| 60 |
4 |
count++; |
| 61 |
|
} |
| 62 |
1 |
assertTrue(count == 4, "hasNext() is false after 4 iterations"); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
1PASS
|
|
| 69 |
1 |
@Test(groups = { "Functional" })... |
| 70 |
|
public void testHasNextAndNextNoHidden() |
| 71 |
|
{ |
| 72 |
1 |
HiddenColumns test = new HiddenColumns(); |
| 73 |
1 |
Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3); |
| 74 |
1 |
int count = 0; |
| 75 |
5 |
while (it2.hasNext()) |
| 76 |
|
{ |
| 77 |
4 |
it2.next(); |
| 78 |
4 |
count++; |
| 79 |
|
} |
| 80 |
1 |
assertTrue(count == 4, "hasNext() is false after 4 iterations"); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
| 87 |
1 |
@Test(groups = { "Functional" })... |
| 88 |
|
public void testHasNextAndNextStartHidden() |
| 89 |
|
{ |
| 90 |
1 |
Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(0, 6); |
| 91 |
1 |
int count = 0; |
| 92 |
5 |
while (it3.hasNext()) |
| 93 |
|
{ |
| 94 |
4 |
it3.next(); |
| 95 |
4 |
count++; |
| 96 |
|
} |
| 97 |
1 |
assertTrue(count == 4, "hasNext() is false after 4 iterations"); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
| 104 |
1 |
@Test(groups = { "Functional" })... |
| 105 |
|
public void testHasNextAndNextEndHidden() |
| 106 |
|
{ |
| 107 |
1 |
Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4); |
| 108 |
1 |
int count = 0; |
| 109 |
3 |
while (it4.hasNext()) |
| 110 |
|
{ |
| 111 |
2 |
it4.next(); |
| 112 |
2 |
count++; |
| 113 |
|
} |
| 114 |
1 |
assertTrue(count == 2, "hasNext() is false after 2 iterations"); |
| 115 |
|
|
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
| 122 |
1 |
@Test(... |
| 123 |
|
groups = |
| 124 |
|
{ "Functional" }, |
| 125 |
|
expectedExceptions = |
| 126 |
|
{ NoSuchElementException.class }) |
| 127 |
|
public void testLastNextWithHidden() throws NoSuchElementException |
| 128 |
|
{ |
| 129 |
1 |
Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3); |
| 130 |
3 |
while (it.hasNext()) |
| 131 |
|
{ |
| 132 |
2 |
it.next(); |
| 133 |
|
} |
| 134 |
1 |
it.next(); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
1PASS
|
|
| 141 |
1 |
@Test(... |
| 142 |
|
groups = |
| 143 |
|
{ "Functional" }, |
| 144 |
|
expectedExceptions = |
| 145 |
|
{ NoSuchElementException.class }) |
| 146 |
|
public void testLastNextNoHidden() throws NoSuchElementException |
| 147 |
|
{ |
| 148 |
1 |
HiddenColumns test = new HiddenColumns(); |
| 149 |
1 |
Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3); |
| 150 |
5 |
while (it2.hasNext()) |
| 151 |
|
{ |
| 152 |
4 |
it2.next(); |
| 153 |
|
} |
| 154 |
1 |
it2.next(); |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
| 161 |
1 |
@Test(... |
| 162 |
|
groups = |
| 163 |
|
{ "Functional" }, |
| 164 |
|
expectedExceptions = |
| 165 |
|
{ NoSuchElementException.class }) |
| 166 |
|
public void testLastNextStartHidden() throws NoSuchElementException |
| 167 |
|
{ |
| 168 |
1 |
Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(0, 6); |
| 169 |
5 |
while (it3.hasNext()) |
| 170 |
|
{ |
| 171 |
4 |
it3.next(); |
| 172 |
|
} |
| 173 |
1 |
it3.next(); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
| 180 |
1 |
@Test(... |
| 181 |
|
groups = |
| 182 |
|
{ "Functional" }, |
| 183 |
|
expectedExceptions = |
| 184 |
|
{ NoSuchElementException.class }) |
| 185 |
|
public void testLastNextEndHidden() throws NoSuchElementException |
| 186 |
|
{ |
| 187 |
1 |
Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4); |
| 188 |
3 |
while (it4.hasNext()) |
| 189 |
|
{ |
| 190 |
2 |
it4.next(); |
| 191 |
|
} |
| 192 |
1 |
it4.next(); |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 198 |
1 |
@Test(... |
| 199 |
|
groups = |
| 200 |
|
{ "Functional" }, |
| 201 |
|
expectedExceptions = |
| 202 |
|
{ UnsupportedOperationException.class }) |
| 203 |
|
public void testRemove() throws UnsupportedOperationException |
| 204 |
|
{ |
| 205 |
1 |
Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3); |
| 206 |
1 |
it.remove(); |
| 207 |
|
} |
| 208 |
|
} |