Repository: incubator-predictionio
Updated Branches:
  refs/heads/develop 84d683f74 -> 09d04edc4


PIO-42 : Negative Test Cases for Engine.train

Closes #322


Project: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-predictionio/commit/09d04edc
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-predictionio/tree/09d04edc
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-predictionio/diff/09d04edc

Branch: refs/heads/develop
Commit: 09d04edc4283a6946982bb18d229cd3f5635c958
Parents: 84d683f
Author: Rajdeep Dua <dua_rajd...@yahoo.com>
Authored: Fri Dec 16 10:26:56 2016 -0800
Committer: Donald Szeto <don...@apache.org>
Committed: Fri Dec 16 10:26:56 2016 -0800

----------------------------------------------------------------------
 .../predictionio/controller/EngineTest.scala    | 60 ++++++++++++++++++++
 1 file changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/09d04edc/core/src/test/scala/org/apache/predictionio/controller/EngineTest.scala
----------------------------------------------------------------------
diff --git 
a/core/src/test/scala/org/apache/predictionio/controller/EngineTest.scala 
b/core/src/test/scala/org/apache/predictionio/controller/EngineTest.scala
index c45ca33..65a363c 100644
--- a/core/src/test/scala/org/apache/predictionio/controller/EngineTest.scala
+++ b/core/src/test/scala/org/apache/predictionio/controller/EngineTest.scala
@@ -315,6 +315,66 @@ class EngineTrainSuite extends FunSuite with 
SharedSparkContext {
       PAlgo0.Model(2, pd), PAlgo1.Model(3, pd), PAlgo0.Model(4, pd))
   }
 
+  test("Empty Algos Sequence") {
+    val models = Engine.train(
+      sc,
+      new PDataSource0(0),
+      new PPreparator0(1),
+      Seq(),
+      defaultWorkflowParams
+    )
+
+    models should not be null
+  }
+
+  test("Null defaultWorkflowParams") {
+
+    an [NullPointerException] should be thrownBy Engine.train(
+      sc,
+      new PDataSource0(0),
+      new PPreparator0(1),
+      Seq(
+        new PAlgo0(2),
+        new PAlgo1(3),
+        new PAlgo0(4)),
+      null
+    )
+  }
+
+  test("Null Spark Context") {
+    // Shouldn't we check if Spark Context is empty ?
+    val models = Engine.train(
+      null,
+      new PDataSource0(0),
+      new PPreparator0(1),
+      Seq(
+        new PAlgo0(2),
+        new PAlgo1(3),
+        new PAlgo0(4)),
+      defaultWorkflowParams
+    )
+
+    val pd = ProcessedData(1, TrainingData(0))
+
+    models should contain theSameElementsAs Seq(
+      PAlgo0.Model(2, pd), PAlgo1.Model(3, pd), PAlgo0.Model(4, pd))
+  }
+
+  test("Null DataSource") {
+    // Shouldn't we check if Spark Context is empty ?
+    an [NullPointerException] should be thrownBy Engine.train(
+      sc,
+      null,
+      new PPreparator0(1),
+      Seq(
+        new PAlgo0(2),
+        new PAlgo1(3),
+        new PAlgo0(4)),
+      defaultWorkflowParams
+    )
+  }
+
+
   test("Local DS/P/Algos") {
     val models = Engine.train(
       sc,

Reply via email to