X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FMappingTest.java;h=d739369517a428303d18f558c9a42ce889419423;hb=a4143dac9ce4bbf4e3c60496c5818d30fc75e759;hp=a29501707823375836a81806f481099cfcf3d44b;hpb=838e4f91d4a53dd315640dbc9ff6ef7a815ee576;p=jalview.git diff --git a/test/jalview/datamodel/MappingTest.java b/test/jalview/datamodel/MappingTest.java index a295017..d739369 100644 --- a/test/jalview/datamodel/MappingTest.java +++ b/test/jalview/datamodel/MappingTest.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1) - * Copyright (C) 2015 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -21,11 +21,14 @@ package jalview.datamodel; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; +import jalview.gui.JvOptionPane; import jalview.util.MapList; import java.util.Arrays; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @@ -33,6 +36,14 @@ import org.testng.annotations.Test; */ public class MappingTest { + + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + /** * trite test of the intersectVisContigs method for a simple DNA -> Protein * exon map and a range of visContigs @@ -57,4 +68,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()); + } }