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