X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FFeatureColourTest.java;fp=test%2Fjalview%2Fschemes%2FFeatureColourTest.java;h=6ccce85c0d2aa8ba625e019cdfe526f702d43a72;hb=09d3b755d9b00f5c3acb44049aedd49361dc0690;hp=a96caec9a3d9b542ab19585ec0f641ad1ad5a3b9;hpb=d34f80c67881e79d7304eb143e9c907bc16d052b;p=jalview.git diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index a96caec..6ccce85 100644 --- a/test/jalview/schemes/FeatureColourTest.java +++ b/test/jalview/schemes/FeatureColourTest.java @@ -712,4 +712,44 @@ public class FeatureColourTest Color expected = new Color(70, 120, 170); assertEquals(expected, fc.getColor(sf)); } + + @Test(groups = { "Functional" }) + public void testIsOutwithThreshold() + { + FeatureColourI fc = new FeatureColour(Color.red); + SequenceFeature sf = new SequenceFeature("METAL", "desc", 10, 12, 1.2f, "grp"); + assertFalse(fc.isOutwithThreshold(null)); + assertFalse(fc.isOutwithThreshold(sf)); + + fc = new FeatureColour(Color.white, Color.black, Color.green, 0f, 10f); + assertFalse(fc.isOutwithThreshold(sf)); // no threshold + + fc.setAboveThreshold(true); + fc.setThreshold(1f); + assertFalse(fc.isOutwithThreshold(sf)); // feature score 1.2 is above 1 + + fc.setThreshold(2f); + assertTrue(fc.isOutwithThreshold(sf)); // feature score 1.2 is not above 2 + + fc.setBelowThreshold(true); + assertFalse(fc.isOutwithThreshold(sf)); // feature score 1.2 is below 2 + + fc.setThreshold(1f); + assertTrue(fc.isOutwithThreshold(sf)); // feature score 1.2 is not below 1 + + /* + * with attribute value threshold + */ + fc.setAttributeName("AC"); + assertFalse(fc.isOutwithThreshold(sf)); // missing attribute AC is ignored + + sf.setValue("AC", "-1"); + assertFalse(fc.isOutwithThreshold(sf)); // value -1 is below 1 + + sf.setValue("AC", "1"); + assertTrue(fc.isOutwithThreshold(sf)); // value 1 is not below 1 + + sf.setValue("AC", "junk"); + assertFalse(fc.isOutwithThreshold(sf)); // bad value is ignored + } }