1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import static org.testng.Assert.assertEquals; |
26 |
|
import static org.testng.Assert.assertFalse; |
27 |
|
import static org.testng.Assert.assertNotEquals; |
28 |
|
import static org.testng.Assert.assertNull; |
29 |
|
import static org.testng.Assert.assertSame; |
30 |
|
import static org.testng.Assert.assertTrue; |
31 |
|
|
32 |
|
import java.util.Iterator; |
33 |
|
|
34 |
|
import org.testng.annotations.AfterMethod; |
35 |
|
import org.testng.annotations.BeforeMethod; |
36 |
|
import org.testng.annotations.Test; |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (71) |
Complexity: 9 |
Complexity Density: 0.15 |
|
38 |
|
public class FileFormatsTest |
39 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
40 |
7 |
@AfterMethod(alwaysRun = true)... |
41 |
|
public void tearDown() |
42 |
|
{ |
43 |
7 |
FileFormats.getInstance().reset(); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
7 |
@BeforeMethod(alwaysRun = true)... |
47 |
|
public void setUp() |
48 |
|
{ |
49 |
7 |
FileFormats.getInstance().reset(); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
52 |
1 |
@Test(groups = "Functional")... |
53 |
|
public void testIsIdentifiable() |
54 |
|
{ |
55 |
1 |
FileFormats formats = FileFormats.getInstance(); |
56 |
1 |
assertTrue(formats |
57 |
|
.isIdentifiable(formats.forName(FileFormat.Fasta.getName()))); |
58 |
1 |
assertTrue(formats |
59 |
|
.isIdentifiable(formats.forName(FileFormat.MMCif.getName()))); |
60 |
1 |
assertTrue(formats |
61 |
|
.isIdentifiable(formats.forName(FileFormat.Jnet.getName()))); |
62 |
1 |
assertTrue(formats |
63 |
|
.isIdentifiable(formats.forName(FileFormat.Jalview.getName()))); |
64 |
|
|
65 |
1 |
assertFalse(formats.isIdentifiable(null)); |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
1 |
formats.deregisterFileFormat(FileFormat.Fasta.getName()); |
71 |
1 |
assertNull(formats.forName(FileFormat.Fasta.getName())); |
72 |
1 |
formats.registerFileFormat(FileFormat.Fasta); |
73 |
1 |
assertSame(FileFormat.Fasta, |
74 |
|
formats.forName(FileFormat.Fasta.getName())); |
75 |
1 |
assertTrue(formats.isIdentifiable(FileFormat.Fasta)); |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
78 |
1 |
@Test(groups = "Functional")... |
79 |
|
public void testGetReadableFormats() |
80 |
|
{ |
81 |
1 |
String expected = "[Fasta, PFAM, Stockholm, PIR, BLC, AMSA, HTML, RNAML, JSON, PileUp, MSF, Clustal, PHYLIP, GenBank Flatfile, ENA Flatfile, GFF or Jalview features, PDB, mmCIF, Jalview]"; |
82 |
1 |
FileFormats formats = FileFormats.getInstance(); |
83 |
1 |
assertEquals(formats.getReadableFormats().toString(), expected); |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
86 |
1 |
@Test(groups = "Functional")... |
87 |
|
public void testGetWritableFormats() |
88 |
|
{ |
89 |
1 |
String expected = "[Fasta, PFAM, Stockholm, PIR, BLC, AMSA, JSON, PileUp, MSF, Clustal, PHYLIP]"; |
90 |
1 |
FileFormats formats = FileFormats.getInstance(); |
91 |
1 |
assertEquals(formats.getWritableFormats(true).toString(), expected); |
92 |
1 |
expected = "[Fasta, PFAM, Stockholm, PIR, BLC, AMSA, JSON, PileUp, MSF, Clustal, PHYLIP, Jalview]"; |
93 |
1 |
assertEquals(formats.getWritableFormats(false).toString(), expected); |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
96 |
1 |
@Test(groups = "Functional")... |
97 |
|
public void testDeregisterFileFormat() |
98 |
|
{ |
99 |
1 |
String writable = "[Fasta, PFAM, Stockholm, PIR, BLC, AMSA, JSON, PileUp, MSF, Clustal, PHYLIP]"; |
100 |
1 |
String readable = "[Fasta, PFAM, Stockholm, PIR, BLC, AMSA, HTML, RNAML, JSON, PileUp, MSF, Clustal, PHYLIP, GenBank Flatfile, ENA Flatfile, GFF or Jalview features, PDB, mmCIF, Jalview]"; |
101 |
1 |
FileFormats formats = FileFormats.getInstance(); |
102 |
1 |
assertEquals(formats.getWritableFormats(true).toString(), writable); |
103 |
1 |
assertEquals(formats.getReadableFormats().toString(), readable); |
104 |
|
|
105 |
1 |
formats.deregisterFileFormat(FileFormat.Fasta.getName()); |
106 |
1 |
writable = "[PFAM, Stockholm, PIR, BLC, AMSA, JSON, PileUp, MSF, Clustal, PHYLIP]"; |
107 |
1 |
readable = "[PFAM, Stockholm, PIR, BLC, AMSA, HTML, RNAML, JSON, PileUp, MSF, Clustal, PHYLIP, GenBank Flatfile, ENA Flatfile, GFF or Jalview features, PDB, mmCIF, Jalview]"; |
108 |
1 |
assertEquals(formats.getWritableFormats(true).toString(), writable); |
109 |
1 |
assertEquals(formats.getReadableFormats().toString(), readable); |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
1 |
formats.registerFileFormat(FileFormat.Fasta); |
115 |
1 |
writable = "[PFAM, Stockholm, PIR, BLC, AMSA, JSON, PileUp, MSF, Clustal, PHYLIP, Fasta]"; |
116 |
1 |
readable = "[PFAM, Stockholm, PIR, BLC, AMSA, HTML, RNAML, JSON, PileUp, MSF, Clustal, PHYLIP, GenBank Flatfile, ENA Flatfile, GFF or Jalview features, PDB, mmCIF, Jalview, Fasta]"; |
117 |
1 |
assertEquals(formats.getWritableFormats(true).toString(), writable); |
118 |
1 |
assertEquals(formats.getReadableFormats().toString(), readable); |
119 |
|
} |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
121 |
1 |
@Test(groups = "Functional")... |
122 |
|
public void testForName() |
123 |
|
{ |
124 |
1 |
FileFormats formats = FileFormats.getInstance(); |
125 |
1 |
for (FileFormatI ff : FileFormat.values()) |
126 |
|
{ |
127 |
22 |
assertSame(ff, formats.forName(ff.getName())); |
128 |
22 |
assertSame(ff, |
129 |
|
formats.forName(ff.getName().toUpperCase(Locale.ROOT))); |
130 |
22 |
assertSame(ff, |
131 |
|
formats.forName(ff.getName().toLowerCase(Locale.ROOT))); |
132 |
|
} |
133 |
1 |
assertNull(formats.forName(null)); |
134 |
1 |
assertNull(formats.forName("rubbish")); |
135 |
|
} |
136 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
137 |
1 |
@Test(groups = "Functional")... |
138 |
|
public void testRegisterFileFormat() |
139 |
|
{ |
140 |
1 |
FileFormats formats = FileFormats.getInstance(); |
141 |
1 |
assertSame(FileFormat.MMCif, |
142 |
|
formats.forName(FileFormat.MMCif.getName())); |
143 |
1 |
assertTrue(formats.isIdentifiable(FileFormat.MMCif)); |
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
1 |
formats.deregisterFileFormat(FileFormat.MMCif.getName()); |
149 |
1 |
assertNull(formats.forName(FileFormat.MMCif.getName())); |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
1 |
formats.registerFileFormat(FileFormat.MMCif); |
156 |
1 |
assertSame(FileFormat.MMCif, |
157 |
|
formats.forName(FileFormat.MMCif.getName())); |
158 |
1 |
assertTrue(formats.isIdentifiable(FileFormat.MMCif)); |
159 |
|
|
160 |
1 |
formats.registerFileFormat(FileFormat.MMCif); |
161 |
1 |
assertSame(FileFormat.MMCif, |
162 |
|
formats.forName(FileFormat.MMCif.getName())); |
163 |
|
} |
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
165 |
1 |
@Test(groups = "Functional")... |
166 |
|
public void testGetFormats() |
167 |
|
{ |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
1 |
FileFormats instance = FileFormats.getInstance(); |
172 |
1 |
Iterator<FileFormatI> formats = instance.getFormats().iterator(); |
173 |
1 |
FileFormatI[] builtIn = FileFormat.values(); |
174 |
|
|
175 |
1 |
for (FileFormatI ff : builtIn) |
176 |
|
{ |
177 |
22 |
assertSame(ff, formats.next()); |
178 |
|
} |
179 |
1 |
assertFalse(formats.hasNext()); |
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
1 |
String firstFormatName = instance.getFormats().iterator().next() |
186 |
|
.getName(); |
187 |
1 |
instance.deregisterFileFormat(firstFormatName); |
188 |
1 |
assertNotEquals(instance.getFormats().iterator().next().getName(), |
189 |
|
firstFormatName); |
190 |
|
} |
191 |
|
} |