| 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 jalview.analysis.AlignmentGenerator; |
| 26 |
|
|
| 27 |
|
import java.util.Hashtable; |
| 28 |
|
import java.util.NoSuchElementException; |
| 29 |
|
|
| 30 |
|
import org.testng.annotations.BeforeClass; |
| 31 |
|
import org.testng.annotations.Test; |
| 32 |
|
|
| |
|
| 95.6% |
Uncovered Elements: 2 (45) |
Complexity: 11 |
Complexity Density: 0.38 |
|
| 33 |
|
public class AllRowsIteratorTest |
| 34 |
|
{ |
| 35 |
|
AlignmentI al; |
| 36 |
|
|
| 37 |
|
Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<>(); |
| 38 |
|
|
| |
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 39 |
1 |
@BeforeClass(alwaysRun = true)... |
| 40 |
|
public void setup() |
| 41 |
|
{ |
| 42 |
|
|
| 43 |
1 |
AlignmentGenerator gen = new AlignmentGenerator(false); |
| 44 |
1 |
al = gen.generate(20, 15, 123, 5, 5); |
| 45 |
1 |
if (!hiddenRepSequences.isEmpty()) |
| 46 |
|
{ |
| 47 |
0 |
al.getHiddenSequences().showAll(hiddenRepSequences); |
| 48 |
|
} |
| 49 |
1 |
hideSequences(2, 4); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
| 55 |
1 |
@Test(groups = { "Functional" })... |
| 56 |
|
public void testHasNextAndNext() |
| 57 |
|
{ |
| 58 |
1 |
AllRowsIterator it = new AllRowsIterator(0, 3, al); |
| 59 |
1 |
int count = 0; |
| 60 |
5 |
while (it.hasNext()) |
| 61 |
|
{ |
| 62 |
4 |
it.next(); |
| 63 |
4 |
count++; |
| 64 |
|
} |
| 65 |
1 |
assertTrue(count == 4, "hasNext() is false after 4 iterations"); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
| 71 |
1 |
@Test(... |
| 72 |
|
groups = |
| 73 |
|
{ "Functional" }, |
| 74 |
|
expectedExceptions = |
| 75 |
|
{ NoSuchElementException.class }) |
| 76 |
|
public void testLastNext() throws NoSuchElementException |
| 77 |
|
{ |
| 78 |
1 |
AllRowsIterator it = new AllRowsIterator(0, 3, al); |
| 79 |
5 |
while (it.hasNext()) |
| 80 |
|
{ |
| 81 |
4 |
it.next(); |
| 82 |
|
} |
| 83 |
1 |
it.next(); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 89 |
1 |
@Test(... |
| 90 |
|
groups = |
| 91 |
|
{ "Functional" }, |
| 92 |
|
expectedExceptions = |
| 93 |
|
{ UnsupportedOperationException.class }) |
| 94 |
|
public void testRemove() throws UnsupportedOperationException |
| 95 |
|
{ |
| 96 |
1 |
AllRowsIterator it = new AllRowsIterator(0, 3, al); |
| 97 |
1 |
it.remove(); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 103 |
1 |
private void hideSequences(int start, int end)... |
| 104 |
|
{ |
| 105 |
1 |
SequenceI[] allseqs = al.getSequencesArray(); |
| 106 |
1 |
SequenceGroup theseSeqs = new SequenceGroup(); |
| 107 |
|
|
| 108 |
4 |
for (int i = start; i <= end; i++) |
| 109 |
|
{ |
| 110 |
3 |
theseSeqs.addSequence(allseqs[i], false); |
| 111 |
3 |
al.getHiddenSequences().hideSequence(allseqs[i]); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
1 |
hiddenRepSequences.put(allseqs[start], theseSeqs); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
| 120 |
1 |
@Test(groups = { "Functional" })... |
| 121 |
|
public void testOneElement() |
| 122 |
|
{ |
| 123 |
1 |
AllRowsIterator it = new AllRowsIterator(0, 0, al); |
| 124 |
1 |
int count = 0; |
| 125 |
2 |
while (it.hasNext()) |
| 126 |
|
{ |
| 127 |
1 |
it.next(); |
| 128 |
1 |
count++; |
| 129 |
|
} |
| 130 |
1 |
assertTrue(count == 1, "hasNext() is false after 1 iteration"); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
} |