JAL-1601 Test getVisibleCongigMapFor
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Tue, 19 Sep 2023 12:09:37 +0000 (14:09 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Mon, 25 Sep 2023 11:21:35 +0000 (13:21 +0200)
test/jalview/datamodel/AlignmentViewTest.java

index 9be344c..21c9b78 100644 (file)
  */
 package jalview.datamodel;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import org.hamcrest.Matchers;
 import static org.testng.Assert.assertEquals;
 
+import java.util.Arrays;
+import java.util.List;
+
 import jalview.gui.AlignFrame;
 import jalview.gui.JvOptionPane;
 import jalview.io.DataSourceType;
@@ -31,6 +37,7 @@ import jalview.viewmodel.AlignmentViewport;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+
 public class AlignmentViewTest
 {
 
@@ -55,6 +62,26 @@ public class AlignmentViewTest
             .getSequenceAsString(), "A$$CDE");
   }
 
+  @Test
+  public void testGetVisibleContigMapFor()
+  {
+    AlignFrame af = new FileLoader()
+        .LoadFileWaitTillLoaded(">seq\nAAA-AAAA---AA--\n",
+            DataSourceType.PASTE);
+    var av = af.getViewport();
+    var seq = av.getAlignment().getSequenceAt(0);
+    var gapMap = seq.gapMap();
+    assertThat(Arrays.stream(gapMap).boxed().toArray(Integer[]::new),
+        Matchers.arrayContaining(0, 1, 2, 4, 5, 6, 7, 11, 12));
+
+    av.hideColumns(0, 1);
+    av.hideColumns(6, 7);
+    AlignmentView view = av.getAlignmentView(true);
+    var delMap = view.getVisibleContigMapFor(gapMap);
+    assertThat(Arrays.stream(delMap).boxed().toArray(Integer[]::new),
+        Matchers.arrayContaining(2, 3, 4, 7, 8));
+  }
+
   @Test(groups = { "Functional" })
   public void testGetVisibleContigs()
   {