JAL-1270 main method converted 'as seen' to JUnit
[jalview.git] / test / jalview / datamodel / MappingTest.java
diff --git a/test/jalview/datamodel/MappingTest.java b/test/jalview/datamodel/MappingTest.java
new file mode 100644 (file)
index 0000000..fe2ff59
--- /dev/null
@@ -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);
+  }
+
+}