diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala index 6aa905086ba8e9ee9f520f460ed9219ce77e3bec..9855e724819cdb4d9ed0c93e062f851c1cc2104f 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala @@ -58,10 +58,10 @@ object ConfigUtils extends Logging { * @param path Nested path to get from map * @return Nested map */ - def getMapFromPath(map: Map[String, Any], path: List[String]): Map[String, Any] = { - val value = getValueFromPath(map, path) getOrElse { return null } + def getMapFromPath(map: Map[String, Any], path: List[String]): Option[Map[String, Any]] = { + val value = getValueFromPath(map, path) getOrElse { return None } value match { - case m: Map[_, _] => m.asInstanceOf[Map[String, Any]] + case m: Map[_, _] => Some(m.asInstanceOf[Map[String, Any]]) case _ => throw new IllegalStateException("Value is not a map: " + value) } } diff --git a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala index 9aa474fa767a4f0d56d0b730ae92b11a9c1970c4..f85824aa8dfebc4984d3e2aa9b3cdaed8ad22588 100644 --- a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala +++ b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala @@ -26,8 +26,8 @@ class ConfigUtilsTest extends TestNGSuite with MockitoSugar with Matchers { } @Test def testGetMapFromPath: Unit = { - getMapFromPath(map1, List("dummy")) shouldBe Map("dummy" -> 1) - getMapFromPath(map1, List("nested3", "nested2", "nested1")) shouldBe Map("dummy" -> 1) + getMapFromPath(map1, List("dummy")) shouldBe Some(Map("dummy" -> 1)) + getMapFromPath(map1, List("nested3", "nested2", "nested1")) shouldBe Some(Map("dummy" -> 1)) intercept[IllegalStateException] { getMapFromPath(map1, List("dummy", "dummy")) }