JAL-2822 verify start/end is correctly updated and restored after edit, undo, and...
authorJim Procter <jprocter@issues.jalview.org>
Thu, 16 Nov 2017 16:34:02 +0000 (16:34 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 16 Nov 2017 16:34:02 +0000 (16:34 +0000)
test/jalview/commands/EditCommandTest.java

index d72fa7d..7f0986b 100644 (file)
@@ -290,16 +290,45 @@ public class EditCommandTest
     SequenceI seq = new Sequence("seq", "ABC--DEF");
     seq.createDatasetSequence();
     assertEquals("ABCDEF", seq.getDatasetSequence().getSequenceAsString());
+    assertEquals(1, seq.getStart());
+    assertEquals(6, seq.getEnd());
 
     /*
      * replace C- with XYZ
      * NB arg4 = start column of selection for edit (base 0)
      * arg5 = column after end of selection for edit
      */
-    new EditCommand("", Action.REPLACE, "XYZ", new SequenceI[] { seq }, 2,
+    EditCommand edit = new EditCommand("", Action.REPLACE, "XYZ",
+            new SequenceI[]
+            { seq }, 2,
             4, al);
     assertEquals("ABXYZ-DEF", seq.getSequenceAsString());
+    assertEquals(1, seq.getStart());
+    assertEquals(7, seq.getEnd());
     assertEquals("ABXYZDEF", seq.getDatasetSequence().getSequenceAsString());
+    assertEquals(7, seq.getDatasetSequence().getEnd());
+
+    edit.undoCommand(
+            new AlignmentI[]
+            { new Alignment(new SequenceI[] { seq }) });
+
+    assertEquals("ABC--DEF", seq.getSequenceAsString());
+    assertEquals("ABCDEF", seq.getDatasetSequence().getSequenceAsString());
+    assertEquals(1, seq.getStart());
+    assertEquals(6, seq.getEnd());
+    assertEquals(6, seq.getDatasetSequence().getEnd());
+
+    edit.undoCommand(
+            new AlignmentI[]
+            { new Alignment(new SequenceI[] { seq }) });
+
+    assertEquals("ABXYZ-DEF", seq.getSequenceAsString());
+    assertEquals(1, seq.getStart());
+    assertEquals(7, seq.getEnd());
+    assertEquals("ABXYZDEF",
+            seq.getDatasetSequence().getSequenceAsString());
+    assertEquals(7, seq.getDatasetSequence().getEnd());
+
   }
 
   /**