JAL-2757 fix PDB also; suppress stack trace and compiler warnings
[jalview.git] / test / jalview / renderer / seqfeatures / FeatureColourFinderTest.java
index 4fc079e..7fd7abc 100644 (file)
@@ -16,6 +16,7 @@ import jalview.io.FileLoader;
 import jalview.schemes.FeatureColour;
 
 import java.awt.Color;
+import java.util.List;
 
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.BeforeTest;
@@ -70,13 +71,10 @@ public class FeatureColourFinderTest
   @BeforeMethod(alwaysRun = true)
   public void setUpBeforeTest()
   {
-    SequenceFeature[] sfs = seq.getSequenceFeatures();
-    if (sfs != null)
+    List<SequenceFeature> sfs = seq.getSequenceFeatures();
+    for (SequenceFeature sf : sfs)
     {
-      for (SequenceFeature sf : sfs)
-      {
-        seq.deleteFeature(sf);
-      }
+      seq.deleteFeature(sf);
     }
     fr.findAllFeatures(true);
 
@@ -454,15 +452,19 @@ public class FeatureColourFinderTest
   @Test(groups = "Functional")
   public void testFindFeatureColour_graduatedWithThreshold()
   {
-    seq.addSequenceFeature(new SequenceFeature("kd", "hydrophobicity", 2,
+    String kdFeature = "kd";
+    String metalFeature = "Metal";
+    seq.addSequenceFeature(new SequenceFeature(kdFeature, "hydrophobicity", 2,
             2, 0f, "KdGroup"));
-    seq.addSequenceFeature(new SequenceFeature("kd", "hydrophobicity", 4,
+    seq.addSequenceFeature(new SequenceFeature(kdFeature, "hydrophobicity", 4,
             4, 5f, "KdGroup"));
-    seq.addSequenceFeature(new SequenceFeature("kd", "hydrophobicity", 7,
+    seq.addSequenceFeature(new SequenceFeature(metalFeature, "Fe", 4, 4,
+            5f, "MetalGroup"));
+    seq.addSequenceFeature(new SequenceFeature(kdFeature, "hydrophobicity", 7,
             7, 10f, "KdGroup"));
   
     /*
-     * graduated colour from 0 to 10
+     * kd feature has graduated colour from 0 to 10
      * above threshold value of 5
      */
     Color min = new Color(100, 50, 150);
@@ -470,8 +472,19 @@ public class FeatureColourFinderTest
     FeatureColourI fc = new FeatureColour(min, max, 0, 10);
     fc.setAboveThreshold(true);
     fc.setThreshold(5f);
-    fr.setColour("kd", fc);
+    fr.setColour(kdFeature, fc);
+    FeatureColour green = new FeatureColour(Color.green);
+    fr.setColour(metalFeature, green);
     fr.featuresAdded();
+
+    /*
+     * render order is kd above Metal
+     */
+    Object[][] data = new Object[2][];
+    data[0] = new Object[] { kdFeature, fc, true };
+    data[1] = new Object[] { metalFeature, green, true };
+    fr.setFeaturePriority(data);
+
     av.setShowSequenceFeatures(true);
   
     /*
@@ -481,10 +494,11 @@ public class FeatureColourFinderTest
     assertEquals(c, Color.blue);
 
     /*
-     * position 4, column 3, score 5 - at threshold - default colour
+     * position 4, column 3, score 5 - at threshold
+     * should return Green (colour of Metal feature)
      */
     c = finder.findFeatureColour(Color.blue, seq, 3);
-    assertEquals(c, Color.blue);
+    assertEquals(c, Color.green);
   
     /*
      * position 7, column 9, score 10 - maximum colour in range
@@ -504,10 +518,11 @@ public class FeatureColourFinderTest
     assertEquals(c, min);
 
     /*
-     * position 4, column 3, score 5 - at threshold - default colour
+     * position 4, column 3, score 5 - at threshold
+     * should return Green (colour of Metal feature)
      */
     c = finder.findFeatureColour(Color.blue, seq, 3);
-    assertEquals(c, Color.blue);
+    assertEquals(c, Color.green);
 
     /*
      * position 7, column 9, score 10 - above threshold - default colour