From 0db8718734daaeba5307a9e3f6b644cee56bec13 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Mon, 9 May 2016 17:13:20 +0200
Subject: [PATCH] Added tests for deps

---
 .../biopet/core/WriteDependenciesTest.scala   | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/biopet-core/src/test/scala/nl/lumc/sasc/biopet/core/WriteDependenciesTest.scala b/biopet-core/src/test/scala/nl/lumc/sasc/biopet/core/WriteDependenciesTest.scala
index 351cc6b6e..c40f615c2 100644
--- a/biopet-core/src/test/scala/nl/lumc/sasc/biopet/core/WriteDependenciesTest.scala
+++ b/biopet-core/src/test/scala/nl/lumc/sasc/biopet/core/WriteDependenciesTest.scala
@@ -3,6 +3,7 @@ package nl.lumc.sasc.biopet.core
 import java.io.File
 import java.nio.file.Files
 
+import nl.lumc.sasc.biopet.utils.ConfigUtils
 import org.broadinstitute.gatk.queue.function.QFunction
 import org.scalatest.Matchers
 import org.scalatest.testng.TestNGSuite
@@ -26,11 +27,27 @@ class WriteDependenciesTest extends TestNGSuite with Matchers {
   }
 
   @Test
-  def test: Unit = {
+  def testDeps: Unit = {
     val outputFile = File.createTempFile("deps.", ".json")
     outputFile.deleteOnExit()
-    WriteDependencies.writeDependencies(Qfunc(file1 :: Nil, file2 :: Nil) :: Qfunc(file2 :: Nil, file3 :: Nil) :: Nil, outputFile)
-    println(Source.fromFile(outputFile).getLines().mkString("\n"))
+    val func1 = Qfunc(file1 :: Nil, file2 :: Nil)
+    val func2 = Qfunc(file2 :: Nil, file3 :: Nil)
+    WriteDependencies.writeDependencies(func1 :: func2 :: Nil, outputFile)
+    val deps = ConfigUtils.fileToConfigMap(outputFile)
+    deps("jobs") shouldBe a[Map[_, _]]
+    val jobs = deps("jobs").asInstanceOf[Map[String, Map[String, Any]]]
+    jobs.count(_._1.contains("Qfunc")) shouldBe 2
+
+    deps("files") shouldBe a[List[_]]
+    val files = deps("files").asInstanceOf[List[Map[String, Any]]]
+    val paths = files.map(x => x.get("path")).flatten
+    assert(paths.contains(file1.toString))
+    assert(paths.contains(file2.toString))
+    assert(paths.contains(file3.toString))
+
+    files.find(_.get("path") == Some(file1.toString)).flatMap(_.get("pipeline_input")) shouldBe Some(true)
+    files.find(_.get("path") == Some(file2.toString)).flatMap(_.get("pipeline_input")) shouldBe Some(false)
+    files.find(_.get("path") == Some(file3.toString)).flatMap(_.get("pipeline_input")) shouldBe Some(false)
   }
 }
 
-- 
GitLab