From c82f8815a3950fc837c8e2827d875e47b8ac457e Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 3 Oct 2019 11:30:28 +0100 Subject: [PATCH] JAL-3383 unit tests and bug fix for SequenceFeatures.hasFeatures(type) --- src/jalview/datamodel/features/SequenceFeatures.java | 3 ++- test/jalview/datamodel/features/SequenceFeaturesTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/jalview/datamodel/features/SequenceFeatures.java b/src/jalview/datamodel/features/SequenceFeatures.java index d283aaa..9a7ef1b 100644 --- a/src/jalview/datamodel/features/SequenceFeatures.java +++ b/src/jalview/datamodel/features/SequenceFeatures.java @@ -483,7 +483,8 @@ public class SequenceFeatures implements SequenceFeaturesI @Override public boolean hasFeatures(String type) { - return featureStore.containsKey(type); + return featureStore.containsKey(type) + && !featureStore.get(type).isEmpty(); } } diff --git a/test/jalview/datamodel/features/SequenceFeaturesTest.java b/test/jalview/datamodel/features/SequenceFeaturesTest.java index 923a5fe..e979f51 100644 --- a/test/jalview/datamodel/features/SequenceFeaturesTest.java +++ b/test/jalview/datamodel/features/SequenceFeaturesTest.java @@ -1331,4 +1331,17 @@ public class SequenceFeaturesTest assertTrue(result.contains(sf2)); assertFalse(result.contains(sf1)); } + + @Test(groups = "Functional") + public void testHasFeatures_ofType() + { + SequenceFeaturesI sf = new SequenceFeatures(); + assertFalse(sf.hasFeatures("Pfam")); + + SequenceFeature sf1 = addFeature(sf, "Pfam", 10, 50); + assertTrue(sf.hasFeatures("Pfam")); + + sf.delete(sf1); + assertFalse(sf.hasFeatures("Pfam")); + } } -- 1.7.10.2