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