JAL-2541 more useful assert message
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 27 Jun 2017 20:16:00 +0000 (21:16 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 14 Sep 2017 10:10:09 +0000 (11:10 +0100)
Conflicts:
test/jalview/commands/EditCommandTest.java

test/jalview/commands/EditCommandTest.java

index 326104a..ac47555 100644 (file)
@@ -796,13 +796,36 @@ public class EditCommandTest
          * undo ready for next cut
          */
         testee.undoCommand(new AlignmentI[] { alignment });
-        int size = seq0.getSequenceFeatures().size();
-        assertEquals(func(5), size);
+        sfs = seq0.getSequenceFeatures();
+        assertEquals("After undo of " + msg, func(5), sfs.size());
+        verifyUndo(from, to, sfs);
       }
     }
   }
 
   /**
+   * Check that after Undo, every feature has start/end that match its original
+   * "start" and "end" properties
+   * 
+   * @param from
+   * @param to
+   * @param sfs
+   */
+  protected void verifyUndo(int from, int to, List<SequenceFeature> sfs)
+  {
+    for (SequenceFeature sf : sfs)
+    {
+      final int oldFrom = ((Integer) sf.getValue("from")).intValue();
+      final int oldTo = ((Integer) sf.getValue("to")).intValue();
+      String msg = String.format(
+              "Undo cut of [%d-%d], feature at [%d-%d] ", from + 1, to + 1,
+              oldFrom, oldTo);
+      assertEquals(msg + "start", oldFrom, sf.getBegin());
+      assertEquals(msg + "end", oldTo, sf.getEnd());
+    }
+  }
+
+  /**
    * Helper method to check a feature has been correctly relocated after a cut
    * 
    * @param sf