X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FMappingTest.java;h=03274668d104b6e722b5ea199b11d05f59b9a0e3;hb=db93a1adcbe0a4eaaf06e0a70ade0d6c5c1961c3;hp=722cffc20a5275c62c185ed4eb0ec913078a2d13;hpb=a90e2fe3cc3b779521a81cf8de410936f3a777c1;p=jalview.git diff --git a/test/jalview/datamodel/MappingTest.java b/test/jalview/datamodel/MappingTest.java index 722cffc..0327466 100644 --- a/test/jalview/datamodel/MappingTest.java +++ b/test/jalview/datamodel/MappingTest.java @@ -21,6 +21,7 @@ package jalview.datamodel; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; import jalview.util.MapList; @@ -57,4 +58,36 @@ public class MappingTest assertEquals("[[1, 6], [11, 13], [15, 20]]", result); } + @Test(groups = { "Functional" }) + public void testToString() + { + /* + * with no sequence + */ + 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] ] 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] ] 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()); + } }