JAL-2110 add 'mapFromId' to Mapping (for e.g. EMBL CDS protein_id)
[jalview.git] / test / jalview / datamodel / MappingTest.java
index cbecad5..b326d90 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.datamodel;
 
 import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertSame;
 
 import jalview.util.MapList;
 
@@ -66,13 +67,27 @@ public class MappingTest
     MapList fk = new MapList(new int[] { 1, 6, 8, 13 }, new int[] { 4, 7 },
             3, 1);
     Mapping m = new Mapping(fk);
-    assertEquals("[ [1, 6] [8, 13] ] To [ [4, 7] ] ", m.toString());
+    assertEquals("[ [1, 6] [8, 13] ] 3:1 to [ [4, 7] ] ", m.toString());
 
     /*
      * with a sequence
      */
     SequenceI seq = new Sequence("Seq1", "");
     m = new Mapping(seq, fk);
-    assertEquals("[ [1, 6] [8, 13] ] To [ [4, 7] ] Seq1", m.toString());
+    assertEquals("[ [1, 6] [8, 13] ] 3:1 to [ [4, 7] ] Seq1", m.toString());
+  }
+
+  @Test(groups = { "Functional" })
+  public void testCopyConstructor()
+  {
+    MapList ml = new MapList(new int[] { 1, 6, 8, 13 }, new int[] { 4, 7 },
+            3, 1);
+    SequenceI seq = new Sequence("seq1", "agtacg");
+    Mapping m = new Mapping(seq, ml);
+    m.setMappedFromId("abc");
+    Mapping copy = new Mapping(m);
+    assertEquals("abc", copy.getMappedFromId());
+    assertEquals(ml, copy.getMap());
+    assertSame(seq, copy.getTo());
   }
 }