From 281b9f9964e80595644d96576c73f7ee8c7b5a84 Mon Sep 17 00:00:00 2001
From: Sander Bollen <a.h.b.bollen@lumc.nl>
Date: Fri, 28 Aug 2015 11:54:18 +0200
Subject: [PATCH] Tests for SamplesTsvToJsonTest. Some of these will fail 
 before #196 is resolved.

---
 .../biopet/tools/SamplesTsvToJsonTest.scala   | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJsonTest.scala

diff --git a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJsonTest.scala b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJsonTest.scala
new file mode 100644
index 000000000..f9b32ca38
--- /dev/null
+++ b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJsonTest.scala
@@ -0,0 +1,51 @@
+package nl.lumc.sasc.biopet.tools
+
+import java.io.File
+import java.nio.file.Paths
+
+import org.scalatest.Matchers
+import org.scalatest.mock.MockitoSugar
+import org.scalatest.testng.TestNGSuite
+import org.testng.annotations.Test
+
+/**
+ * Created by ahbbollen on 28-8-15.
+ */
+class SamplesTsvToJsonTest extends TestNGSuite with MockitoSugar with Matchers {
+  import SamplesTsvToJson._
+  private def resourcePath(p: String): String = {
+    Paths.get(getClass.getResource(p).toURI).toString
+  }
+
+  @Test
+  def testCorrectSampleTsv = {
+    val tsv = resourcePath("/sample.tsv")
+
+    noException should be thrownBy main(Array("-i", tsv))
+  }
+
+  @Test
+  def testNoSampleColumn() = {
+    val tsv = resourcePath("/no_sample.tsv")
+    val thrown = the [IllegalStateException] thrownBy main(Array("-i", tsv))
+    thrown.getMessage should equal ("Sample column does not exist in: "  + tsv)
+  }
+
+  @Test
+  def testNumberInLibs = {
+    val tsv = resourcePath("/number.tsv")
+    val thrown = the [IllegalStateException] thrownBy main(Array("-i", tsv))
+    thrown.getMessage should equal ("Sample or library may not start with a number")
+  }
+
+  @Test
+  def testSampleIDs = {
+    val tsv = resourcePath("/same.tsv")
+    val thrown = the [IllegalStateException] thrownBy main(Array("-i", tsv))
+    thrown.getMessage should equal ("Combination of Sample_ID_1 and Lib_ID_1 is found multiple times")
+
+  }
+
+
+
+}
-- 
GitLab