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