e4643264126f34a308512a19cab5093a4cdd18d8
[jalview.git] / test / jalview / datamodel / features / FeatureAttributesTest.java
1 package jalview.datamodel.features;
2
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
5
6 import java.util.Comparator;
7
8 import junit.extensions.PA;
9
10 import org.testng.annotations.Test;
11
12 public class FeatureAttributesTest
13 {
14
15   /**
16    * Test the method that keeps attribute names in non-case-sensitive order,
17    * including handling of 'compound' names
18    */
19   @Test(groups="Functional")
20   public void testAttributeNameComparator()
21   {
22     FeatureAttributes fa = FeatureAttributes.getInstance();
23     Comparator<String[]> comp = (Comparator<String[]>) PA.getValue(fa,
24             "comparator");
25
26     assertEquals(
27             comp.compare(new String[] { "CSQ" }, new String[] { "csq" }), 0);
28
29     assertTrue(comp.compare(new String[] { "CSQ", "a" },
30             new String[] { "csq" }) > 0);
31
32     assertTrue(comp.compare(new String[] { "CSQ" }, new String[] { "csq",
33         "b" }) < 0);
34
35     assertTrue(comp.compare(new String[] { "CSQ", "AF" }, new String[] {
36         "csq", "ac" }) > 0);
37
38     assertTrue(comp.compare(new String[] { "CSQ", "ac" }, new String[] {
39         "csq", "AF" }) < 0);
40   }
41 }