1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.commands; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
|
25 |
|
import jalview.datamodel.Alignment; |
26 |
|
import jalview.datamodel.AlignmentI; |
27 |
|
import jalview.datamodel.Sequence; |
28 |
|
import jalview.datamodel.SequenceI; |
29 |
|
import jalview.gui.JvOptionPane; |
30 |
|
|
31 |
|
import org.testng.annotations.BeforeClass; |
32 |
|
import org.testng.annotations.BeforeMethod; |
33 |
|
import org.testng.annotations.Test; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@author |
39 |
|
|
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (51) |
Complexity: 8 |
Complexity Density: 0.19 |
|
41 |
|
public class TrimRegionCommandTest |
42 |
|
{ |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
44 |
1 |
@BeforeClass(alwaysRun = true)... |
45 |
|
public void setUpJvOptionPane() |
46 |
|
{ |
47 |
1 |
JvOptionPane.setInteractiveMode(false); |
48 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
49 |
|
} |
50 |
|
|
51 |
|
private AlignmentI al; |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
53 |
6 |
@BeforeMethod(alwaysRun = true)... |
54 |
|
public void setUp() |
55 |
|
{ |
56 |
6 |
SequenceI[] seqs = new SequenceI[2]; |
57 |
6 |
seqs[0] = new Sequence("seq0", "abcde-"); |
58 |
6 |
seqs[1] = new Sequence("seq1", "-ghjkl"); |
59 |
6 |
al = new Alignment(seqs); |
60 |
6 |
al.setDataset(null); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
66 |
1 |
@Test(groups = { "Functional" })... |
67 |
|
public void testTrimLeft_withUndoAndRedo() |
68 |
|
{ |
69 |
1 |
TrimRegionCommand cmd = new TrimRegionCommand("Remove Left", true, |
70 |
|
al.getSequencesArray(), 2, al); |
71 |
1 |
assertEquals(2, cmd.getSize()); |
72 |
1 |
assertEquals("cde-", al.getSequenceAt(0).getSequenceAsString()); |
73 |
1 |
assertEquals("hjkl", al.getSequenceAt(1).getSequenceAsString()); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
1 |
cmd.undoCommand(new AlignmentI[] { al }); |
79 |
1 |
assertEquals("abcde-", al.getSequenceAt(0).getSequenceAsString()); |
80 |
1 |
assertEquals("-ghjkl", al.getSequenceAt(1).getSequenceAsString()); |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
1 |
cmd.doCommand(new AlignmentI[] { al }); |
86 |
1 |
assertEquals("cde-", al.getSequenceAt(0).getSequenceAsString()); |
87 |
1 |
assertEquals("hjkl", al.getSequenceAt(1).getSequenceAsString()); |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
94 |
1 |
@Test(groups = { "Functional" })... |
95 |
|
public void testTrimLeft_noColumns() |
96 |
|
{ |
97 |
1 |
TrimRegionCommand cmd = new TrimRegionCommand("Remove Left", true, |
98 |
|
al.getSequencesArray(), 0, al); |
99 |
1 |
assertEquals(0, cmd.getSize()); |
100 |
1 |
assertEquals("abcde-", al.getSequenceAt(0).getSequenceAsString()); |
101 |
1 |
assertEquals("-ghjkl", al.getSequenceAt(1).getSequenceAsString()); |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
107 |
1 |
@Test(groups = { "Functional" })... |
108 |
|
public void testTrimLeft_oneColumn() |
109 |
|
{ |
110 |
1 |
TrimRegionCommand cmd = new TrimRegionCommand("Remove Left", true, |
111 |
|
al.getSequencesArray(), 1, al); |
112 |
1 |
assertEquals(1, cmd.getSize()); |
113 |
1 |
assertEquals("bcde-", al.getSequenceAt(0).getSequenceAsString()); |
114 |
1 |
assertEquals("ghjkl", al.getSequenceAt(1).getSequenceAsString()); |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
121 |
1 |
@Test(groups = { "Functional" })... |
122 |
|
public void testTrimRight_noColumns() |
123 |
|
{ |
124 |
1 |
TrimRegionCommand cmd = new TrimRegionCommand("Remove Right", false, |
125 |
|
al.getSequencesArray(), 5, al); |
126 |
1 |
assertEquals(0, cmd.getSize()); |
127 |
1 |
assertEquals("abcde-", al.getSequenceAt(0).getSequenceAsString()); |
128 |
1 |
assertEquals("-ghjkl", al.getSequenceAt(1).getSequenceAsString()); |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
134 |
1 |
@Test(groups = { "Functional" })... |
135 |
|
public void testTrimRight_oneColumn() |
136 |
|
{ |
137 |
1 |
TrimRegionCommand cmd = new TrimRegionCommand("Remove Right", false, |
138 |
|
al.getSequencesArray(), 4, al); |
139 |
1 |
assertEquals(1, cmd.getSize()); |
140 |
1 |
assertEquals("abcde", al.getSequenceAt(0).getSequenceAsString()); |
141 |
1 |
assertEquals("-ghjk", al.getSequenceAt(1).getSequenceAsString()); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
147 |
1 |
@Test(groups = { "Functional" })... |
148 |
|
public void testTrimRight_withUndoAndRedo() |
149 |
|
{ |
150 |
1 |
TrimRegionCommand cmd = new TrimRegionCommand("Remove Right", false, |
151 |
|
al.getSequencesArray(), 2, al); |
152 |
1 |
assertEquals(3, cmd.getSize()); |
153 |
1 |
assertEquals("abc", al.getSequenceAt(0).getSequenceAsString()); |
154 |
1 |
assertEquals("-gh", al.getSequenceAt(1).getSequenceAsString()); |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
1 |
cmd.undoCommand(new AlignmentI[] { al }); |
160 |
1 |
assertEquals("abcde-", al.getSequenceAt(0).getSequenceAsString()); |
161 |
1 |
assertEquals("-ghjkl", al.getSequenceAt(1).getSequenceAsString()); |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
1 |
cmd.doCommand(new AlignmentI[] { al }); |
167 |
1 |
assertEquals("abc", al.getSequenceAt(0).getSequenceAsString()); |
168 |
1 |
assertEquals("-gh", al.getSequenceAt(1).getSequenceAsString()); |
169 |
|
} |
170 |
|
} |