How to write a Mockito testcase for Spark DataFrame
<p>I have the following method :</p>

<pre><code>def subsetConversion(fPath: DataFrame): Tuple2[DataFrame, DataFrame] = {

  /* line 87*/ var convertedPaths = fPath.filter(fPath("Conversion") === 1)
  var nonConvertedPaths = fPath.filter(fPath("Conversion") === 0)

  var dataFrameTuple = (convertedPaths, nonConvertedPaths)

  logger.info("Returning converted and non converted data frames" + dataFrameTuple)

  dataFrameTuple

}
</code></pre>

<p>I've written the following testcase to test the above method :</p>

<pre><code>"subset Conversion Data" should "pass this test and divide the input data frame to a tuple of two data frames" in {
  val dataFrameInput = Mockito.mock(classOf[DataFrame])
  val subsetData = uJTrnsfrm.subsetConversion(dataFrameInput)    
  assert(subsetData.isInstanceOf[Tuple2[DataFrame, DataFrame]])    
}
</code></pre>

<p>where uJTrnsfrm is an instance of the class in which the subsetConversion method is present. On testing this, i get the following exception : </p>

<pre><code>    - should pass this test and divide the input data frame to a tuple of two data frames *** FAILED *** java.lang.NullPointerException:
  at com.accenture.aa.dmah.attribution.userjourney.LogisticRegressionUserJourneyTransformation.subsetConversion(LogisticRegressionUserJourneyTransformation.scala:87)
  at com.accenture.aa.dmah.test.attribution.userJourneyTransformation.LogisticRegressionUserJourneyTransformationTest$$anonfun$6.apply$mcV$sp(LogisticRegressionUserJourneyTransformationTest.scala:76)
  at com.accenture.aa.dmah.test.attribution.userJourneyTransformation.LogisticRegressionUserJourneyTransformationTest$$anonfun$6.apply(LogisticRegressionUserJourneyTransformationTest.scala:74)
  at com.accenture.aa.dmah.test.attribution.userJourneyTransformation.LogisticRegressionUserJourneyTransformationTest$$anonfun$6.apply(LogisticRegressionUserJourneyTransformationTest.scala:74)
  at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
  at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
  at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
  at org.scalatest.Transformer.apply(Transformer.scala:22)
  at org.scalatest.Transformer.apply(Transformer.scala:20)
  at org.scalatest.FlatSpecLike$$anon$1.apply(FlatSpecLike.scala:1647)
</code></pre>

<p>Any suggestions as to what i can do to run it successfully.</p>