From 10342ec527ae42c2cd3a16217c7de6ba7c9cfd1a Mon Sep 17 00:00:00 2001
From: Wai Yi Leung <w.y.leung@lumc.nl>
Date: Fri, 13 May 2016 15:00:56 +0200
Subject: [PATCH] Extended tests.

---
 .../extensions/clever/CleverFixVCFTest.scala  | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/biopet-extensions/src/test/scala/nl/lumc/sasc/biopet/extensions/clever/CleverFixVCFTest.scala b/biopet-extensions/src/test/scala/nl/lumc/sasc/biopet/extensions/clever/CleverFixVCFTest.scala
index 6592a920e..114fcf22d 100644
--- a/biopet-extensions/src/test/scala/nl/lumc/sasc/biopet/extensions/clever/CleverFixVCFTest.scala
+++ b/biopet-extensions/src/test/scala/nl/lumc/sasc/biopet/extensions/clever/CleverFixVCFTest.scala
@@ -1,14 +1,27 @@
 package nl.lumc.sasc.biopet.extensions.clever
 
+import java.io.File
+import java.nio.file.Paths
+
 import org.scalatest.Matchers
 import org.scalatest.testng.TestNGSuite
 import org.testng.annotations.Test
+import scala.io.Source
 
 /**
  * Created by wyleung on 13-5-16.
  */
 class CleverFixVCFTest extends TestNGSuite with Matchers {
 
+  /** Returns the absolute path to test resource directory as a File object */
+  private[clever] val resourceDir: File = new File(Paths.get(getClass.getResource(".").toURI).toString)
+
+  /** Given a resource file name, returns the the absolute path to it as a File object */
+  private[clever] def resourceFile(p: String): File = new File(resourceDir, p)
+
+  val rawCleverVCF = resourceFile("test.clever.vcf")
+  val expectedCleverVCF = resourceFile("expectedresult.clever.vcf")
+
   @Test
   def replacementSucces = {
     CleverFixVCF.replaceHeaderLine(
@@ -31,4 +44,39 @@ class CleverFixVCFTest extends TestNGSuite with Matchers {
     ) should equal(vcfRecordExpected + "\n")
   }
 
+  @Test
+  def mainTest = {
+    val output = File.createTempFile("clever", ".test.vcf")
+    output.deleteOnExit()
+
+    val result = CleverFixVCF.main(Array(
+      "-i", rawCleverVCF.getAbsolutePath,
+      "-o", output.getAbsolutePath,
+      "-s", "testsample"
+    ))
+
+    val exp = Source.fromFile(expectedCleverVCF).getLines()
+    val obs = Source.fromFile(output).getLines()
+
+    (exp zip obs).foreach(_ match {
+      case (a,b) => {
+        a shouldEqual(b)
+      }
+      case _ =>
+    })
+  }
+
+  @Test
+  def javaCommand = {
+    val output = File.createTempFile("clever", ".test.vcf")
+    output.deleteOnExit()
+    val cfvcf = new CleverFixVCF(null)
+    cfvcf.input = rawCleverVCF
+    cfvcf.output = output
+    cfvcf.sampleName = "testsample"
+
+    cfvcf.cmdLine should include ("'-s' 'testsample'")
+    cfvcf.cmdLine should include (s"'-i' '${rawCleverVCF}'")
+    cfvcf.cmdLine should include (s"'-o' '${output}'")
+  }
 }
-- 
GitLab