From: gmungoc Date: Fri, 15 May 2015 13:25:56 +0000 (+0100) Subject: JAL-1270 main method converted 'as seen' to JUnit X-Git-Tag: Release_2_10_0~672 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d66775feacb4a7cc43c5296e8ef33811e5e75e79;p=jalview.git JAL-1270 main method converted 'as seen' to JUnit --- diff --git a/src/jalview/datamodel/Mapping.java b/src/jalview/datamodel/Mapping.java index 559ae4c..d7b7eb9 100644 --- a/src/jalview/datamodel/Mapping.java +++ b/src/jalview/datamodel/Mapping.java @@ -20,12 +20,12 @@ */ package jalview.datamodel; -import jalview.util.MapList; - import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Vector; +import jalview.util.MapList; + public class Mapping { /** @@ -663,24 +663,6 @@ public class Mapping return copy; } - public static void main(String[] args) - { - /** - * trite test of the intersectVisContigs method for a simple DNA -> Protein - * exon map and a range of visContigs - */ - MapList fk = new MapList(new int[] - { 1, 6, 8, 13, 15, 23 }, new int[] - { 1, 7 }, 3, 1); - Mapping m = new Mapping(fk); - Mapping m_1 = m.intersectVisContigs(new int[] - { fk.getFromLowest(), fk.getFromHighest() }); - Mapping m_2 = m.intersectVisContigs(new int[] - { 1, 7, 11, 20 }); - System.out.println("" + m_1.map.getFromRanges()); - - } - /** * get the sequence being mapped to - if any * diff --git a/test/jalview/datamodel/MappingTest.java b/test/jalview/datamodel/MappingTest.java new file mode 100644 index 0000000..fe2ff59 --- /dev/null +++ b/test/jalview/datamodel/MappingTest.java @@ -0,0 +1,43 @@ +package jalview.datamodel; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; + +import org.junit.Test; + +import jalview.util.MapList; + +/** + * Test class refactored from main method + */ +public class MappingTest +{ + /** + * trite test of the intersectVisContigs method for a simple DNA -> Protein + * exon map and a range of visContigs + */ + @Test + public void testIntersectVisContigs() + { + MapList fk = new MapList(new int[] + { 1, 6, 8, 13, 15, 23 }, new int[] + { 1, 7 }, 3, 1); + Mapping m = new Mapping(fk); + Mapping m_1 = m.intersectVisContigs(new int[] + { fk.getFromLowest(), fk.getFromHighest() }); + Mapping m_2 = m.intersectVisContigs(new int[] + { 1, 7, 11, 20 }); + + // assertions from output values 'as is', not checked for correctness + String result = Arrays.deepToString(m_1.map.getFromRanges() + .toArray()); + System.out.println(result); + assertEquals("[[1, 6], [8, 13], [15, 23]]", result); + + result = Arrays.deepToString(m_2.map.getFromRanges().toArray()); + System.out.println(result); + assertEquals("[[1, 6], [11, 13], [15, 20]]", result); + } + +}