JAL-3383 unit tests and bug fix for SequenceFeatures.hasFeatures(type)
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 3 Oct 2019 10:30:28 +0000 (11:30 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 3 Oct 2019 10:30:28 +0000 (11:30 +0100)
src/jalview/datamodel/features/SequenceFeatures.java
test/jalview/datamodel/features/SequenceFeaturesTest.java

index d283aaa..9a7ef1b 100644 (file)
@@ -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();
   }
 
 }
index 923a5fe..e979f51 100644 (file)
@@ -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"));
+  }
 }