1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel.features; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertNull; |
25 |
|
import static org.testng.Assert.assertTrue; |
26 |
|
|
27 |
|
import jalview.datamodel.SequenceFeature; |
28 |
|
import jalview.datamodel.features.FeatureAttributes.Datatype; |
29 |
|
|
30 |
|
import java.util.Comparator; |
31 |
|
import java.util.HashMap; |
32 |
|
import java.util.Map; |
33 |
|
|
34 |
|
import org.testng.annotations.AfterMethod; |
35 |
|
import org.testng.annotations.BeforeClass; |
36 |
|
import org.testng.annotations.Test; |
37 |
|
|
38 |
|
import junit.extensions.PA; |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (51) |
Complexity: 6 |
Complexity Density: 0.13 |
|
40 |
|
public class FeatureAttributesTest |
41 |
|
{ |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
46 |
1 |
@BeforeClass(alwaysRun = true)... |
47 |
|
public void setUp() |
48 |
|
{ |
49 |
1 |
FeatureAttributes fa = FeatureAttributes.getInstance(); |
50 |
1 |
((Map<?, ?>) PA.getValue(fa, "attributes")).clear(); |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
56 |
4 |
@AfterMethod(alwaysRun = true)... |
57 |
|
public void tearDown() |
58 |
|
{ |
59 |
4 |
FeatureAttributes fa = FeatureAttributes.getInstance(); |
60 |
4 |
((Map<?, ?>) PA.getValue(fa, "attributes")).clear(); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
67 |
1 |
@Test(groups = "Functional")... |
68 |
|
public void testAttributeNameComparator() |
69 |
|
{ |
70 |
1 |
FeatureAttributes fa = FeatureAttributes.getInstance(); |
71 |
1 |
Comparator<String[]> comp = (Comparator<String[]>) PA.getValue(fa, |
72 |
|
"comparator"); |
73 |
|
|
74 |
1 |
assertEquals( |
75 |
|
comp.compare(new String[] |
76 |
|
{ "CSQ" }, new String[] { "csq" }), 0); |
77 |
|
|
78 |
1 |
assertTrue( |
79 |
|
comp.compare(new String[] |
80 |
|
{ "CSQ", "a" }, new String[] { "csq" }) > 0); |
81 |
|
|
82 |
1 |
assertTrue( |
83 |
|
comp.compare(new String[] |
84 |
|
{ "CSQ" }, new String[] { "csq", "b" }) < 0); |
85 |
|
|
86 |
1 |
assertTrue( |
87 |
|
comp.compare(new String[] |
88 |
|
{ "CSQ", "AF" }, new String[] { "csq", "ac" }) > 0); |
89 |
|
|
90 |
1 |
assertTrue( |
91 |
|
comp.compare(new String[] |
92 |
|
{ "CSQ", "ac" }, new String[] { "csq", "AF" }) < 0); |
93 |
|
} |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
95 |
1 |
@Test(groups = "Functional")... |
96 |
|
public void testGetMinMax() |
97 |
|
{ |
98 |
1 |
SequenceFeature sf = new SequenceFeature("Pfam", "desc", 10, 20, |
99 |
|
"group"); |
100 |
1 |
FeatureAttributes fa = FeatureAttributes.getInstance(); |
101 |
1 |
assertNull(fa.getMinMax("Pfam", "kd")); |
102 |
1 |
sf.setValue("domain", "xyz"); |
103 |
1 |
assertNull(fa.getMinMax("Pfam", "kd")); |
104 |
1 |
sf.setValue("kd", "1.3"); |
105 |
1 |
assertEquals(fa.getMinMax("Pfam", "kd"), new float[] { 1.3f, 1.3f }); |
106 |
1 |
sf.setValue("kd", "-2.6"); |
107 |
1 |
assertEquals(fa.getMinMax("Pfam", "kd"), new float[] { -2.6f, 1.3f }); |
108 |
|
|
109 |
1 |
sf.setValue("kd", "some text"); |
110 |
1 |
assertNull(fa.getMinMax("Pfam", "kd")); |
111 |
|
|
112 |
1 |
Map<String, String> csq = new HashMap<>(); |
113 |
1 |
csq.put("AF", "-3"); |
114 |
1 |
sf.setValue("CSQ", csq); |
115 |
1 |
assertEquals(fa.getMinMax("Pfam", "CSQ", "AF"), |
116 |
|
new float[] |
117 |
|
{ -3f, -3f }); |
118 |
1 |
csq.put("AF", "4"); |
119 |
1 |
sf.setValue("CSQ", csq); |
120 |
1 |
assertEquals(fa.getMinMax("Pfam", "CSQ", "AF"), |
121 |
|
new float[] |
122 |
|
{ -3f, 4f }); |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
129 |
1 |
@Test(groups = "Functional")... |
130 |
|
public void testGetDescription() |
131 |
|
{ |
132 |
1 |
FeatureAttributes fa = FeatureAttributes.getInstance(); |
133 |
|
|
134 |
1 |
assertNull(fa.getDescription("Pfam", "kd")); |
135 |
|
|
136 |
1 |
fa.addDescription("Pfam", "desc1", "kd"); |
137 |
1 |
assertEquals(fa.getDescription("Pfam", "kd"), "desc1"); |
138 |
|
|
139 |
1 |
fa.addDescription("Pfam", "desc2", "kd"); |
140 |
1 |
assertNull(fa.getDescription("Pfam", "kd")); |
141 |
|
} |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
143 |
1 |
@Test(groups = "Functional")... |
144 |
|
public void testDatatype() |
145 |
|
{ |
146 |
1 |
FeatureAttributes fa = FeatureAttributes.getInstance(); |
147 |
1 |
assertNull(fa.getDatatype("Pfam", "kd")); |
148 |
1 |
SequenceFeature sf = new SequenceFeature("Pfam", "desc", 10, 20, |
149 |
|
"group"); |
150 |
1 |
sf.setValue("kd", "-1"); |
151 |
1 |
sf.setValue("domain", "Metal"); |
152 |
1 |
sf.setValue("phase", "1"); |
153 |
1 |
sf.setValue("phase", "reverse"); |
154 |
1 |
assertEquals(fa.getDatatype("Pfam", "kd"), Datatype.Number); |
155 |
1 |
assertEquals(fa.getDatatype("Pfam", "domain"), Datatype.Character); |
156 |
1 |
assertEquals(fa.getDatatype("Pfam", "phase"), Datatype.Mixed); |
157 |
|
} |
158 |
|
} |